Skip to content

Commit

Permalink
udpate options to avoid copylocks error
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Aug 18, 2023
1 parent d11b379 commit 87de8df
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions cmd/oras/root/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Example - Attach file to the manifest tagged 'v1' in an OCI image layout folder
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
return runAttach(cmd.Context(), opts)
return runAttach(cmd.Context(), &opts)
},
}

Expand All @@ -92,7 +92,7 @@ Example - Attach file to the manifest tagged 'v1' in an OCI image layout folder
return cmd
}

func runAttach(ctx context.Context, opts attachOptions) error {
func runAttach(ctx context.Context, opts *attachOptions) error {
ctx, logger := opts.WithContext(ctx)
annotations, err := opts.LoadManifestAnnotations()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/oras/root/blob/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ Example - Delete a blob and print its descriptor:
},
RunE: func(cmd *cobra.Command, args []string) error {
opts.targetRef = args[0]
return deleteBlob(cmd.Context(), opts)
return deleteBlob(cmd.Context(), &opts)
},
}

option.ApplyFlags(&opts, cmd.Flags())
return cmd
}

func deleteBlob(ctx context.Context, opts deleteBlobOptions) (err error) {
func deleteBlob(ctx context.Context, opts *deleteBlobOptions) (err error) {
ctx, logger := opts.WithContext(ctx)
repo, err := opts.NewRepository(opts.targetRef, logger.Warn, opts.Common)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/oras/root/blob/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Example - Fetch and print a blob from OCI image layout archive file 'layout.tar'
},
Aliases: []string{"get"},
RunE: func(cmd *cobra.Command, args []string) error {
return fetchBlob(cmd.Context(), opts)
return fetchBlob(cmd.Context(), &opts)
},
}

Expand All @@ -89,7 +89,7 @@ Example - Fetch and print a blob from OCI image layout archive file 'layout.tar'
return cmd
}

func fetchBlob(ctx context.Context, opts fetchBlobOptions) (fetchErr error) {
func fetchBlob(ctx context.Context, opts *fetchBlobOptions) (fetchErr error) {
ctx, logger := opts.WithContext(ctx)
var target oras.ReadOnlyTarget
target, err := opts.NewReadonlyTarget(ctx, logger.Warn, opts.Common)
Expand Down
4 changes: 2 additions & 2 deletions cmd/oras/root/blob/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Example - Push blob 'hi.txt' into an OCI image layout folder 'layout-dir':
return option.Parse(&opts)
},
RunE: func(cmd *cobra.Command, args []string) error {
return pushBlob(cmd.Context(), opts)
return pushBlob(cmd.Context(), &opts)
},
}

Expand All @@ -95,7 +95,7 @@ Example - Push blob 'hi.txt' into an OCI image layout folder 'layout-dir':
return cmd
}

func pushBlob(ctx context.Context, opts pushBlobOptions) (err error) {
func pushBlob(ctx context.Context, opts *pushBlobOptions) (err error) {
ctx, logger := opts.WithContext(ctx)

repo, err := opts.NewTarget(opts.Common, logger.Warn)
Expand Down
4 changes: 2 additions & 2 deletions cmd/oras/root/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Example - Copy an artifact with multiple tags with concurrency tuned:
return option.Parse(&opts)
},
RunE: func(cmd *cobra.Command, args []string) error {
return runCopy(cmd.Context(), opts)
return runCopy(cmd.Context(), &opts)
},
}
cmd.Flags().BoolVarP(&opts.recursive, "recursive", "r", false, "[Preview] recursively copy the artifact and its referrer artifacts")
Expand All @@ -96,7 +96,7 @@ Example - Copy an artifact with multiple tags with concurrency tuned:
return cmd
}

func runCopy(ctx context.Context, opts copyOptions) error {
func runCopy(ctx context.Context, opts *copyOptions) error {
ctx, logger := opts.WithContext(ctx)

// Prepare source
Expand Down
8 changes: 4 additions & 4 deletions cmd/oras/root/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Example - Discover referrers of the manifest tagged 'v1' in an OCI image layout
return option.Parse(&opts)
},
RunE: func(cmd *cobra.Command, args []string) error {
return runDiscover(cmd.Context(), opts)
return runDiscover(cmd.Context(), &opts)
},
}

Expand All @@ -90,7 +90,7 @@ Example - Discover referrers of the manifest tagged 'v1' in an OCI image layout
return cmd
}

