Skip to content

Commit

Permalink
fix: fix bugs related to the spec --distribution-spec (oras-project…
Browse files Browse the repository at this point in the history
…#772)

Signed-off-by: Sylvia Lei <lixlei@microsoft.com>
  • Loading branch information
Wwwsylvia authored and TerryHowe committed Feb 2, 2023
1 parent 9939299 commit 02db59c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions cmd/oras/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Example - Attach file to the manifest tagged 'v1' in an OCI layout folder 'layou
cmd.Flags().StringVarP(&opts.artifactType, "artifact-type", "", "", "artifact type")
cmd.Flags().IntVarP(&opts.concurrency, "concurrency", "", 5, "concurrency level")
cmd.MarkFlagRequired("artifact-type")
opts.EnableDistributionSpecFlag()
option.ApplyFlags(&opts, cmd.Flags())
return cmd
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/oras/internal/option/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ func (opts *Remote) ApplyFlagsWithPrefix(fs *pflag.FlagSet, prefix, description

// Parse tries to read password with optional cmd prompt.
func (opts *Remote) Parse() error {
return opts.readPassword()
if err := opts.readPassword(); err != nil {
return err
}
return opts.distributionSpec.Parse()
}

// readPassword tries to read password with optional cmd prompt.
Expand Down
7 changes: 2 additions & 5 deletions cmd/oras/internal/option/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package option

import (
"context"
"errors"
"fmt"
"os"
"strings"
Expand Down Expand Up @@ -84,13 +83,11 @@ func (opts *Target) Parse() error {
switch {
case opts.isOCILayout:
opts.Type = TargetTypeOCILayout
if opts.Remote.distributionSpec.referrersAPI != nil {
return errors.New("cannot enforce referrers API for image layout target")
}
return nil
default:
opts.Type = TargetTypeRemote
return opts.Remote.Parse()
}
return nil
}

// parseOCILayoutReference parses the raw in format of <path>[:<tag>|@<digest>]
Expand Down

0 comments on commit 02db59c

Please sign in to comment.