mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-09-06 09:21:28 +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 {
|
||||
Path string
|
||||
Directory bool
|
||||
Symlink string
|
||||
Contents string
|
||||
}
|
||||
Outputs []struct {
|
||||
@@ -438,7 +439,7 @@ func filesystem(m *Moby) (*bytes.Buffer, error) {
|
||||
if f.Path == "" {
|
||||
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")
|
||||
}
|
||||
// we need all the leading directories
|
||||
@@ -477,6 +478,17 @@ func filesystem(m *Moby) (*bytes.Buffer, error) {
|
||||
if err != nil {
|
||||
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 {
|
||||
hdr := &tar.Header{
|
||||
Name: f.Path,
|
||||
|
@@ -20,6 +20,7 @@ var schema = string(`
|
||||
"properties": {
|
||||
"path": {"type": "string"},
|
||||
"directory": {"type": "boolean"},
|
||||
"symlink": {"type": "string"},
|
||||
"contents": {"type": "string"}
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user