mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-20 09:39:08 +00:00
Update Image strings before writing them out
If the YAML file contains: - path: etc/linuxkit.yml metadata: yaml in the fil section, the image was build with content trust, then the linuxkit.yml file image contains fully qualified image references (including the sha256). Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
parent
ad83cb8928
commit
1aee0c3d30
@ -388,6 +388,8 @@ func tarAppend(iw *tar.Writer, tr *tar.Reader) error {
|
||||
|
||||
// this allows inserting metadata into a file in the image
|
||||
func metadata(m Moby, md string) ([]byte, error) {
|
||||
// Make sure the Image strings are update to date with the refs
|
||||
updateImages(&m)
|
||||
switch md {
|
||||
case "json":
|
||||
return json.MarshalIndent(m, "", " ")
|
||||
|
@ -197,6 +197,31 @@ func extractReferences(m *Moby) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func updateImages(m *Moby) error {
|
||||
if m.Kernel.ref != nil {
|
||||
m.Kernel.Image = m.Kernel.ref.String()
|
||||
}
|
||||
for i, ii := range m.initRefs {
|
||||
m.Init[i] = ii.String()
|
||||
}
|
||||
for _, image := range m.Onboot {
|
||||
if image.ref != nil {
|
||||
image.Image = image.ref.String()
|
||||
}
|
||||
}
|
||||
for _, image := range m.Onshutdown {
|
||||
if image.ref != nil {
|
||||
image.Image = image.ref.String()
|
||||
}
|
||||
}
|
||||
for _, image := range m.Services {
|
||||
if image.ref != nil {
|
||||
image.Image = image.ref.String()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewConfig parses a config file
|
||||
func NewConfig(config []byte) (Moby, error) {
|
||||
m := Moby{}
|
||||
|
Loading…
Reference in New Issue
Block a user