-
Notifications
You must be signed in to change notification settings - Fork 1.3k
exporter/containerimage: default to oci-mediatypes=true #6095
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
base: master
Are you sure you want to change the base?
Changes from all commits
a7b2007
5ec168d
9e98782
eb6d9bf
add1e0e
76a3271
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,6 @@ import ( | |
| cacheconfig "github.com/moby/buildkit/cache/config" | ||
| "github.com/moby/buildkit/exporter/containerimage/exptypes" | ||
| "github.com/moby/buildkit/exporter/util/epoch" | ||
| "github.com/moby/buildkit/util/bklog" | ||
| "github.com/moby/buildkit/util/compression" | ||
| "github.com/pkg/errors" | ||
| ) | ||
|
|
@@ -49,7 +48,7 @@ func (c *ImageCommitOpts) Load(ctx context.Context, opt map[string]string) (map[ | |
| case exptypes.OptKeyName: | ||
| c.ImageName = v | ||
| case exptypes.OptKeyOCITypes: | ||
| err = parseBoolWithDefault(&c.OCITypes, k, v, true) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not handling the empty value in here seems like possibly breaking change. Don't remember the history behind it but maybe don't break it as it seems harmeless.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That change was made for the other types that originally used this parsing function, so based on that I'm relatively confident in/in favor of this change. |
||
| err = parseBool(&c.OCITypes, k, v) | ||
| case exptypes.OptKeyOCIArtifact: | ||
| err = parseBool(&c.OCIArtifact, k, v) | ||
| case exptypes.OptKeyForceInlineAttestations: | ||
|
|
@@ -67,42 +66,18 @@ func (c *ImageCommitOpts) Load(ctx context.Context, opt map[string]string) (map[ | |
| } | ||
| } | ||
|
|
||
| if c.RefCfg.Compression.Type.OnlySupportOCITypes() { | ||
| c.EnableOCITypes(ctx, c.RefCfg.Compression.Type.String()) | ||
| if c.RefCfg.Compression.Type.OnlySupportOCITypes() && !c.OCITypes { | ||
| return nil, errors.Errorf("exporter option \"compression=%s\" conflicts with \"oci-mediatypes=false\"", c.RefCfg.Compression.Type) | ||
| } | ||
| if c.OCIArtifact && !c.OCITypes { | ||
| c.EnableOCITypes(ctx, "oci-artifact") | ||
| return nil, errors.New("exporter option \"oci-artifact=true\" conflicts with \"oci-mediatypes=false\"") | ||
| } | ||
|
|
||
| c.Annotations = c.Annotations.Merge(as) | ||
|
|
||
| return rest, nil | ||
| } | ||
|
|
||
| func (c *ImageCommitOpts) EnableOCITypes(ctx context.Context, reason string) { | ||
| if !c.OCITypes { | ||
| message := "forcibly turning on oci-mediatype mode" | ||
| if reason != "" { | ||
| message += " for " + reason | ||
| } | ||
| bklog.G(ctx).Warn(message) | ||
|
|
||
| c.OCITypes = true | ||
| } | ||
| } | ||
|
|
||
| func (c *ImageCommitOpts) EnableForceCompression(ctx context.Context, reason string) { | ||
| if !c.RefCfg.Compression.Force { | ||
| message := "forcibly turning on force-compression mode" | ||
| if reason != "" { | ||
| message += " for " + reason | ||
| } | ||
| bklog.G(ctx).Warn(message) | ||
|
|
||
| c.RefCfg.Compression.Force = true | ||
| } | ||
| } | ||
|
|
||
| func parseBool(dest *bool, key string, value string) error { | ||
| b, err := strconv.ParseBool(value) | ||
| if err != nil { | ||
|
|
@@ -112,14 +87,6 @@ func parseBool(dest *bool, key string, value string) error { | |
| return nil | ||
| } | ||
|
|
||
| func parseBoolWithDefault(dest *bool, key string, value string, defaultValue bool) error { | ||
| if value == "" { | ||
| *dest = defaultValue | ||
| return nil | ||
| } | ||
| return parseBool(dest, key, value) | ||
| } | ||
|
|
||
| func toBytesMap(m map[string]string) map[string][]byte { | ||
| result := make(map[string][]byte) | ||
| for k, v := range m { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we start considering changing the defaults in code? (Have a "DisableOCITypes" boolean, and start sunsetting the "OCITypes" bool)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed this a bit; @tonistiigi expressed a preference for keeping the exporter as-is for now, and just initializing the instance with the modified default.