mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-21 10:09:07 +00:00
Support creating of directories in files section
e.g. files: - path: etc/docker/daemon.json contents: '{"debug": true}' - path: var/lib/mydaemon directory: true Signed-off-by: Ian Campbell <ian.campbell@docker.com>
This commit is contained in:
parent
1602277ba7
commit
a3ac69639b
@ -29,6 +29,7 @@ type Moby struct {
|
|||||||
Daemon []MobyImage
|
Daemon []MobyImage
|
||||||
Files []struct {
|
Files []struct {
|
||||||
Path string
|
Path string
|
||||||
|
Directory bool
|
||||||
Contents string
|
Contents string
|
||||||
}
|
}
|
||||||
Outputs []struct {
|
Outputs []struct {
|
||||||
@ -385,7 +386,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.Contents == "" {
|
if !f.Directory && f.Contents == "" {
|
||||||
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
|
||||||
@ -410,6 +411,21 @@ func filesystem(m *Moby) (*bytes.Buffer, error) {
|
|||||||
return buf, err
|
return buf, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if f.Directory {
|
||||||
|
if f.Contents != "" {
|
||||||
|
return buf, errors.New("Directory with contents not allowed")
|
||||||
|
}
|
||||||
|
hdr := &tar.Header{
|
||||||
|
Name: f.Path,
|
||||||
|
Typeflag: tar.TypeDir,
|
||||||
|
Mode: 0700,
|
||||||
|
}
|
||||||
|
err := tw.WriteHeader(hdr)
|
||||||
|
if err != nil {
|
||||||
|
return buf, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
hdr := &tar.Header{
|
hdr := &tar.Header{
|
||||||
Name: f.Path,
|
Name: f.Path,
|
||||||
Mode: 0600,
|
Mode: 0600,
|
||||||
@ -424,5 +440,6 @@ func filesystem(m *Moby) (*bytes.Buffer, error) {
|
|||||||
return buf, err
|
return buf, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return buf, nil
|
return buf, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user