Skip to content

Commit

Permalink
opt to change config media type (oras-project#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
shizhMSFT authored May 6, 2019
1 parent 39de067 commit 691760d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/oras/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ func pack(provider content.Provider, descriptors []ocispec.Descriptor, opts *pus
if opts.configAnnotations != nil {
config.Annotations = opts.configAnnotations
}
if opts.configMediaType != "" {
config.MediaType = opts.configMediaType
}

// Manifest
manifest := ocispec.Manifest{
Expand Down
9 changes: 9 additions & 0 deletions pkg/oras/push_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

type pushOpts struct {
config *ocispec.Descriptor
configMediaType string
configAnnotations map[string]string
manifestAnnotations map[string]string
validateName func(desc ocispec.Descriptor) error
Expand All @@ -36,6 +37,14 @@ func WithConfig(config ocispec.Descriptor) PushOpt {
}
}

// WithConfigMediaType overrides the config media type
func WithConfigMediaType(mediaType string) PushOpt {
return func(o *pushOpts) error {
o.configMediaType = mediaType
return nil
}
}

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

0 comments on commit 691760d

Please sign in to comment.