Skip to content

Commit

Permalink
Allow overriding the manifestdescriptor when pushing (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecordell authored and jzelinskie committed Oct 14, 2019
1 parent ea5c23a commit 205efe3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
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

0 comments on commit 205efe3

Please sign in to comment.