From 49f58abd35c2c45aee4e8449cd8ed551ded77bde Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Thu, 24 Aug 2023 09:26:03 +0800 Subject: [PATCH] chore: align naming of pack option to oras-go (#1073) Signed-off-by: Billy Zha --- cmd/oras/internal/option/spec.go | 8 ++++---- cmd/oras/root/push.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/oras/internal/option/spec.go b/cmd/oras/internal/option/spec.go index 3b9e833b1..837959761 100644 --- a/cmd/oras/internal/option/spec.go +++ b/cmd/oras/internal/option/spec.go @@ -29,17 +29,17 @@ const ( // ImageSpec option struct. type ImageSpec struct { - flag string - PackType oras.PackManifestVersion + flag string + PackVersion oras.PackManifestVersion } // Parse parses flags into the option. func (opts *ImageSpec) Parse() error { switch opts.flag { case ImageSpecV1_1: - opts.PackType = oras.PackManifestVersion1_1_RC4 + opts.PackVersion = oras.PackManifestVersion1_1_RC4 case ImageSpecV1_0: - opts.PackType = oras.PackManifestVersion1_0 + opts.PackVersion = oras.PackManifestVersion1_0 default: return fmt.Errorf("unknown image specification flag: %q", opts.flag) } diff --git a/cmd/oras/root/push.go b/cmd/oras/root/push.go index 5bad2955e..c8e10a86c 100644 --- a/cmd/oras/root/push.go +++ b/cmd/oras/root/push.go @@ -101,7 +101,7 @@ Example - Push file "hi.txt" into an OCI image layout folder 'layout-dir' with t if err := option.Parse(&opts); err != nil { return err } - switch opts.PackType { + switch opts.PackVersion { case oras.PackManifestVersion1_0: if opts.manifestConfigRef != "" && opts.artifactType != "" { return errors.New("--artifact-type and --config cannot both be provided for 1.0 OCI image") @@ -161,7 +161,7 @@ func runPush(ctx context.Context, opts pushOptions) error { packOpts.Layers = descs memoryStore := memory.New() pack := func() (ocispec.Descriptor, error) { - root, err := oras.PackManifest(ctx, memoryStore, opts.PackType, opts.artifactType, packOpts) + root, err := oras.PackManifest(ctx, memoryStore, opts.PackVersion, opts.artifactType, packOpts) if err != nil { return ocispec.Descriptor{}, err }