diff --git a/internal/commands/manifest_add.go b/internal/commands/manifest_add.go new file mode 100644 index 0000000000..44f7e809cb --- /dev/null +++ b/internal/commands/manifest_add.go @@ -0,0 +1,39 @@ +package commands + +import ( + "github.com/buildpacks/pack/pkg/logging" + "github.com/spf13/cobra" +) + +// ManifestAddFlags define flags provided to the ManifestAdd +type ManifestAddFlags struct { + ManifestAnnotateFlags + all bool +} + +// ManifestAdd modifies a manifest list (Image index) and add a new image to the list of manifests. +func ManifestAdd(logger logging.Logger, pack PackClient) *cobra.Command { + var flags ManifestAddFlags + + cmd := &cobra.Command{ + Use: "pack manifest add [OPTIONS] [flags]", + Args: cobra.MatchAll(cobra.ExactArgs(2), cobra.OnlyValidArgs), + Short: "manifest add modifies a manifest list (Image index) and add a new image to the list of manifests.", + Example: `pack manifest add cnbs/sample-package:hello-multiarch-universe \ + cnbs/sample-package:hello-universe-riscv-linux`, + Long: `manifest add modifies a manifest list (Image index) and add a new image to the list of manifests. + + When a manifest list exits locally, user can add a new image to the manifest list using this command`, + RunE: logError(logger, func(cmd *cobra.Command, args []string) error { + return nil + }), + } + + cmd.Flags().BoolVar(&flags.all, "all", false, "add all of the contents to the local list (applies only if is an index)") + cmd.Flags().StringVar(&flags.os, "os", "", "Set the operating system") + cmd.Flags().StringVar(&flags.arch, "arch", "", "Set the architecture") + cmd.Flags().StringVar(&flags.variant, "variant", "", "Set the architecture variant") + + AddHelpFlag(cmd, "add") + return cmd +} \ No newline at end of file diff --git a/internal/commands/manifest_add_test.go b/internal/commands/manifest_add_test.go new file mode 100644 index 0000000000..fe7b8c53f5 --- /dev/null +++ b/internal/commands/manifest_add_test.go @@ -0,0 +1 @@ +package commands_test \ No newline at end of file diff --git a/internal/commands/manifest_annotate.go b/internal/commands/manifest_annotate.go new file mode 100644 index 0000000000..f975ec97b8 --- /dev/null +++ b/internal/commands/manifest_annotate.go @@ -0,0 +1,37 @@ +package commands + +import ( + "github.com/buildpacks/pack/pkg/logging" + "github.com/spf13/cobra" +) + +// ManifestAnnotateFlags define flags provided to the ManifestAnnotate +type ManifestAnnotateFlags struct { + os, arch, variant string +} + +// ManifestAnnotate modifies a manifest list (Image index) and update the platform information for an image included in the manifest list. +func ManifestAnnotate(logger logging.Logger, pack PackClient) *cobra.Command { + var flags ManifestAnnotateFlags + + cmd := &cobra.Command{ + Use: "pack manifest annotate [OPTIONS] [flags]", + Args: cobra.MatchAll(cobra.ExactArgs(2), cobra.OnlyValidArgs), + Short: "manifest annotate modifies a manifest list (Image index) and update the platform information for an image included in the manifest list.", + Example: `pack manifest annotate cnbs/sample-package:hello-universe-multiarch \ + cnbs/sample-package:hello-universe --arch amd64`, + Long: `manifest annotate modifies a manifest list (Image index) and update the platform information for an image included in the manifest list. + + Sometimes a manifest list could reference an image that doesn't specify the architecture, The "annotate" command allows users to update those values before pushing the manifest list a registry`, + RunE: logError(logger, func(cmd *cobra.Command, args []string) error { + return nil + }), + } + + cmd.Flags().StringVar(&flags.os, "os", "", "Set the architecture") + cmd.Flags().StringVar(&flags.arch, "arch", "", "Set the architecture") + cmd.Flags().StringVar(&flags.variant, "variant", "", "Set the architecture") + + AddHelpFlag(cmd, "annotate") + return cmd +} \ No newline at end of file diff --git a/internal/commands/manifest_annotate_test.go b/internal/commands/manifest_annotate_test.go new file mode 100644 index 0000000000..fe7b8c53f5 --- /dev/null +++ b/internal/commands/manifest_annotate_test.go @@ -0,0 +1 @@ +package commands_test \ No newline at end of file diff --git a/internal/commands/manifest_create.go b/internal/commands/manifest_create.go new file mode 100644 index 0000000000..1a9d8a3972 --- /dev/null +++ b/internal/commands/manifest_create.go @@ -0,0 +1,41 @@ +package commands + +import ( + "github.com/buildpacks/pack/pkg/logging" + "github.com/spf13/cobra" +) + +// ManifestCreateFlags define flags provided to the ManifestCreate +type ManifestCreateFlags struct { + format, registry string + insecure, publish bool +} + +// ManifestCreate creates an image-index/image-list for a multi-arch image +func ManifestCreate(logger logging.Logger, pack PackClient) *cobra.Command { + var flags ManifestCreateFlags + + cmd := &cobra.Command{ + Use: "pack manifest create [ ... ] [flags]", + Args: cobra.MatchAll(cobra.MinimumNArgs(2), cobra.OnlyValidArgs), + Short: "manifest create generates a manifest list for a multi-arch image", + Example: `pack manifest create cnbs/sample-package:hello-multiarch-universe \ + cnbs/sample-package:hello-universe \ + cnbs/sample-package:hello-universe-windows`, + Long: `Create a manifest list or manifest index for the image to support muti architecture for the image, it create a new ManifestList or ManifestIndex with the given name/repoName and adds the list of Manifests to the newly created ManifestIndex or ManifestList + + If the already exists in the registry: pack will save a local copy of the remote manifest list, + If the doestn't exist in a registry: pack will create a local representation of the manifest list that will only save on the remote registry if the user publish it`, + RunE: logError(logger, func(cmd *cobra.Command, args []string) error { + return nil + }), + } + + cmd.Flags().StringVarP(&flags.format, "format", "f", "", "Format to save image index as ('OCI' or 'V2S2') (default 'v2s2')") + cmd.Flags().BoolVar(&flags.insecure, "insecure", false, "Allow publishing to insecure registry") + cmd.Flags().BoolVar(&flags.publish, "publish", false, "Publish to registry") + cmd.Flags().StringVarP(&flags.registry, "registry", "r", "", "Publish to registry") + + AddHelpFlag(cmd, "create") + return cmd +} \ No newline at end of file diff --git a/internal/commands/manifest_create_test.go b/internal/commands/manifest_create_test.go new file mode 100644 index 0000000000..fe7b8c53f5 --- /dev/null +++ b/internal/commands/manifest_create_test.go @@ -0,0 +1 @@ +package commands_test \ No newline at end of file diff --git a/internal/commands/manifest_inspect.go b/internal/commands/manifest_inspect.go new file mode 100644 index 0000000000..f9769826b4 --- /dev/null +++ b/internal/commands/manifest_inspect.go @@ -0,0 +1,31 @@ +package commands + +import ( + "github.com/buildpacks/pack/pkg/logging" + "github.com/spf13/cobra" +) + +// ManifestInspectFlags define flags provided to the ManifestInspect +// type ManifestInspectFlags struct { +// } + +// ManifestInspect shows the manifest information stored in local storage +func ManifestInspect(logger logging.Logger, pack PackClient) *cobra.Command { + // var flags ManifestInspectFlags + + cmd := &cobra.Command{ + Use: "pack manifest inspect [flags]", + Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), + Short: "manifest inspect shows the manifest information stored in local storage", + Example: `pack manifest inspect cnbs/sample-builder:multiarch`, + Long: `manifest inspect shows the manifest information stored in local storage. + + The inspect command will help users to view how their local manifest list looks like`, + RunE: logError(logger, func(cmd *cobra.Command, args []string) error { + return nil + }), + } + + AddHelpFlag(cmd, "inspect") + return cmd +} \ No newline at end of file diff --git a/internal/commands/manifest_inspect_test.go b/internal/commands/manifest_inspect_test.go new file mode 100644 index 0000000000..fe7b8c53f5 --- /dev/null +++ b/internal/commands/manifest_inspect_test.go @@ -0,0 +1 @@ +package commands_test \ No newline at end of file diff --git a/internal/commands/manifest_push.go b/internal/commands/manifest_push.go new file mode 100644 index 0000000000..fd0e200436 --- /dev/null +++ b/internal/commands/manifest_push.go @@ -0,0 +1,37 @@ +package commands + +import ( + "github.com/buildpacks/pack/pkg/logging" + "github.com/spf13/cobra" +) + +// ManifestPushFlags define flags provided to the ManifestPush +type ManifestPushFlags struct { + format string + insecure, purge bool +} + +// ManifestPush pushes a manifest list (Image index) to a registry. +func ManifestPush(logger logging.Logger, pack PackClient) *cobra.Command { + var flags ManifestPushFlags + + cmd := &cobra.Command{ + Use: "pack manifest push [OPTIONS] [flags]", + Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), + Short: "manifest push pushes a manifest list (Image index) to a registry.", + Example: `pack manifest push cnbs/sample-package:hello-multiarch-universe`, + Long: `manifest push pushes a manifest list (Image index) to a registry. + + Once a manifest list is ready to be published into the registry, the push command can be used`, + RunE: logError(logger, func(cmd *cobra.Command, args []string) error { + return nil + }), + } + + cmd.Flags().StringVarP(&flags.format, "format", "f", "", "Format to save image index as ('OCI' or 'V2S2') (default 'v2s2')") + cmd.Flags().BoolVar(&flags.insecure, "insecure", false, "Allow publishing to insecure registry") + cmd.Flags().BoolVar(&flags.purge, "purge", false, "Delete the manifest list or image index from local storage if pushing succeeds") + + AddHelpFlag(cmd, "push") + return cmd +} \ No newline at end of file diff --git a/internal/commands/manifest_push_test.go b/internal/commands/manifest_push_test.go new file mode 100644 index 0000000000..fe7b8c53f5 --- /dev/null +++ b/internal/commands/manifest_push_test.go @@ -0,0 +1 @@ +package commands_test \ No newline at end of file diff --git a/internal/commands/manifest_remove.go b/internal/commands/manifest_remove.go new file mode 100644 index 0000000000..d00681127b --- /dev/null +++ b/internal/commands/manifest_remove.go @@ -0,0 +1,31 @@ +package commands + +import ( + "github.com/buildpacks/pack/pkg/logging" + "github.com/spf13/cobra" +) + +// ManifestDeleteFlags define flags provided to the ManifestDelete +// type ManifestDeleteFlags struct { +// } + +// ManifestDelete deletes one or more manifest lists from local storage +func ManifestDelete(logger logging.Logger, pack PackClient) *cobra.Command { + // var flags ManifestDeleteFlags + + cmd := &cobra.Command{ + Use: "pack manifest remove [manifest-list] [manifest-list...] [flags]", + Args: cobra.MatchAll(cobra.MinimumNArgs(1), cobra.OnlyValidArgs), + Short: "Delete one or more manifest lists from local storage", + Example: `pack manifest remove cnbs/sample-package:hello-multiarch-universe`, + Long: `Delete one or more manifest lists from local storage. + + When a manifest list exits locally, users can remove existing images from a manifest list`, + RunE: logError(logger, func(cmd *cobra.Command, args []string) error { + return nil + }), + } + + AddHelpFlag(cmd, "remove") + return cmd +} \ No newline at end of file diff --git a/internal/commands/manifest_remove_test.go b/internal/commands/manifest_remove_test.go new file mode 100644 index 0000000000..fe7b8c53f5 --- /dev/null +++ b/internal/commands/manifest_remove_test.go @@ -0,0 +1 @@ +package commands_test \ No newline at end of file diff --git a/internal/commands/manifest_rm.go b/internal/commands/manifest_rm.go new file mode 100644 index 0000000000..233f42185c --- /dev/null +++ b/internal/commands/manifest_rm.go @@ -0,0 +1,32 @@ +package commands + +import ( + "github.com/buildpacks/pack/pkg/logging" + "github.com/spf13/cobra" +) + +// ManifestRemoveFlags define flags provided to the ManifestRemove +// type ManifestRemoveFlags struct { +// } + +// ManifestRemove will remove the specified image manifest if it is already referenced in the index +func ManifestRemove(logger logging.Logger, pack PackClient) *cobra.Command { + // var flags ManifestRemoveFlags + + cmd := &cobra.Command{ + Use: "pack manifest rm [manifest-list] [manifest] [manifest...] [flags]", + Args: cobra.MatchAll(cobra.MinimumNArgs(2), cobra.OnlyValidArgs), + Short: "manifest rm will remove the specified image manifest if it is already referenced in the index", + Example: `pack manifest rm cnbs/sample-package:hello-multiarch-universe \ + cnbs/sample-package:hello-universe-windows`, + Long: `manifest rm will remove the specified image manifest if it is already referenced in the index. + + Sometimes users can just experiment with the feature locally and they want to discard all the local information created by pack. 'rm' command just delete the local manifest list`, + RunE: logError(logger, func(cmd *cobra.Command, args []string) error { + return nil + }), + } + + AddHelpFlag(cmd, "rm") + return cmd +} \ No newline at end of file diff --git a/internal/commands/manifest_rm_test.go b/internal/commands/manifest_rm_test.go new file mode 100644 index 0000000000..fe7b8c53f5 --- /dev/null +++ b/internal/commands/manifest_rm_test.go @@ -0,0 +1 @@ +package commands_test \ No newline at end of file