func runDiscover(ctx context.Context, opts discoverOptions) error {
func runDiscover(ctx context.Context, opts *discoverOptions) error {
ctx, logger := opts.WithContext(ctx)
repo, err := opts.NewReadonlyTarget(ctx, logger.Warn, opts.Common)
if err != nil {
Expand All @@ -110,7 +110,7 @@ func runDiscover(ctx context.Context, opts discoverOptions) error {

if opts.outputType == "tree" {
root := tree.New(fmt.Sprintf("%s@%s", opts.Path, desc.Digest))
err = fetchAllReferrers(ctx, repo, desc, opts.artifactType, root, &opts)
err = fetchAllReferrers(ctx, repo, desc, opts.artifactType, root, opts)
if err != nil {
return err
}
Expand Down Expand Up @@ -189,7 +189,7 @@ func printDiscoveredReferrersTable(refs []ocispec.Descriptor, verbose bool) erro
print(ref.ArtifactType, ref.Digest)
if verbose {
if err := printJSON(ref); err != nil {
return fmt.Errorf("Error printing JSON: %w", err)
return fmt.Errorf("Eirror printing JSON: %w", err)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/oras/root/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ Example - Log in with username and password in an interactive terminal and no TL
},
RunE: func(cmd *cobra.Command, args []string) error {
opts.Hostname = args[0]
return runLogin(cmd.Context(), opts)
return runLogin(cmd.Context(), &opts)
},
}
option.ApplyFlags(&opts, cmd.Flags())
return cmd
}

func runLogin(ctx context.Context, opts loginOptions) (err error) {
func runLogin(ctx context.Context, opts *loginOptions) (err error) {
ctx, logger := opts.WithContext(ctx)

// prompt for credential
Expand Down
4 changes: 2 additions & 2 deletions cmd/oras/root/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Example - Logout:
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
opts.hostname = args[0]
return runLogout(cmd.Context(), opts)
return runLogout(cmd.Context(), &opts)
},
}

Expand All @@ -53,7 +53,7 @@ Example - Logout:
return cmd
}

func runLogout(ctx context.Context, opts logoutOptions) error {
func runLogout(ctx context.Context, opts *logoutOptions) error {
if opts.debug {
logrus.SetLevel(logrus.DebugLevel)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/oras/root/manifest/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Example - Delete a manifest by digest 'sha256:99e4703fbf30916f549cd6bfa9cdbab614
},
RunE: func(cmd *cobra.Command, args []string) error {
opts.targetRef = args[0]
return deleteManifest(cmd.Context(), opts)
return deleteManifest(cmd.Context(), &opts)
},
}

Expand All @@ -75,7 +75,7 @@ Example - Delete a manifest by digest 'sha256:99e4703fbf30916f549cd6bfa9cdbab614
return cmd
}

func deleteManifest(ctx context.Context, opts deleteOptions) error {
func deleteManifest(ctx context.Context, opts *deleteOptions) error {
ctx, logger := opts.WithContext(ctx)
repo, err := opts.NewRepository(opts.targetRef, logger.Warn, opts.Common)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/oras/root/manifest/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Example - Fetch raw manifest from an OCI layout archive file 'layout.tar':
},
Aliases: []string{"get"},
RunE: func(cmd *cobra.Command, args []string) error {
return fetchManifest(cmd.Context(), opts)
return fetchManifest(cmd.Context(), &opts)
},
}

Expand All @@ -89,7 +89,7 @@ Example - Fetch raw manifest from an OCI layout archive file 'layout.tar':
return cmd
}

func fetchManifest(ctx context.Context, opts fetchOptions) (fetchErr error) {
func fetchManifest(ctx context.Context, opts *fetchOptions) (fetchErr error) {
ctx, logger := opts.WithContext(ctx)

target, err := opts.NewReadonlyTarget(ctx, logger.Warn, opts.Common)
Expand Down
4 changes: 2 additions & 2 deletions cmd/oras/root/manifest/fetch_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Example - Fetch and print the prettified descriptor of the config:
return option.Parse(&opts)
},
RunE: func(cmd *cobra.Command, args []string) error {
return fetchConfig(cmd.Context(), opts)
return fetchConfig(cmd.Context(), &opts)
},
}

Expand All @@ -85,7 +85,7 @@ Example - Fetch and print the prettified descriptor of the config:
return cmd
}

func fetchConfig(ctx context.Context, opts fetchConfigOptions) (fetchErr error) {
func fetchConfig(ctx context.Context, opts *fetchConfigOptions) (fetchErr error) {
ctx, logger := opts.WithContext(ctx)

repo, err := opts.NewReadonlyTarget(ctx, logger.Warn, opts.Common)
Expand Down
4 changes: 2 additions & 2 deletions cmd/oras/root/manifest/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Example - Push a manifest to an OCI image layout folder 'layout-dir' and tag wit
return option.Parse(&opts)
},
RunE: func(cmd *cobra.Command, args []string) error {
return pushManifest(cmd.Context(), opts)
return pushManifest(cmd.Context(), &opts)
},
}

Expand All @@ -103,7 +103,7 @@ Example - Push a manifest to an OCI image layout folder 'layout-dir' and tag wit
return cmd
}

