mirror of
https://github.com/linuxkit/linuxkit.git
synced 2026-04-03 10:43:54 +00:00
Allow some files specified with source to be optional
See discussion in https://github.com/linuxkit/linuxkit/pull/2027 Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
@@ -574,6 +574,14 @@ func filesystem(m Moby, tw *tar.Writer) error {
|
||||
if len(f.Source) > 2 && f.Source[:2] == "~/" {
|
||||
f.Source = homeDir() + f.Source[1:]
|
||||
}
|
||||
if f.Optional {
|
||||
_, err := os.Stat(f.Source)
|
||||
if err != nil {
|
||||
// skip if not found or readable
|
||||
log.Debugf("Skipping file [%s] as not readable and marked optional", f.Source)
|
||||
continue
|
||||
}
|
||||
}
|
||||
contents, err := ioutil.ReadFile(f.Source)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -32,6 +32,7 @@ type Moby struct {
|
||||
Symlink string
|
||||
Contents string
|
||||
Source string
|
||||
Optional bool
|
||||
Mode string
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ var schema = string(`
|
||||
"symlink": {"type": "string"},
|
||||
"contents": {"type": "string"},
|
||||
"source": {"type": "string"},
|
||||
"optional": {"type": "boolean"},
|
||||
"mode": {"type": "string"}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user