Skip to content

Commit

Permalink
code clean
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed May 10, 2024
1 parent 10b7016 commit 53392e2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
10 changes: 5 additions & 5 deletions cmd/oras/internal/option/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ const (
FormatTypeGoTemplate = "go-template"
)

// FormatType represents a custom type for formatting.
// FormatType represents a custom description in help doc.
type FormatType struct {
Name string
Usage string
}

// Format contains input and parsed options to format output.
// Format contains input and parsed options for formatted output flags.
type Format struct {
Type string
Template string
Expand Down Expand Up @@ -69,7 +69,7 @@ func (opts *Format) ApplyFlags(fs *pflag.FlagSet) {

// apply flags
fs.StringVar(&opts.Input, "format", opts.Input, usage)
fs.StringVar(&opts.Template, "template", "", `Template string used to format output`)
fs.StringVar(&opts.Template, "template", "", "Template string used to format output")
}

// Parse parses the input format flag.
Expand Down Expand Up @@ -98,6 +98,7 @@ func (opts *Format) Parse(_ *cobra.Command) error {
}

func (opts *Format) parseFlag() error {
opts.Type = opts.Input
if opts.Template != "" {
// template explicitly set
opts.Type = opts.Input
Expand All @@ -112,8 +113,6 @@ func (opts *Format) parseFlag() error {
// add parameter to template
opts.Type = FormatTypeGoTemplate
opts.Template = opts.Input[len(goTemplatePrefix):]
} else {
opts.Type = opts.Input
}
return nil
}
Expand All @@ -124,6 +123,7 @@ func (opts *Format) SetTypes(types []FormatType) {
}

// SetTypesAndDefault resets the format options and default value.
// Caller should make sure that this function is used before applying flags.
func (opts *Format) SetTypesAndDefault(defaultType string, types []FormatType) {
opts.Input = defaultType
opts.types = types
Expand Down
1 change: 0 additions & 1 deletion cmd/oras/root/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ Example - Discover referrers of the manifest tagged 'v1' in an OCI image layout
if err := oerrors.CheckMutuallyExclusiveFlags(cmd.Flags(), "format", "output"); err != nil {
return err
}

opts.RawReference = args[0]
if err := option.Parse(cmd, &opts); err != nil {
return err
Expand Down
1 change: 0 additions & 1 deletion cmd/oras/root/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ func runPull(cmd *cobra.Command, opts *pullOptions) error {
if err != nil {
return err
}

// Copy Options
copyOptions := oras.DefaultCopyOptions
copyOptions.Concurrency = opts.concurrency
Expand Down
1 change: 0 additions & 1 deletion cmd/oras/root/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ func runPush(cmd *cobra.Command, opts *pushOptions) error {
if err != nil {
return err
}

annotations, err := opts.LoadManifestAnnotations()
if err != nil {
return err
Expand Down

0 comments on commit 53392e2

Please sign in to comment.