Skip to content

Commit

Permalink
fix: disable oras tag fallback to tag schema when tagging a referrer
Browse files Browse the repository at this point in the history
Signed-off-by: njucjc <njucjc@gmail.com>
  • Loading branch information
njucjc committed Jul 1, 2024
1 parent 1cd85fe commit e19fdea
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cmd/oras/root/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/spf13/cobra"
"oras.land/oras-go/v2"
"oras.land/oras-go/v2/errdef"
"oras.land/oras-go/v2/registry/remote"
"oras.land/oras/cmd/oras/internal/argument"
"oras.land/oras/cmd/oras/internal/command"
"oras.land/oras/cmd/oras/internal/display/status"
Expand Down Expand Up @@ -58,10 +59,6 @@ Example - Tag the manifest 'v1.0.1' in 'localhost:5000/hello' to 'v1.0.1', 'v1.0
Example - Tag the manifest 'v1.0.1' to 'v1.0.2' in an OCI image layout folder 'layout-dir':
oras tag --oci-layout layout-dir:v1.0.1 v1.0.2
Example - Tag the referrers with digest sha256:9463e0d192846bc994279417b50114606712d516aab45f4d8b31cbc6e46aad71 to 'v1.0.2' using specific methods for the Referrers API:
oras tag --distribution-spec v1.1-referrers-api localhost:5000/hello@sha256:9463e0d192846bc994279417b50114606712d516aab45f4d8b31cbc6e46aad71 v1.0.2
oras tag --distribution-spec v1.1-referrers-tag localhost:5000/hello@sha256:9463e0d192846bc994279417b50114606712d516aab45f4d8b31cbc6e46aad71 v1.0.2
`,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) > 0 && (args[0] == "list" || args[0] == "ls") {
Expand Down Expand Up @@ -95,7 +92,6 @@ Example - Tag the referrers with digest sha256:9463e0d192846bc994279417b50114606
},
}

opts.EnableDistributionSpecFlag()
option.ApplyFlags(&opts, cmd.Flags())
cmd.Flags().IntVarP(&opts.concurrency, "concurrency", "", 5, "concurrency level")
return oerrors.Command(cmd, &opts.Target)
Expand All @@ -104,6 +100,12 @@ Example - Tag the referrers with digest sha256:9463e0d192846bc994279417b50114606
func tagManifest(cmd *cobra.Command, opts *tagOptions) error {
ctx, logger := command.GetLogger(cmd, &opts.Common)
target, err := opts.NewTarget(opts.Common, logger)
if targetRepo, ok := target.(*remote.Repository); ok {
err := targetRepo.SetReferrersCapability(true)
if err != nil {
return err
}
}
if err != nil {
return err
}
Expand Down

0 comments on commit e19fdea

Please sign in to comment.