Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segfault and add (optional) variant in image config #123

Merged
merged 1 commit into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions pkg/registry/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,26 @@ func resolvePlatform(descriptor ocispec.Descriptor, img types.ManifestEntry, img
platform = &ocispec.Platform{}
}
// fill os/arch from inspected image if not specified in input YAML
if img.Platform.OS == "" && img.Platform.Architecture == "" {
if platform.OS == "" && platform.Architecture == "" {
// prefer a full platform object, if one is already available (and appears to have meaningful content)
if descriptor.Platform.OS != "" || descriptor.Platform.Architecture != "" {
if descriptor.Platform != nil && (descriptor.Platform.OS != "" || descriptor.Platform.Architecture != "") {
platform = descriptor.Platform
} else if imgConfig.OS != "" || imgConfig.Architecture != "" {
platform.OS = imgConfig.OS
platform.Architecture = imgConfig.Architecture
}
}
// if Variant is specified in the origin image but not the descriptor or YAML, bubble it up
if imgConfig.Variant != "" && platform.Variant == "" {
platform.Variant = imgConfig.Variant
}
// Windows: if the origin image has OSFeature and/or OSVersion information, and
// these values were not specified in the creation YAML, then
// retain the origin values in the Platform definition for the manifest list:
if imgConfig.OSVersion != "" && img.Platform.OSVersion == "" {
if imgConfig.OSVersion != "" && platform.OSVersion == "" {
platform.OSVersion = imgConfig.OSVersion
}
if len(imgConfig.OSFeatures) > 0 && len(img.Platform.OSFeatures) == 0 {
if len(imgConfig.OSFeatures) > 0 && len(platform.OSFeatures) == 0 {
platform.OSFeatures = imgConfig.OSFeatures
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/types/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const (
// Image struct handles Windows support extensions to OCI spec
type Image struct {
ocispec.Image
// TODO https://github.com/opencontainers/image-spec/pull/809
Variant string `json:"variant,omitempty"`
OSVersion string `json:"os.version,omitempty"`
OSFeatures []string `json:"os.features,omitempty"`
}