Skip to content

Commit

Permalink
fix: resolve comment
Browse files Browse the repository at this point in the history
Signed-off-by: Junjie Gao <[email protected]>
  • Loading branch information
JeyJeyGao committed Dec 5, 2022
1 parent c789f57 commit 994a564
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cmd/notation/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func listCommand(opts *listOpts) *cobra.Command {
func runList(command *cobra.Command, opts *listOpts) error {
// initialize
reference := opts.reference
sigRepo, err := getSignatureRepositoryClient(command.Context(), &opts.SecureFlagOpts, reference)
sigRepo, err := getSignatureRepository(command.Context(), &opts.SecureFlagOpts, reference)
if err != nil {
return err
}
Expand Down
28 changes: 14 additions & 14 deletions cmd/notation/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"oras.land/oras-go/v2/registry/remote/auth"
)

func getSignatureRepositoryClient(ctx context.Context, opts *SecureFlagOpts, reference string) (notationregistry.Repository, error) {
func getSignatureRepository(ctx context.Context, opts *SecureFlagOpts, reference string) (notationregistry.Repository, error) {
ref, err := registry.ParseReference(reference)
if err != nil {
return nil, err
Expand All @@ -28,6 +28,19 @@ func getSignatureRepositoryClient(ctx context.Context, opts *SecureFlagOpts, ref
return getRepositoryClient(ctx, opts, ref)
}

func getRegistryClient(ctx context.Context, opts *SecureFlagOpts, serverAddress string) (*remote.Registry, error) {
reg, err := remote.NewRegistry(serverAddress)
if err != nil {
return nil, err
}

reg.Client, reg.PlainHTTP, err = getAuthClient(ctx, opts, reg.Reference)
if err != nil {
return nil, err
}
return reg, nil
}

func getRepositoryClient(ctx context.Context, opts *SecureFlagOpts, ref registry.Reference) (notationregistry.Repository, error) {
authClient, plainHTTP, err := getAuthClient(ctx, opts, ref)
if err != nil {
Expand Down Expand Up @@ -55,19 +68,6 @@ func setHttpDebugLog(ctx context.Context, authClient *auth.Client) {
authClient.Client.Transport = trace.NewTransport(authClient.Client.Transport)
}

func getRegistryClient(ctx context.Context, opts *SecureFlagOpts, serverAddress string) (*remote.Registry, error) {
reg, err := remote.NewRegistry(serverAddress)
if err != nil {
return nil, err
}

reg.Client, reg.PlainHTTP, err = getAuthClient(ctx, opts, reg.Reference)
if err != nil {
return nil, err
}
return reg, nil
}

func getAuthClient(ctx context.Context, opts *SecureFlagOpts, ref registry.Reference) (*auth.Client, bool, error) {
var plainHTTP bool

Expand Down
2 changes: 1 addition & 1 deletion cmd/notation/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func runSign(command *cobra.Command, cmdOpts *signOpts) error {
if err != nil {
return err
}
sigRepo, err := getSignatureRepositoryClient(ctx, &cmdOpts.SecureFlagOpts, cmdOpts.reference)
sigRepo, err := getSignatureRepository(ctx, &cmdOpts.SecureFlagOpts, cmdOpts.reference)
if err != nil {
return err
}
Expand Down

0 comments on commit 994a564

Please sign in to comment.