Skip to content

Commit

Permalink
resolved comments
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoxuan Wang <xiaoxuanwang@microsoft.com>
  • Loading branch information
Xiaoxuan Wang committed Sep 4, 2024
1 parent 14ba46b commit 8c94001
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
6 changes: 3 additions & 3 deletions cmd/oras/internal/display/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ func NewManifestPushHandler(printer *output.Printer) metadata.ManifestPushHandle
return text.NewManifestPushHandler(printer)
}

// NewIndexCreateHandler returns an index create handler.
func NewIndexCreateHandler(printer *output.Printer) metadata.IndexCreateHandler {
return text.NewIndexCreateHandler(printer)
// NewManifestIndexCreateHandler returns an index create handler.
func NewManifestIndexCreateHandler(printer *output.Printer) metadata.ManifestIndexCreateHandler {
return text.NewManifestIndexCreateHandler(printer)
}

// NewCopyHandler returns copy handlers.
Expand Down
4 changes: 2 additions & 2 deletions cmd/oras/internal/display/metadata/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ type ManifestPushHandler interface {
TaggedHandler
}

// IndexCreateHandler handles metadata output for index create events.
type IndexCreateHandler interface {
// ManifestIndexCreateHandler handles metadata output for index create events.
type ManifestIndexCreateHandler interface {
TaggedHandler
}

Expand Down
12 changes: 6 additions & 6 deletions cmd/oras/internal/display/metadata/text/manifest_index_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ import (
"oras.land/oras/cmd/oras/internal/output"
)

// IndexCreateHandler handles text metadata output for index create events.
type IndexCreateHandler struct {
// ManifestIndexCreateHandler handles text metadata output for index create events.
type ManifestIndexCreateHandler struct {
printer *output.Printer
}

// NewIndexCreateHandler returns a new handler for index create events.
func NewIndexCreateHandler(printer *output.Printer) metadata.IndexCreateHandler {
return &IndexCreateHandler{
// NewManifestIndexCreateHandler returns a new handler for index create events.
func NewManifestIndexCreateHandler(printer *output.Printer) metadata.ManifestIndexCreateHandler {
return &ManifestIndexCreateHandler{
printer: printer,
}
}

// OnTagged implements metadata.TaggedHandler.
func (h *IndexCreateHandler) OnTagged(_ ocispec.Descriptor, tag string) error {
func (h *ManifestIndexCreateHandler) OnTagged(_ ocispec.Descriptor, tag string) error {
return h.printer.Println("Tagged", tag)
}
15 changes: 9 additions & 6 deletions cmd/oras/root/manifest/index/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,17 @@ func createCmd() *cobra.Command {
Example - create an index from source manifests tagged 'linux-amd64' and 'linux-arm64', and push without tagging:
oras manifest index create localhost:5000/hello linux-amd64 linux-arm64
Example - create an index from source manifests tagged 'linux-amd64' and 'linux-arm64', and push with the tag 'latest':
oras manifest index create localhost:5000/hello:latest linux-amd64 linux-arm64
Example - create an index from source manifests tagged 'linux-amd64' and 'linux-arm64', and push with the tag 'v1':
oras manifest index create localhost:5000/hello:v1 linux-amd64 linux-arm64
Example - create an index from source manifests using both tags and digests, and push with tag 'latest':
oras manifest index create localhost:5000/hello:latest linux-amd64 sha256:xxx
Example - create an index from source manifests using both tags and digests, and push with tag 'v1':
oras manifest index create localhost:5000/hello:v1 linux-amd64 sha256:99e4703fbf30916f549cd6bfa9cdbab614b5392fbe64fdee971359a77073cdf9
Example - create an index and push it with multiple tags:
oras manifest index create localhost:5000/hello:tag1,tag2,tag3 linux-amd64 linux-arm64 sha256:xxx
oras manifest index create localhost:5000/hello:tag1,tag2,tag3 linux-amd64 linux-arm64 sha256:99e4703fbf30916f549cd6bfa9cdbab614b5392fbe64fdee971359a77073cdf9
Example - create an index and push to an OCI image layout folder 'layout-dir' and tag with 'v1':
oras manifest index create layout-dir:v1 linux-amd64 sha256:99e4703fbf30916f549cd6bfa9cdbab614b5392fbe64fdee971359a77073cdf9
`,
Args: oerrors.CheckArgs(argument.AtLeast(1), "the destination index to create."),
PreRunE: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -175,7 +178,7 @@ func pushIndex(ctx context.Context, target oras.Target, desc ocispec.Descriptor,
}
printer.Println(status.IndexPromptPushed, path)
if len(extraRefs) != 0 {
handler := display.NewIndexCreateHandler(printer)
handler := display.NewManifestIndexCreateHandler(printer)
tagListener := listener.NewTaggedListener(target, handler.OnTagged)
if _, err = oras.TagBytesN(ctx, tagListener, desc.MediaType, content, extraRefs, oras.DefaultTagBytesNOptions); err != nil {
return err

Check warning on line 184 in cmd/oras/root/manifest/index/create.go

View check run for this annotation

Codecov / codecov/patch

cmd/oras/root/manifest/index/create.go#L184

Added line #L184 was not covered by tests
Expand Down
5 changes: 3 additions & 2 deletions internal/descriptor/descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (
"oras.land/oras/internal/docker"
)

// IsManifest checks if a descriptor describes a manifest.
// IsManifest checks if a descriptor describes a manifest. Copied from oras-go with
// slight modification.
func IsManifest(desc ocispec.Descriptor) bool {
switch desc.MediaType {
case docker.MediaTypeManifest,
Expand Down Expand Up @@ -51,7 +52,7 @@ func ShortDigest(desc ocispec.Descriptor) (digestString string) {
}

// Plain returns a plain descriptor that contains only MediaType, Digest and
// Size.
// Size. Copied from oras-go.
func Plain(desc ocispec.Descriptor) ocispec.Descriptor {
return ocispec.Descriptor{
MediaType: desc.MediaType,
Expand Down

0 comments on commit 8c94001

Please sign in to comment.