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

Allow overriding the ManifestDescriptor when pushing #133

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/oras/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ func pack(provider content.Provider, descriptors []ocispec.Descriptor, opts *pus
}

// Manifest
if opts.manifest != nil {
return *opts.manifest, store, nil
}

manifest := ocispec.Manifest{
Versioned: specs.Versioned{
SchemaVersion: 2, // historical value. does not pertain to OCI or docker version
Expand Down
11 changes: 10 additions & 1 deletion pkg/oras/push_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type pushOpts struct {
config *ocispec.Descriptor
configMediaType string
configAnnotations map[string]string
manifest *ocispec.Descriptor
manifestAnnotations map[string]string
validateName func(desc ocispec.Descriptor) error
baseHandlers []images.Handler
Expand All @@ -29,7 +30,7 @@ func pushOptsDefaults() *pushOpts {
// PushOpt allows callers to set options on the oras push
type PushOpt func(o *pushOpts) error

// WithConfig overrides the config
// WithConfig overrides the config - setting this will ignore WithConfigMediaType and WithConfigAnnotations
func WithConfig(config ocispec.Descriptor) PushOpt {
return func(o *pushOpts) error {
o.config = &config
Expand All @@ -53,6 +54,14 @@ func WithConfigAnnotations(annotations map[string]string) PushOpt {
}
}

// WithManifest overrides the manifest - setting this will ignore WithManifestConfigAnnotations
func WithManifest(manifest ocispec.Descriptor) PushOpt {
return func(o *pushOpts) error {
o.manifest = &manifest
return nil
}
}

// WithManifestAnnotations overrides the manifest annotations
func WithManifestAnnotations(annotations map[string]string) PushOpt {
return func(o *pushOpts) error {
Expand Down