Skip to content

Commit

Permalink
Remove media type options for pull operation (#387)
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah authored May 18, 2022
1 parent 32f1daa commit 054fa1d
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions cmd/oras/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ import (
)

type pullOptions struct {
targetRef string
allowedMediaTypes []string
allowAllMediaTypes bool
keepOldFiles bool
pathTraversal bool
output string
manifestConfigRef string
verbose bool
cacheRoot string
targetRef string
keepOldFiles bool
pathTraversal bool
output string
manifestConfigRef string
verbose bool
cacheRoot string

debug bool
configs []string
Expand Down Expand Up @@ -72,8 +70,6 @@ Example - Pull files with local cache:
},
}

cmd.Flags().StringArrayVarP(&opts.allowedMediaTypes, "media-type", "t", nil, "allowed media types to be pulled")
cmd.Flags().BoolVarP(&opts.allowAllMediaTypes, "allow-all", "a", false, "allow all media types to be pulled")
cmd.Flags().BoolVarP(&opts.keepOldFiles, "keep-old-files", "k", false, "do not replace existing files when pulling, treat them as errors")
cmd.Flags().BoolVarP(&opts.pathTraversal, "allow-path-traversal", "T", false, "allow storing files out of the output directory")
cmd.Flags().StringVarP(&opts.output, "output", "o", "", "output directory")
Expand All @@ -96,20 +92,13 @@ func runPull(opts pullOptions) error {
} else if !opts.verbose {
ctx = ctxo.WithLoggerDiscarded(ctx)
}
if opts.allowAllMediaTypes {
opts.allowedMediaTypes = nil
} else if len(opts.allowedMediaTypes) == 0 {
opts.allowedMediaTypes = []string{content.DefaultBlobMediaType, content.DefaultBlobDirMediaType}
}

resolver := newResolver(opts.username, opts.password, opts.insecure, opts.plainHTTP, opts.configs...)
store := content.NewFileStore(opts.output)
defer store.Close()
store.DisableOverwrite = opts.keepOldFiles
store.AllowPathTraversalOnWrite = opts.pathTraversal

pullOpts := []oras.PullOpt{
oras.WithAllowedMediaTypes(opts.allowedMediaTypes),
oras.WithPullStatusTrack(os.Stdout),
}
if opts.cacheRoot != "" {
Expand Down

0 comments on commit 054fa1d

Please sign in to comment.