mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-09-06 17:32:26 +00:00
Add support for symlinks in files section
Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
@@ -32,6 +32,7 @@ type Moby struct {
|
|||||||
Files []struct {
|
Files []struct {
|
||||||
Path string
|
Path string
|
||||||
Directory bool
|
Directory bool
|
||||||
|
Symlink string
|
||||||
Contents string
|
Contents string
|
||||||
}
|
}
|
||||||
Outputs []struct {
|
Outputs []struct {
|
||||||
@@ -438,7 +439,7 @@ func filesystem(m *Moby) (*bytes.Buffer, error) {
|
|||||||
if f.Path == "" {
|
if f.Path == "" {
|
||||||
return buf, errors.New("Did not specify path for file")
|
return buf, errors.New("Did not specify path for file")
|
||||||
}
|
}
|
||||||
if !f.Directory && f.Contents == "" {
|
if !f.Directory && f.Contents == "" && f.Symlink == "" {
|
||||||
return buf, errors.New("Contents of file not specified")
|
return buf, errors.New("Contents of file not specified")
|
||||||
}
|
}
|
||||||
// we need all the leading directories
|
// we need all the leading directories
|
||||||
@@ -477,6 +478,17 @@ func filesystem(m *Moby) (*bytes.Buffer, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return buf, err
|
return buf, err
|
||||||
}
|
}
|
||||||
|
} else if f.Symlink != "" {
|
||||||
|
hdr := &tar.Header{
|
||||||
|
Name: f.Path,
|
||||||
|
Typeflag: tar.TypeSymlink,
|
||||||
|
Mode: 0600,
|
||||||
|
Linkname: f.Symlink,
|
||||||
|
}
|
||||||
|
err := tw.WriteHeader(hdr)
|
||||||
|
if err != nil {
|
||||||
|
return buf, err
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
hdr := &tar.Header{
|
hdr := &tar.Header{
|
||||||
Name: f.Path,
|
Name: f.Path,
|
||||||
|
@@ -20,6 +20,7 @@ var schema = string(`
|
|||||||
"properties": {
|
"properties": {
|
||||||
"path": {"type": "string"},
|
"path": {"type": "string"},
|
||||||
"directory": {"type": "boolean"},
|
"directory": {"type": "boolean"},
|
||||||
|
"symlink": {"type": "string"},
|
||||||
"contents": {"type": "string"}
|
"contents": {"type": "string"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user