From e35503048f1943dee7f4e91782524bbe0a22690e Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Thu, 23 Mar 2023 12:50:04 +0000 Subject: [PATCH] rename Signed-off-by: Billy Zha --- cmd/oras/internal/option/common.go | 4 ++-- cmd/oras/root/attach.go | 2 +- cmd/oras/root/blob/delete.go | 2 +- cmd/oras/root/blob/fetch.go | 2 +- cmd/oras/root/blob/push.go | 2 +- cmd/oras/root/cp.go | 2 +- cmd/oras/root/discover.go | 2 +- cmd/oras/root/login.go | 2 +- cmd/oras/root/manifest/delete.go | 2 +- cmd/oras/root/manifest/fetch.go | 2 +- cmd/oras/root/manifest/fetch_config.go | 2 +- cmd/oras/root/manifest/push.go | 2 +- cmd/oras/root/pull.go | 2 +- cmd/oras/root/push.go | 2 +- cmd/oras/root/repo/ls.go | 2 +- cmd/oras/root/repo/tags.go | 2 +- cmd/oras/root/tag.go | 2 +- 17 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cmd/oras/internal/option/common.go b/cmd/oras/internal/option/common.go index b04fccf34..6c5817967 100644 --- a/cmd/oras/internal/option/common.go +++ b/cmd/oras/internal/option/common.go @@ -35,7 +35,7 @@ func (opts *Common) ApplyFlags(fs *pflag.FlagSet) { fs.BoolVarP(&opts.Verbose, "verbose", "v", false, "verbose output") } -// WithLogger sets a logger to ctx with proper logging options tuned. -func (opts *Common) WithLogger(ctx context.Context) (context.Context, logrus.FieldLogger) { +// WithContext returns a new FieldLogger and an associated Context derived from ctx. +func (opts *Common) WithContext(ctx context.Context) (context.Context, logrus.FieldLogger) { return trace.NewLogger(ctx, opts.Debug, opts.Verbose) } diff --git a/cmd/oras/root/attach.go b/cmd/oras/root/attach.go index f7436727d..0e50b4498 100644 --- a/cmd/oras/root/attach.go +++ b/cmd/oras/root/attach.go @@ -98,7 +98,7 @@ Example - Attach file to the manifest tagged 'v1' in an OCI layout folder 'layou } func runAttach(opts attachOptions, cmd *cobra.Command) error { - ctx, _ := opts.WithLogger(cmd.Context()) + ctx, _ := opts.WithContext(cmd.Context()) annotations, err := opts.LoadManifestAnnotations() if err != nil { return err diff --git a/cmd/oras/root/blob/delete.go b/cmd/oras/root/blob/delete.go index 5a42c64b6..7254b95e1 100644 --- a/cmd/oras/root/blob/delete.go +++ b/cmd/oras/root/blob/delete.go @@ -70,7 +70,7 @@ Example - Delete a blob and print its descriptor: } func deleteBlob(opts deleteBlobOptions, cmd *cobra.Command) (err error) { - ctx, _ := opts.WithLogger(cmd.Context()) + ctx, _ := opts.WithContext(cmd.Context()) repo, err := opts.NewRepository(opts.targetRef, opts.Common) if err != nil { return err diff --git a/cmd/oras/root/blob/fetch.go b/cmd/oras/root/blob/fetch.go index d6b64a114..9d8822f99 100644 --- a/cmd/oras/root/blob/fetch.go +++ b/cmd/oras/root/blob/fetch.go @@ -89,7 +89,7 @@ Example - Fetch and print a blob from OCI image layout archive file 'layout.tar' } func fetchBlob(opts fetchBlobOptions, cmd *cobra.Command) (fetchErr error) { - ctx, _ := opts.WithLogger(cmd.Context()) + ctx, _ := opts.WithContext(cmd.Context()) var target oras.ReadOnlyTarget target, err := opts.NewReadonlyTarget(ctx, opts.Common) if err != nil { diff --git a/cmd/oras/root/blob/push.go b/cmd/oras/root/blob/push.go index 87f290c8a..eb8eb6818 100644 --- a/cmd/oras/root/blob/push.go +++ b/cmd/oras/root/blob/push.go @@ -95,7 +95,7 @@ Example - Push blob 'hi.txt' into an OCI layout folder 'layout-dir': } func pushBlob(opts pushBlobOptions, cmd *cobra.Command) (err error) { - ctx, _ := opts.WithLogger(cmd.Context()) + ctx, _ := opts.WithContext(cmd.Context()) repo, err := opts.NewTarget(opts.Common) if err != nil { diff --git a/cmd/oras/root/cp.go b/cmd/oras/root/cp.go index 56eb9b8bb..2b4681c44 100644 --- a/cmd/oras/root/cp.go +++ b/cmd/oras/root/cp.go @@ -96,7 +96,7 @@ Example - Copy an artifact with multiple tags with concurrency tuned: } func runCopy(opts copyOptions, cmd *cobra.Command) error { - ctx, _ := opts.WithLogger(cmd.Context()) + ctx, _ := opts.WithContext(cmd.Context()) // Prepare source src, err := opts.From.NewReadonlyTarget(ctx, opts.Common) diff --git a/cmd/oras/root/discover.go b/cmd/oras/root/discover.go index 2f5e3d1d9..aae60131c 100644 --- a/cmd/oras/root/discover.go +++ b/cmd/oras/root/discover.go @@ -91,7 +91,7 @@ Example - Discover referrers of the manifest tagged 'v1' in an OCI layout folder } func runDiscover(opts discoverOptions, cmd *cobra.Command) error { - ctx, _ := opts.WithLogger(cmd.Context()) + ctx, _ := opts.WithContext(cmd.Context()) repo, err := opts.NewReadonlyTarget(ctx, opts.Common) if err != nil { return err diff --git a/cmd/oras/root/login.go b/cmd/oras/root/login.go index a76652c07..826938ad7 100644 --- a/cmd/oras/root/login.go +++ b/cmd/oras/root/login.go @@ -73,7 +73,7 @@ Example - Log in with username and password in an interactive terminal and no TL } func runLogin(opts loginOptions, cmd *cobra.Command) (err error) { - ctx, _ := opts.WithLogger(cmd.Context()) + ctx, _ := opts.WithContext(cmd.Context()) // prompt for credential if opts.Password == "" { diff --git a/cmd/oras/root/manifest/delete.go b/cmd/oras/root/manifest/delete.go index 61acc7ee5..83533c9cc 100644 --- a/cmd/oras/root/manifest/delete.go +++ b/cmd/oras/root/manifest/delete.go @@ -75,7 +75,7 @@ Example - Delete a manifest by digest 'sha256:99e4703fbf30916f549cd6bfa9cdbab614 } func deleteManifest(opts deleteOptions, cmd *cobra.Command) error { - ctx, _ := opts.WithLogger(cmd.Context()) + ctx, _ := opts.WithContext(cmd.Context()) repo, err := opts.NewRepository(opts.targetRef, opts.Common) if err != nil { return err diff --git a/cmd/oras/root/manifest/fetch.go b/cmd/oras/root/manifest/fetch.go index 4a27ed028..ae74bc899 100644 --- a/cmd/oras/root/manifest/fetch.go +++ b/cmd/oras/root/manifest/fetch.go @@ -89,7 +89,7 @@ Example - Fetch raw manifest from an OCI layout archive file 'layout.tar': } func fetchManifest(opts fetchOptions, cmd *cobra.Command) (fetchErr error) { - ctx, _ := opts.WithLogger(cmd.Context()) + ctx, _ := opts.WithContext(cmd.Context()) target, err := opts.NewReadonlyTarget(ctx, opts.Common) if err != nil { diff --git a/cmd/oras/root/manifest/fetch_config.go b/cmd/oras/root/manifest/fetch_config.go index 74180149f..24168ed9a 100644 --- a/cmd/oras/root/manifest/fetch_config.go +++ b/cmd/oras/root/manifest/fetch_config.go @@ -86,7 +86,7 @@ Example - Fetch and print the prettified descriptor of the config: } func fetchConfig(opts fetchConfigOptions, cmd *cobra.Command) (fetchErr error) { - ctx, _ := opts.WithLogger(cmd.Context()) + ctx, _ := opts.WithContext(cmd.Context()) repo, err := opts.NewReadonlyTarget(ctx, opts.Common) if err != nil { diff --git a/cmd/oras/root/manifest/push.go b/cmd/oras/root/manifest/push.go index 59372f4bc..e42e3a5bb 100644 --- a/cmd/oras/root/manifest/push.go +++ b/cmd/oras/root/manifest/push.go @@ -104,7 +104,7 @@ Example - Push a manifest to an OCI layout folder 'layout-dir' and tag with 'v1' } func pushManifest(opts pushOptions, cmd *cobra.Command) error { - ctx, _ := opts.WithLogger(cmd.Context()) + ctx, _ := opts.WithContext(cmd.Context()) var target oras.Target var err error target, err = opts.NewTarget(opts.Common) diff --git a/cmd/oras/root/pull.go b/cmd/oras/root/pull.go index 64b1f3929..e9dd1a8e6 100644 --- a/cmd/oras/root/pull.go +++ b/cmd/oras/root/pull.go @@ -102,7 +102,7 @@ Example - Pull artifact files from an OCI layout archive 'layout.tar': } func runPull(opts pullOptions, cmd *cobra.Command) error { - ctx, _ := opts.WithLogger(cmd.Context()) + ctx, _ := opts.WithContext(cmd.Context()) // Copy Options var printed sync.Map copyOptions := oras.DefaultCopyOptions diff --git a/cmd/oras/root/push.go b/cmd/oras/root/push.go index 01f9c25cd..24563be7e 100644 --- a/cmd/oras/root/push.go +++ b/cmd/oras/root/push.go @@ -123,7 +123,7 @@ Example - Push file "hi.txt" into an OCI layout folder 'layout-dir' with tag 'te } func runPush(opts pushOptions, cmd *cobra.Command) error { - ctx, _ := opts.WithLogger(cmd.Context()) + ctx, _ := opts.WithContext(cmd.Context()) annotations, err := opts.LoadManifestAnnotations() if err != nil { return err diff --git a/cmd/oras/root/repo/ls.go b/cmd/oras/root/repo/ls.go index efd8f0554..82002ee93 100644 --- a/cmd/oras/root/repo/ls.go +++ b/cmd/oras/root/repo/ls.go @@ -68,7 +68,7 @@ Example - List the repositories under the registry that include values lexically } func listRepository(opts repositoryOptions, cmd *cobra.Command) error { - ctx, _ := opts.WithLogger(cmd.Context()) + ctx, _ := opts.WithContext(cmd.Context()) reg, err := opts.Remote.NewRegistry(opts.hostname, opts.Common) if err != nil { return err diff --git a/cmd/oras/root/repo/tags.go b/cmd/oras/root/repo/tags.go index 858aa4cc1..640ae6cc1 100644 --- a/cmd/oras/root/repo/tags.go +++ b/cmd/oras/root/repo/tags.go @@ -77,7 +77,7 @@ Example - Show tags associated with a digest: } func showTags(opts showTagsOptions, cmd *cobra.Command) error { - ctx, logger := opts.WithLogger(cmd.Context()) + ctx, logger := opts.WithContext(cmd.Context()) finder, err := opts.NewReadonlyTarget(ctx, opts.Common) if err != nil { return err diff --git a/cmd/oras/root/tag.go b/cmd/oras/root/tag.go index fa0004ef5..4057c40de 100644 --- a/cmd/oras/root/tag.go +++ b/cmd/oras/root/tag.go @@ -71,7 +71,7 @@ Example - Tag the manifest 'v1.0.1' to 'v1.0.2' in an OCI layout folder 'layout- } func tagManifest(opts tagOptions, cmd *cobra.Command) error { - ctx, _ := opts.WithLogger(cmd.Context()) + ctx, _ := opts.WithContext(cmd.Context()) target, err := opts.NewTarget(opts.Common) if err != nil { return err