From 4df1548c1e6bb58708326634fc235d32b638df20 Mon Sep 17 00:00:00 2001 From: Meredith Lancaster Date: Mon, 4 Mar 2024 15:36:48 -0700 Subject: [PATCH] rename logger pkg to logger Signed-off-by: Meredith Lancaster --- pkg/cmd/attestation/download/download.go | 4 ++-- pkg/cmd/attestation/download/download_test.go | 4 ++-- pkg/cmd/attestation/download/options.go | 4 ++-- pkg/cmd/attestation/inspect/inspect.go | 4 ++-- pkg/cmd/attestation/inspect/inspect_test.go | 4 ++-- pkg/cmd/attestation/inspect/options.go | 4 ++-- pkg/cmd/attestation/{logger => logging}/logger.go | 2 +- pkg/cmd/attestation/verification/sigstore.go | 6 +++--- pkg/cmd/attestation/verify/options.go | 4 ++-- pkg/cmd/attestation/verify/verify.go | 6 +++--- pkg/cmd/attestation/verify/verify_test.go | 6 +++--- pkg/cmd/attestation/verifytufroot/verify-tuf-root.go | 4 ++-- 12 files changed, 26 insertions(+), 26 deletions(-) rename pkg/cmd/attestation/{logger => logging}/logger.go (99%) diff --git a/pkg/cmd/attestation/download/download.go b/pkg/cmd/attestation/download/download.go index 30c5bfe5e..6475a7840 100644 --- a/pkg/cmd/attestation/download/download.go +++ b/pkg/cmd/attestation/download/download.go @@ -8,7 +8,7 @@ import ( "github.com/cli/cli/v2/pkg/cmdutil" "github.com/cli/cli/v2/pkg/cmd/attestation/artifact" "github.com/cli/cli/v2/pkg/cmd/attestation/api" - "github.com/cli/cli/v2/pkg/cmd/attestation/logger" + "github.com/cli/cli/v2/pkg/cmd/attestation/logging" "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" @@ -57,7 +57,7 @@ func NewDownloadCmd(f *cmdutil.Factory) *cobra.Command { opts.APIClient = api.NewLiveClient() // Create a logger for use throughout the download command - opts.Logger = logger.NewLogger(f.IOStreams, false, opts.Verbose) + opts.Logger = logging.NewLogger(f.IOStreams, false, opts.Verbose) // Configure the live OCI client opts.ConfigureOCIClient() diff --git a/pkg/cmd/attestation/download/download_test.go b/pkg/cmd/attestation/download/download_test.go index 528e435ff..e5d77d9f0 100644 --- a/pkg/cmd/attestation/download/download_test.go +++ b/pkg/cmd/attestation/download/download_test.go @@ -9,7 +9,7 @@ import ( "github.com/cli/cli/v2/pkg/cmd/attestation/api" "github.com/cli/cli/v2/pkg/cmd/attestation/artifact" "github.com/cli/cli/v2/pkg/cmd/attestation/artifact/oci" - "github.com/cli/cli/v2/pkg/cmd/attestation/logger" + "github.com/cli/cli/v2/pkg/cmd/attestation/logging" "github.com/cli/cli/v2/pkg/cmd/attestation/test" "github.com/stretchr/testify/assert" @@ -31,7 +31,7 @@ func TestRunDownload(t *testing.T) { DigestAlgorithm: "sha512", OutputPath: tempDir, Limit: 30, - Logger: logger.NewSystemLogger(), + Logger: logging.NewSystemLogger(), } t.Run("fetch and store attestations successfully", func(t *testing.T) { diff --git a/pkg/cmd/attestation/download/options.go b/pkg/cmd/attestation/download/options.go index 9b330bb85..07c1e3c7c 100644 --- a/pkg/cmd/attestation/download/options.go +++ b/pkg/cmd/attestation/download/options.go @@ -6,14 +6,14 @@ import ( "github.com/cli/cli/v2/pkg/cmd/attestation/api" "github.com/cli/cli/v2/pkg/cmd/attestation/artifact/digest" "github.com/cli/cli/v2/pkg/cmd/attestation/artifact/oci" - "github.com/cli/cli/v2/pkg/cmd/attestation/logger" + "github.com/cli/cli/v2/pkg/cmd/attestation/logging" ) type Options struct { ArtifactPath string DigestAlgorithm string APIClient api.Client - Logger *logger.Logger + Logger *logging.Logger Limit int OCIClient oci.Client OutputPath string diff --git a/pkg/cmd/attestation/inspect/inspect.go b/pkg/cmd/attestation/inspect/inspect.go index e2c8c4f51..1b3179cd2 100644 --- a/pkg/cmd/attestation/inspect/inspect.go +++ b/pkg/cmd/attestation/inspect/inspect.go @@ -7,7 +7,7 @@ import ( "github.com/cli/cli/v2/pkg/cmdutil" "github.com/cli/cli/v2/pkg/cmd/attestation/artifact" - "github.com/cli/cli/v2/pkg/cmd/attestation/logger" + "github.com/cli/cli/v2/pkg/cmd/attestation/logging" "github.com/cli/cli/v2/pkg/cmd/attestation/verification" "github.com/MakeNowJust/heredoc" @@ -50,7 +50,7 @@ func NewInspectCmd(f *cmdutil.Factory) *cobra.Command { `), PreRunE: func(cmd *cobra.Command, args []string) error { // Create a logger for use throughout the inspect command - opts.Logger = logger.NewDefaultLogger(f.IOStreams) + opts.Logger = logging.NewDefaultLogger(f.IOStreams) // set the artifact path opts.ArtifactPath = args[0] diff --git a/pkg/cmd/attestation/inspect/inspect_test.go b/pkg/cmd/attestation/inspect/inspect_test.go index 92a682dc5..6f480eb1e 100644 --- a/pkg/cmd/attestation/inspect/inspect_test.go +++ b/pkg/cmd/attestation/inspect/inspect_test.go @@ -3,7 +3,7 @@ package inspect import ( "testing" - "github.com/cli/cli/v2/pkg/cmd/attestation/logger" + "github.com/cli/cli/v2/pkg/cmd/attestation/logging" "github.com/cli/cli/v2/pkg/cmd/attestation/test" "github.com/stretchr/testify/assert" @@ -23,7 +23,7 @@ func TestRunInspect(t *testing.T) { res := test.SuppressAndRestoreOutput() defer res() - logger := logger.NewSystemLogger() + logger := logging.NewSystemLogger() opts := Options{ ArtifactPath: artifactPath, diff --git a/pkg/cmd/attestation/inspect/options.go b/pkg/cmd/attestation/inspect/options.go index 6c028bfc4..a4b117b7c 100644 --- a/pkg/cmd/attestation/inspect/options.go +++ b/pkg/cmd/attestation/inspect/options.go @@ -6,7 +6,7 @@ import ( "github.com/cli/cli/v2/pkg/cmd/attestation/artifact/digest" "github.com/cli/cli/v2/pkg/cmd/attestation/artifact/oci" - "github.com/cli/cli/v2/pkg/cmd/attestation/logger" + "github.com/cli/cli/v2/pkg/cmd/attestation/logging" ) // Options captures the options for the inspect command @@ -16,7 +16,7 @@ type Options struct { DigestAlgorithm string JsonResult bool Verbose bool - Logger *logger.Logger + Logger *logging.Logger OCIClient oci.Client } diff --git a/pkg/cmd/attestation/logger/logger.go b/pkg/cmd/attestation/logging/logger.go similarity index 99% rename from pkg/cmd/attestation/logger/logger.go rename to pkg/cmd/attestation/logging/logger.go index e46cf70e7..86c60e54c 100644 --- a/pkg/cmd/attestation/logger/logger.go +++ b/pkg/cmd/attestation/logging/logger.go @@ -1,4 +1,4 @@ -package logger +package logging import ( "fmt" diff --git a/pkg/cmd/attestation/verification/sigstore.go b/pkg/cmd/attestation/verification/sigstore.go index f68821d6f..9ac93e353 100644 --- a/pkg/cmd/attestation/verification/sigstore.go +++ b/pkg/cmd/attestation/verification/sigstore.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/cli/cli/v2/pkg/cmd/attestation/api" - "github.com/cli/cli/v2/pkg/cmd/attestation/logger" + "github.com/cli/cli/v2/pkg/cmd/attestation/logging" "github.com/sigstore/sigstore-go/pkg/bundle" "github.com/sigstore/sigstore-go/pkg/root" @@ -30,7 +30,7 @@ type SigstoreResults struct { type SigstoreConfig struct { CustomTrustedRoot string - Logger *logger.Logger + Logger *logging.Logger NoPublicGood bool } @@ -40,7 +40,7 @@ type SigstoreVerifier struct { customVerifier *verify.SignedEntityVerifier policy verify.PolicyBuilder onlyVerifyWithGithub bool - Logger *logger.Logger + Logger *logging.Logger } // NewSigstoreVerifier creates a new SigstoreVerifier struct diff --git a/pkg/cmd/attestation/verify/options.go b/pkg/cmd/attestation/verify/options.go index 6d4a5a7f0..3ede5e077 100644 --- a/pkg/cmd/attestation/verify/options.go +++ b/pkg/cmd/attestation/verify/options.go @@ -8,7 +8,7 @@ import ( "github.com/cli/cli/v2/pkg/cmd/attestation/artifact/digest" "github.com/cli/cli/v2/pkg/cmd/attestation/artifact/oci" "github.com/cli/cli/v2/pkg/cmd/attestation/api" - "github.com/cli/cli/v2/pkg/cmd/attestation/logger" + "github.com/cli/cli/v2/pkg/cmd/attestation/logging" ) // Options captures the options for the verify command @@ -28,7 +28,7 @@ type Options struct { SANRegex string Verbose bool APIClient api.Client - Logger *logger.Logger + Logger *logging.Logger Limit int OCIClient oci.Client } diff --git a/pkg/cmd/attestation/verify/verify.go b/pkg/cmd/attestation/verify/verify.go index ae414ee85..b0930a51d 100644 --- a/pkg/cmd/attestation/verify/verify.go +++ b/pkg/cmd/attestation/verify/verify.go @@ -9,7 +9,7 @@ import ( "github.com/cli/cli/v2/pkg/cmdutil" "github.com/cli/cli/v2/pkg/cmd/attestation/api" "github.com/cli/cli/v2/pkg/cmd/attestation/artifact" - "github.com/cli/cli/v2/pkg/cmd/attestation/logger" + "github.com/cli/cli/v2/pkg/cmd/attestation/logging" "github.com/cli/cli/v2/pkg/cmd/attestation/verification" "github.com/MakeNowJust/heredoc" @@ -71,7 +71,7 @@ func NewVerifyCmd(f *cmdutil.Factory) *cobra.Command { opts.APIClient = api.NewLiveClient() // Create a logger for use throughout the verify command - opts.Logger = logger.NewLogger(f.IOStreams, opts.Quiet, opts.Verbose) + opts.Logger = logging.NewLogger(f.IOStreams, opts.Quiet, opts.Verbose) // Configure the live OCI client opts.ConfigureOCIClient() @@ -208,7 +208,7 @@ func RunVerify(opts *Options) error { return nil } -func verifySLSAPredicateType(logger *logger.Logger, apr []*verification.AttestationProcessingResult) error { +func verifySLSAPredicateType(logger *logging.Logger, apr []*verification.AttestationProcessingResult) error { logger.VerbosePrintf("Evaluating attestations have valid SLSA predicate type...\n") for _, result := range apr { diff --git a/pkg/cmd/attestation/verify/verify_test.go b/pkg/cmd/attestation/verify/verify_test.go index 670d372cc..d1d852ee6 100644 --- a/pkg/cmd/attestation/verify/verify_test.go +++ b/pkg/cmd/attestation/verify/verify_test.go @@ -5,7 +5,7 @@ import ( "github.com/cli/cli/v2/pkg/cmd/attestation/api" "github.com/cli/cli/v2/pkg/cmd/attestation/artifact/oci" - "github.com/cli/cli/v2/pkg/cmd/attestation/logger" + "github.com/cli/cli/v2/pkg/cmd/attestation/logging" "github.com/cli/cli/v2/pkg/cmd/attestation/test" "github.com/cli/cli/v2/pkg/cmd/attestation/verification" @@ -24,7 +24,7 @@ func TestRunVerify(t *testing.T) { res := test.SuppressAndRestoreOutput() defer res() - logger := logger.NewSystemLogger() + logger := logging.NewSystemLogger() publicGoodOpts := Options{ ArtifactPath: test.NormalizeRelativePath("../test/data/sigstore-js-2.1.0.tgz"), @@ -176,7 +176,7 @@ func TestVerifySLSAPredicateType_InvalidPredicate(t *testing.T) { }, } - err := verifySLSAPredicateType(logger.NewSystemLogger(), apr) + err := verifySLSAPredicateType(logging.NewSystemLogger(), apr) assert.Error(t, err) assert.ErrorIs(t, err, ErrNoMatchingSLSAPredicate) } diff --git a/pkg/cmd/attestation/verifytufroot/verify-tuf-root.go b/pkg/cmd/attestation/verifytufroot/verify-tuf-root.go index 349e936cc..4704d35cb 100644 --- a/pkg/cmd/attestation/verifytufroot/verify-tuf-root.go +++ b/pkg/cmd/attestation/verifytufroot/verify-tuf-root.go @@ -5,7 +5,7 @@ import ( "os" "github.com/cli/cli/v2/pkg/cmdutil" - "github.com/cli/cli/v2/pkg/cmd/attestation/logger" + "github.com/cli/cli/v2/pkg/cmd/attestation/logging" "github.com/cli/cli/v2/pkg/cmd/attestation/verification" "github.com/MakeNowJust/heredoc" @@ -34,7 +34,7 @@ func NewVerifyTUFRootCmd(f *cmdutil.Factory) *cobra.Command { gh attestation tuf-root-verify --mirror https://tuf-repo.github.com --root /path/to/1.root.json `), Run: func(cmd *cobra.Command, args []string) { - logger := logger.NewDefaultLogger(f.IOStreams) + logger := logging.NewDefaultLogger(f.IOStreams) if err := verifyTUFRoot(mirror, root); err != nil { fmt.Sprintln(logger.IO.Out, logger.ColorScheme.Redf("Failed to verify the TUF repository: %s", err)) os.Exit(1)