mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 09:39:08 +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:
parent
d534273407
commit
4d64a46ae9
@ -574,6 +574,14 @@ func filesystem(m Moby, tw *tar.Writer) error {
|
|||||||
if len(f.Source) > 2 && f.Source[:2] == "~/" {
|
if len(f.Source) > 2 && f.Source[:2] == "~/" {
|
||||||
f.Source = homeDir() + f.Source[1:]
|
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)
|
contents, err := ioutil.ReadFile(f.Source)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -32,6 +32,7 @@ type Moby struct {
|
|||||||
Symlink string
|
Symlink string
|
||||||
Contents string
|
Contents string
|
||||||
Source string
|
Source string
|
||||||
|
Optional bool
|
||||||
Mode string
|
Mode string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ var schema = string(`
|
|||||||
"symlink": {"type": "string"},
|
"symlink": {"type": "string"},
|
||||||
"contents": {"type": "string"},
|
"contents": {"type": "string"},
|
||||||
"source": {"type": "string"},
|
"source": {"type": "string"},
|
||||||
|
"optional": {"type": "boolean"},
|
||||||
"mode": {"type": "string"}
|
"mode": {"type": "string"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -58,12 +58,17 @@ files:
|
|||||||
source: "/some/path/on/local/filesystem"
|
source: "/some/path/on/local/filesystem"
|
||||||
mode: "0666"
|
mode: "0666"
|
||||||
- path: dir/name2
|
- path: dir/name2
|
||||||
|
source: "/some/path/that/it/is/ok/to/omit"
|
||||||
|
optional: true
|
||||||
|
mode: "0666"
|
||||||
|
- path: dir/name3
|
||||||
contents: "orange"
|
contents: "orange"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
```
|
```
|
||||||
|
|
||||||
Specifying the `mode` is optional, and will default to `0600`. Leading directories will be
|
Specifying the `mode` is optional, and will default to `0600`. Leading directories will be
|
||||||
created if not specified.
|
created if not specified. You can use `~/path` in `source` to specify a path in the build
|
||||||
|
user's home directory.
|
||||||
|
|
||||||
## `trust`
|
## `trust`
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user