Skip to content

Commit c9d84ae

Browse files
committed
fix: generate OCI-compliant image config
Related: #12537 According to the OCI image spec, the `RootFS` MUST have a `Type` with a value of `layers` (see [spec](https://github.com/opencontainers/image-spec/blob/26647a49f642c7d22a1cd3aa0a48e4650a542269/config.md?plain=1#L215)) Instead of initializing a `v1.ConfigFile`, we can use the `empty` package to get a "correct", empty image config, which includes the `Type: "layers"` field in `RootFS` ([see here](https://github.com/google/go-containerregistry/blob/e075f209120b2467fd1b7d24727f1890a0edb74a/pkg/v1/empty/image.go#L41-L48)). Signed-off-by: Laura Brehm <laurabrehm@hey.com>
1 parent 7a4b2b3 commit c9d84ae

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

pkg/imager/out.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,12 @@ func (i *Imager) outInstaller(ctx context.Context, path string, report *reporter
450450
newInstallerImg := mutate.MediaType(empty.Image, types.OCIManifestSchema1)
451451
newInstallerImg = mutate.ConfigMediaType(newInstallerImg, types.OCIConfigJSON)
452452

453-
newInstallerImg, err = mutate.ConfigFile(newInstallerImg, &v1.ConfigFile{
454-
Architecture: i.prof.Arch,
455-
OS: "linux",
456-
})
453+
// `empty.Image` won't error, so no need to check
454+
newCfgFile, _ := empty.Image.ConfigFile() //nolint:errcheck
455+
newCfgFile.Architecture = i.prof.Arch
456+
newCfgFile.OS = "linux"
457+
458+
newInstallerImg, err = mutate.ConfigFile(newInstallerImg, newCfgFile)
457459
if err != nil {
458460
return fmt.Errorf("failed to set image architecture: %w", err)
459461
}

0 commit comments

Comments
 (0)