func pushManifest(ctx context.Context, opts pushOptions) error {
func pushManifest(ctx context.Context, opts *pushOptions) error {
ctx, logger := opts.WithContext(ctx)
var target oras.Target
var err error
Expand Down
4 changes: 2 additions & 2 deletions cmd/oras/root/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Example - Pull artifact files from an OCI layout archive 'layout.tar':
return option.Parse(&opts)
},
RunE: func(cmd *cobra.Command, args []string) error {
return runPull(cmd.Context(), opts)
return runPull(cmd.Context(), &opts)
},
}

Expand All @@ -102,7 +102,7 @@ Example - Pull artifact files from an OCI layout archive 'layout.tar':
return cmd
}

func runPull(ctx context.Context, opts pullOptions) error {
func runPull(ctx context.Context, opts *pullOptions) error {
ctx, logger := opts.WithContext(ctx)
// Copy Options
var printed sync.Map
Expand Down
4 changes: 2 additions & 2 deletions cmd/oras/root/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Example - Push file "hi.txt" into an OCI image layout folder 'layout-dir' with t
return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
return runPush(cmd.Context(), opts)
return runPush(cmd.Context(), &opts)
},
}
cmd.Flags().StringVarP(&opts.manifestConfigRef, "config", "", "", "`path` of image config file")
Expand All @@ -125,7 +125,7 @@ Example - Push file "hi.txt" into an OCI image layout folder 'layout-dir' with t
return cmd
}

func runPush(ctx context.Context, opts pushOptions) error {
func runPush(ctx context.Context, opts *pushOptions) error {
ctx, logger := opts.WithContext(ctx)
annotations, err := opts.LoadManifestAnnotations()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/oras/root/repo/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Example - List the repositories under the registry that include values lexically
if opts.hostname, opts.namespace, err = repository.ParseRepoPath(args[0]); err != nil {
return fmt.Errorf("could not parse repository path: %w", err)
}
return listRepository(cmd.Context(), opts)
return listRepository(cmd.Context(), &opts)
},
}

Expand All @@ -68,7 +68,7 @@ Example - List the repositories under the registry that include values lexically
return cmd
}

func listRepository(ctx context.Context, opts repositoryOptions) error {
func listRepository(ctx context.Context, opts *repositoryOptions) error {
ctx, logger := opts.WithContext(ctx)
reg, err := opts.Remote.NewRegistry(opts.hostname, logger.Warn, opts.Common)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/oras/root/repo/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Example - [Experimental] Show tags associated with a digest:
return option.Parse(&opts)
},
RunE: func(cmd *cobra.Command, args []string) error {
return showTags(cmd.Context(), opts)
return showTags(cmd.Context(), &opts)
},
}
cmd.Flags().StringVar(&opts.last, "last", "", "start after the tag specified by `last`")
Expand All @@ -77,7 +77,7 @@ Example - [Experimental] Show tags associated with a digest:
return cmd
}

func showTags(ctx context.Context, opts showTagsOptions) error {
func showTags(ctx context.Context, opts *showTagsOptions) error {
ctx, logger := opts.WithContext(ctx)
finder, err := opts.NewReadonlyTarget(ctx, logger.Warn, opts.Common)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/oras/root/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Example - Tag the manifest 'v1.0.1' to 'v1.0.2' in an OCI image layout folder 'l
return option.Parse(&opts)
},
RunE: func(cmd *cobra.Command, args []string) error {
return tagManifest(cmd.Context(), opts)
return tagManifest(cmd.Context(), &opts)
},
}

Expand All @@ -75,7 +75,7 @@ Example - Tag the manifest 'v1.0.1' to 'v1.0.2' in an OCI image layout folder 'l
return cmd
}

func tagManifest(ctx context.Context, opts tagOptions) error {
func tagManifest(ctx context.Context, opts *tagOptions) error {
ctx, logger := opts.WithContext(ctx)
target, err := opts.NewTarget(opts.Common, logger.Warn)
if err != nil {
Expand Down

0 comments on commit 87de8df

Please sign in to comment.