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

Remove media type options for pull operation #387

Merged
merged 2 commits into from
May 18, 2022
Merged
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
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