From 7caa240601785c7c17cf72a186405b69da1fc9b0 Mon Sep 17 00:00:00 2001 From: Junjie Gao Date: Fri, 2 Dec 2022 22:04:32 +0800 Subject: [PATCH] fix: update to refactor set http debug log Signed-off-by: Junjie Gao --- cmd/notation/list.go | 2 +- cmd/notation/login.go | 2 +- cmd/notation/manifest.go | 10 +++++----- cmd/notation/registry.go | 2 +- cmd/notation/sign.go | 4 ++-- cmd/notation/verify.go | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/notation/list.go b/cmd/notation/list.go index ddda5f801..440018816 100644 --- a/cmd/notation/list.go +++ b/cmd/notation/list.go @@ -51,7 +51,7 @@ func runList(command *cobra.Command, opts *listOpts) error { sigRepo := notationRegistry.NewRepository(remoteRepo) // core process - manifestDesc, err := getManifestDescriptorFromReference(command.Context(), &opts.SecureFlagOpts, reference, false) + manifestDesc, err := getManifestDescriptorFromReference(command.Context(), &opts.SecureFlagOpts, reference) if err != nil { return err } diff --git a/cmd/notation/login.go b/cmd/notation/login.go index 5079386b2..2bee48b7a 100644 --- a/cmd/notation/login.go +++ b/cmd/notation/login.go @@ -82,7 +82,7 @@ func runLogin(cmd *cobra.Command, opts *loginOpts) error { } func validateAuthConfig(ctx context.Context, opts *loginOpts, serverAddress string) error { - registry, err := getRegistryClient(&opts.SecureFlagOpts, serverAddress, false) + registry, err := getRegistryClient(&opts.SecureFlagOpts, serverAddress) if err != nil { return err } diff --git a/cmd/notation/manifest.go b/cmd/notation/manifest.go index d0d649adb..aee03c0ba 100644 --- a/cmd/notation/manifest.go +++ b/cmd/notation/manifest.go @@ -4,20 +4,20 @@ import ( "context" "errors" - notationregistry "github.com/notaryproject/notation-go/registry" + notationRegistry "github.com/notaryproject/notation-go/registry" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "oras.land/oras-go/v2/registry" ) -func getManifestDescriptorFromContext(ctx context.Context, opts *SecureFlagOpts, ref string, debug bool) (ocispec.Descriptor, error) { +func getManifestDescriptorFromContext(ctx context.Context, opts *SecureFlagOpts, ref string) (ocispec.Descriptor, error) { if ref == "" { return ocispec.Descriptor{}, errors.New("missing reference") } - return getManifestDescriptorFromReference(ctx, opts, ref, debug) + return getManifestDescriptorFromReference(ctx, opts, ref) } -func getManifestDescriptorFromReference(ctx context.Context, opts *SecureFlagOpts, reference string, debug bool) (ocispec.Descriptor, error) { +func getManifestDescriptorFromReference(ctx context.Context, opts *SecureFlagOpts, reference string) (ocispec.Descriptor, error) { ref, err := registry.ParseReference(reference) if err != nil { return ocispec.Descriptor{}, err @@ -26,5 +26,5 @@ func getManifestDescriptorFromReference(ctx context.Context, opts *SecureFlagOpt if err != nil { return ocispec.Descriptor{}, err } - return notationregistry.NewRepository(repository).Resolve(ctx, ref.ReferenceOrDefault()) + return notationRegistry.NewRepository(repository).Resolve(ctx, ref.ReferenceOrDefault()) } diff --git a/cmd/notation/registry.go b/cmd/notation/registry.go index 9c9a9625d..81618f62e 100644 --- a/cmd/notation/registry.go +++ b/cmd/notation/registry.go @@ -50,7 +50,7 @@ func setHttpDebugLog(repo *remote.Repository, debug bool) { } } -func getRegistryClient(opts *SecureFlagOpts, serverAddress string, debug bool) (*remote.Registry, error) { +func getRegistryClient(opts *SecureFlagOpts, serverAddress string) (*remote.Registry, error) { reg, err := remote.NewRegistry(serverAddress) if err != nil { return nil, err diff --git a/cmd/notation/sign.go b/cmd/notation/sign.go index bf24ba6cf..51f2811bb 100644 --- a/cmd/notation/sign.go +++ b/cmd/notation/sign.go @@ -79,7 +79,7 @@ func runSign(command *cobra.Command, cmdOpts *signOpts) error { } // core process - desc, opts, err := prepareSigningContent(command.Context(), cmdOpts) + desc, opts, err := prepareSigningContent(ctx, cmdOpts) if err != nil { return err } @@ -100,7 +100,7 @@ func runSign(command *cobra.Command, cmdOpts *signOpts) error { } func prepareSigningContent(ctx context.Context, opts *signOpts) (ocispec.Descriptor, notation.SignOptions, error) { - manifestDesc, err := getManifestDescriptorFromContext(ctx, &opts.SecureFlagOpts, opts.reference, opts.Debug) + manifestDesc, err := getManifestDescriptorFromContext(ctx, &opts.SecureFlagOpts, opts.reference) if err != nil { return ocispec.Descriptor{}, notation.SignOptions{}, err } diff --git a/cmd/notation/verify.go b/cmd/notation/verify.go index 9d085f798..c578edb55 100644 --- a/cmd/notation/verify.go +++ b/cmd/notation/verify.go @@ -110,7 +110,7 @@ func resolveReference(command *cobra.Command, opts *verifyOpts) (registry.Refere } // Resolve tag reference to digest reference. - manifestDesc, err := getManifestDescriptorFromReference(command.Context(), &opts.SecureFlagOpts, opts.reference, opts.Debug) + manifestDesc, err := getManifestDescriptorFromReference(command.Context(), &opts.SecureFlagOpts, opts.reference) if err != nil { return registry.Reference{}, err }