diff --git a/cmd/oras/root/manifest/index/update.go b/cmd/oras/root/manifest/index/update.go index 64bdf0978..b48deb0ff 100644 --- a/cmd/oras/root/manifest/index/update.go +++ b/cmd/oras/root/manifest/index/update.go @@ -22,9 +22,11 @@ import ( "strings" "github.com/opencontainers/go-digest" + "github.com/opencontainers/image-spec/specs-go" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/spf13/cobra" "oras.land/oras-go/v2" + "oras.land/oras-go/v2/content" "oras.land/oras/cmd/oras/internal/argument" "oras.land/oras/cmd/oras/internal/command" oerrors "oras.land/oras/cmd/oras/internal/errors" @@ -108,12 +110,26 @@ func updateIndex(cmd *cobra.Command, opts updateOptions) error { if err != nil { return err } - desc, content, err := packIndex(&index, manifests) - if err != nil { - return err + // desc, content, err := packIndex(&index, manifests) + // if err != nil { + // return err + // } + + updatedIndex := ocispec.Index{ + Versioned: specs.Versioned{ + SchemaVersion: 2, + }, + MediaType: index.MediaType, + ArtifactType: index.ArtifactType, + Manifests: manifests, + Subject: index.Subject, + Annotations: index.Annotations, } + indexBytes, _ := json.Marshal(updatedIndex) + desc := content.NewDescriptorFromBytes(updatedIndex.MediaType, indexBytes) + opts.Println("Updated the index") - return pushIndex(ctx, target, desc, content, opts.Reference, opts.extraRefs, opts.AnnotatedReference(), opts.Printer) + return pushIndex(ctx, target, desc, indexBytes, opts.Reference, opts.extraRefs, opts.AnnotatedReference(), opts.Printer) } func fetchIndex(ctx context.Context, target oras.ReadOnlyTarget, opts updateOptions) (ocispec.Index, error) {