Skip to content

Commit

Permalink
rebased
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxuan Wang <[email protected]>
  • Loading branch information
Xiaoxuan Wang committed Aug 20, 2024
1 parent ef5dacd commit c2ecf10
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions cmd/oras/root/manifest/index/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit c2ecf10

Please sign in to comment.