From f28e31b212feecc4548050e049603b620a5a8152 Mon Sep 17 00:00:00 2001 From: Zack Brady Date: Tue, 27 Aug 2024 02:45:14 -0400 Subject: [PATCH 1/4] initial desc formatting/updates --- cmd/hauler/cli/completion.go | 24 ++++++++--------- cmd/hauler/cli/login.go | 11 ++++---- cmd/hauler/cli/store.go | 50 ++++++++++++++---------------------- internal/flags/add.go | 24 ++++++++--------- internal/flags/copy.go | 8 +++--- internal/flags/extract.go | 2 +- internal/flags/info.go | 8 +++--- internal/flags/load.go | 2 +- internal/flags/login.go | 6 ++--- internal/flags/save.go | 2 +- internal/flags/serve.go | 22 ++++++++-------- internal/flags/store.go | 2 +- internal/flags/sync.go | 12 ++++----- 13 files changed, 77 insertions(+), 96 deletions(-) diff --git a/cmd/hauler/cli/completion.go b/cmd/hauler/cli/completion.go index 8d50263..47a8a1d 100644 --- a/cmd/hauler/cli/completion.go +++ b/cmd/hauler/cli/completion.go @@ -9,9 +9,8 @@ import ( func addCompletion(parent *cobra.Command) { cmd := &cobra.Command{ - Use: "hauler completion", - Short: "Generates completion scripts for various shells", - Long: `The completion sub-command generates completion scripts for various shells.`, + Use: "completion", + Short: "Generate autocompletion scripts for various shells", } cmd.AddCommand( @@ -32,8 +31,7 @@ func completionError(err error) ([]string, cobra.ShellCompDirective) { func addCompletionZsh() *cobra.Command { cmd := &cobra.Command{ Use: "zsh", - Short: "Generates zsh completion scripts", - Long: `The completion sub-command generates completion scripts for zsh.`, + Short: "Generates completion scripts for zsh", Example: `To load completion run . <(hauler completion zsh) @@ -51,7 +49,7 @@ func addCompletionZsh() *cobra.Command { mv _hauler ~/.oh-my-zsh/completions # oh-my-zsh mv _hauler ~/.zprezto/modules/completion/external/src/ # zprezto`, Run: func(cmd *cobra.Command, args []string) { - cmd.GenZshCompletion(os.Stdout) + cmd.Root().GenZshCompletion(os.Stdout) // Cobra doesn't source zsh completion file, explicitly doing it here fmt.Println("compdef _hauler hauler") }, @@ -62,8 +60,7 @@ func addCompletionZsh() *cobra.Command { func addCompletionBash() *cobra.Command { cmd := &cobra.Command{ Use: "bash", - Short: "Generates bash completion scripts", - Long: `The completion sub-command generates completion scripts for bash.`, + Short: "Generates completion scripts for bash", Example: `To load completion run . <(hauler completion bash) @@ -73,7 +70,7 @@ func addCompletionBash() *cobra.Command { # ~/.bashrc or ~/.profile command -v hauler >/dev/null && . <(hauler completion bash)`, Run: func(cmd *cobra.Command, args []string) { - cmd.GenBashCompletion(os.Stdout) + cmd.Root().GenBashCompletion(os.Stdout) }, } return cmd @@ -82,15 +79,14 @@ func addCompletionBash() *cobra.Command { func addCompletionFish() *cobra.Command { cmd := &cobra.Command{ Use: "fish", - Short: "Generates fish completion scripts", - Long: `The completion sub-command generates completion scripts for fish.`, + Short: "Generates completion scripts for fish", Example: `To configure your fish shell to load completions for each session write this script to your completions dir: hauler completion fish > ~/.config/fish/completions/hauler.fish See http://fishshell.com/docs/current/index.html#completion-own for more details`, Run: func(cmd *cobra.Command, args []string) { - cmd.GenFishCompletion(os.Stdout, true) + cmd.Root().GenFishCompletion(os.Stdout, true) }, } return cmd @@ -99,7 +95,7 @@ func addCompletionFish() *cobra.Command { func addCompletionPowershell() *cobra.Command { cmd := &cobra.Command{ Use: "powershell", - Short: "Generates powershell completion scripts", + Short: "Generates completion scripts for powershell", Long: `The completion sub-command generates completion scripts for powershell.`, Example: `To load completion run @@ -117,7 +113,7 @@ func addCompletionPowershell() *cobra.Command { cd "${XDG_CONFIG_HOME:-"$HOME/.config/"}/powershell/modules" hauler completion powershell >> hauler-completions.ps1`, Run: func(cmd *cobra.Command, args []string) { - cmd.GenPowerShellCompletion(os.Stdout) + cmd.Root().GenPowerShellCompletion(os.Stdout) }, } return cmd diff --git a/cmd/hauler/cli/login.go b/cmd/hauler/cli/login.go index 65025e2..74fcf79 100644 --- a/cmd/hauler/cli/login.go +++ b/cmd/hauler/cli/login.go @@ -18,12 +18,11 @@ func addLogin(parent *cobra.Command) { o := &flags.LoginOpts{} cmd := &cobra.Command{ - Use: "login", - Short: "Log in to a registry", - Example: ` -# Log in to reg.example.com -hauler login reg.example.com -u bob -p haulin`, - Args: cobra.ExactArgs(1), + Use: "login", + Short: "Login to a registry", + Long: "Login to an OCI Compliant Registry (stored at ~/.docker/config.json)", + Example: "# login to registry.example.com\nhauler login registry.example.com -u bob -p haulin", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, arg []string) error { ctx := cmd.Context() diff --git a/cmd/hauler/cli/store.go b/cmd/hauler/cli/store.go index 044d074..21d294e 100644 --- a/cmd/hauler/cli/store.go +++ b/cmd/hauler/cli/store.go @@ -16,7 +16,7 @@ func addStore(parent *cobra.Command) { cmd := &cobra.Command{ Use: "store", Aliases: []string{"s"}, - Short: "Interact with hauler's embedded content store", + Short: "Interact with the embedded content store", RunE: func(cmd *cobra.Command, args []string) error { return cmd.Help() }, @@ -31,8 +31,6 @@ func addStore(parent *cobra.Command) { addStoreServe(), addStoreInfo(), addStoreCopy(), - - // TODO: Remove this in favor of sync? addStoreAdd(), ) @@ -44,7 +42,7 @@ func addStoreExtract() *cobra.Command { cmd := &cobra.Command{ Use: "extract", - Short: "Extract content from the store to disk", + Short: "Extract individual content outside the store to disk", Aliases: []string{"x"}, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -112,7 +110,7 @@ func addStoreLoad() *cobra.Command { func addStoreServe() *cobra.Command { cmd := &cobra.Command{ Use: "serve", - Short: "Expose the content of a local store through an OCI compliant registry or file server", + Short: "Expose the local content store via an OCI Compliant Registry or Fileserver", RunE: func(cmd *cobra.Command, args []string) error { return cmd.Help() }, @@ -130,7 +128,7 @@ func addStoreServeRegistry() *cobra.Command { o := &flags.ServeRegistryOpts{StoreRootOpts: rootStoreOpts} cmd := &cobra.Command{ Use: "registry", - Short: "Serve the embedded registry", + Short: "Expose the embedded OCI Compliant Registry", RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() @@ -153,7 +151,7 @@ func addStoreServeFiles() *cobra.Command { o := &flags.ServeFilesOpts{StoreRootOpts: rootStoreOpts} cmd := &cobra.Command{ Use: "fileserver", - Short: "Serve the file server", + Short: "Expose the embedded Fileserver", RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() @@ -231,7 +229,7 @@ func addStoreCopy() *cobra.Command { cmd := &cobra.Command{ Use: "copy", - Short: "Copy all store contents to another OCI registry", + Short: "Copy all store content outside the store", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() @@ -252,7 +250,7 @@ func addStoreCopy() *cobra.Command { func addStoreAdd() *cobra.Command { cmd := &cobra.Command{ Use: "add", - Short: "Add content to store", + Short: "Add content to the store", RunE: func(cmd *cobra.Command, args []string) error { return cmd.Help() }, @@ -271,9 +269,10 @@ func addStoreAddFile() *cobra.Command { o := &flags.AddFileOpts{StoreRootOpts: rootStoreOpts} cmd := &cobra.Command{ - Use: "file", - Short: "Add a file to the content store", - Args: cobra.ExactArgs(1), + Use: "file", + Short: "Add a file to the store", + Example: "# fetch local file\nhauler store add file file.txt\n\n# fetch remote file\nhauler store add file https://get.rke2.io/install.sh\n\n# fetch remote file and assign new name\nhauler store add file https://get.hauler.dev --name hauler-install.sh", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() @@ -294,9 +293,10 @@ func addStoreAddImage() *cobra.Command { o := &flags.AddImageOpts{StoreRootOpts: rootStoreOpts} cmd := &cobra.Command{ - Use: "image", - Short: "Add an image to the content store", - Args: cobra.ExactArgs(1), + Use: "image", + Short: "Add a image to the store", + Example: "# fetch image\nhauler store add image busybox\n\n# fetch image with repository and tag\nhauler store add image library/busybox:stable\n\n# fetch image with full image reference and specific platform\nhauler store add image ghcr.io/hauler-dev/hauler-debug:v1.0.7 --platform linux/amd74\n\n# fetch image with full image reference via digest\nhauler store add image gcr.io/distroless/base@sha256:7fa7445dfbebae4f4b7ab0e6ef99276e96075ae42584af6286ba080750d6dfe5\n\n# fetch image with full image reference, specific platform, and signature verification\nhauler store add image rgcrprod.azurecr.us/hauler/rke2-manifest.yaml:v1.28.12-rke2r1 --platform linux/amd64 --key carbide-key.pub", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() @@ -320,22 +320,10 @@ func addStoreAddChart() *cobra.Command { } cmd := &cobra.Command{ - Use: "chart", - Short: "Add a local or remote chart to the content store", - Example: ` -# add a local chart -hauler store add chart path/to/chart/directory - -# add a local compressed chart -hauler store add chart path/to/chart.tar.gz - -# add a remote chart -hauler store add chart longhorn --repo "https://charts.longhorn.io" - -# add a specific version of a chart -hauler store add chart rancher --repo "https://releases.rancher.com/server-charts/latest" --version "2.6.2" -`, - Args: cobra.ExactArgs(1), + Use: "chart", + Short: "Add a helm chart to the store", + Example: "# fetch local helm chart\nhauler store add chart path/to/chart/directory\n\n# fetch local compressed helm chart\nhauler store add chart path/to/chart.tar.gz\n\n# fetch remote oci helm chart\nhauler store add chart hauler-helm --repo oci://ghcr.io/hauler-dev\n\n# fetch remote oci helm chart with version\nhauler store add chart hauler-helm --repo oci://ghcr.io/hauler-dev --version 1.0.6\n\n# fetch remote helm chart\nhauler store add chart rancher --repo https://releases.rancher.com/server-charts/stable\n\n# fetch remote helm chart with specific version\nhauler store add chart rancher --repo https://releases.rancher.com/server-charts/latest --version 2.9.1", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() diff --git a/internal/flags/add.go b/internal/flags/add.go index f4fb138..feb43d1 100644 --- a/internal/flags/add.go +++ b/internal/flags/add.go @@ -14,8 +14,8 @@ type AddImageOpts struct { func (o *AddImageOpts) AddFlags(cmd *cobra.Command) { f := cmd.Flags() - f.StringVarP(&o.Key, "key", "k", "", "(Optional) Path to the key for digital signature verification") - f.StringVarP(&o.Platform, "platform", "p", "", "(Optional) Specific platform to save. i.e. linux/amd64. Defaults to all if flag is omitted.") + f.StringVarP(&o.Key, "key", "k", "", "(Optional) Location of public key to use for signature verification") + f.StringVarP(&o.Platform, "platform", "p", "", "(Optional) Specifiy the platform of the image... i.e. linux/amd64 (defaults to all)") } type AddFileOpts struct { @@ -25,7 +25,7 @@ type AddFileOpts struct { func (o *AddFileOpts) AddFlags(cmd *cobra.Command) { f := cmd.Flags() - f.StringVarP(&o.Name, "name", "n", "", "(Optional) Name to assign to file in store") + f.StringVarP(&o.Name, "name", "n", "", "(Optional) Rewrite the name of the file") } type AddChartOpts struct { @@ -37,13 +37,13 @@ type AddChartOpts struct { func (o *AddChartOpts) AddFlags(cmd *cobra.Command) { f := cmd.Flags() - f.StringVar(&o.ChartOpts.RepoURL, "repo", "", "chart repository url where to locate the requested chart") - f.StringVar(&o.ChartOpts.Version, "version", "", "specify a version constraint for the chart version to use. This constraint can be a specific tag (e.g. 1.1.1) or it may reference a valid range (e.g. ^2.0.0). If this is not specified, the latest version is used") - f.BoolVar(&o.ChartOpts.Verify, "verify", false, "verify the package before using it") - f.StringVar(&o.ChartOpts.Username, "username", "", "chart repository username where to locate the requested chart") - f.StringVar(&o.ChartOpts.Password, "password", "", "chart repository password where to locate the requested chart") - f.StringVar(&o.ChartOpts.CertFile, "cert-file", "", "identify HTTPS client using this SSL certificate file") - f.StringVar(&o.ChartOpts.KeyFile, "key-file", "", "identify HTTPS client using this SSL key file") - f.BoolVar(&o.ChartOpts.InsecureSkipTLSverify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the chart download") - f.StringVar(&o.ChartOpts.CaFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle") + f.StringVar(&o.ChartOpts.RepoURL, "repo", "", "Location of the chart (https:// | http:// | oci://)") + f.StringVar(&o.ChartOpts.Version, "version", "", "(Optional) Specifiy the version of the chart (v1.0.0 | 2.0.0 | ^2.0.0)") + f.BoolVar(&o.ChartOpts.Verify, "verify", false, "(Optional) Verify the chart before fetching it") + f.StringVar(&o.ChartOpts.Username, "username", "", "(Optional) Username to use for authentication") + f.StringVar(&o.ChartOpts.Password, "password", "", "(Optional) Password to use for authentication") + f.StringVar(&o.ChartOpts.CertFile, "cert-file", "", "(Optional) Location of the TLS Certificate to use for client authenication") + f.StringVar(&o.ChartOpts.KeyFile, "key-file", "", "(Optional) Location of the TLS Key to use for client authenication") + f.BoolVar(&o.ChartOpts.InsecureSkipTLSverify, "insecure-skip-tls-verify", false, "(Optional) Skip TLS certificate verification") + f.StringVar(&o.ChartOpts.CaFile, "ca-file", "", "(Optional) Location of CA Bundle to enable certification verification") } diff --git a/internal/flags/copy.go b/internal/flags/copy.go index b6848ce..233dedf 100644 --- a/internal/flags/copy.go +++ b/internal/flags/copy.go @@ -14,8 +14,8 @@ type CopyOpts struct { func (o *CopyOpts) AddFlags(cmd *cobra.Command) { f := cmd.Flags() - f.StringVarP(&o.Username, "username", "u", "", "Username when copying to an authenticated remote registry") - f.StringVarP(&o.Password, "password", "p", "", "Password when copying to an authenticated remote registry") - f.BoolVar(&o.Insecure, "insecure", false, "Toggle allowing insecure connections when copying to a remote registry") - f.BoolVar(&o.PlainHTTP, "plain-http", false, "Toggle allowing plain http connections when copying to a remote registry") + f.StringVarP(&o.Username, "username", "u", "", "(Optional) Username to use for authentication") + f.StringVarP(&o.Password, "password", "p", "", "(Optional) Password to use for authentication") + f.BoolVar(&o.Insecure, "insecure", false, "(Optional) Allow insecure connections") + f.BoolVar(&o.PlainHTTP, "plain-http", false, "(Optional) Allow plain HTTP connections") } diff --git a/internal/flags/extract.go b/internal/flags/extract.go index 29156f5..f48b426 100644 --- a/internal/flags/extract.go +++ b/internal/flags/extract.go @@ -10,5 +10,5 @@ type ExtractOpts struct { func (o *ExtractOpts) AddFlags(cmd *cobra.Command) { f := cmd.Flags() - f.StringVarP(&o.DestinationDir, "output", "o", "", "Directory to save contents to (defaults to current directory)") + f.StringVarP(&o.DestinationDir, "output", "o", "", "(Optional) Specify the directory to output (defaults to current directory)") } diff --git a/internal/flags/info.go b/internal/flags/info.go index 68641d5..df03922 100644 --- a/internal/flags/info.go +++ b/internal/flags/info.go @@ -14,9 +14,7 @@ type InfoOpts struct { func (o *InfoOpts) AddFlags(cmd *cobra.Command) { f := cmd.Flags() - f.StringVarP(&o.OutputFormat, "output", "o", "table", "Output format (table, json)") - f.StringVarP(&o.TypeFilter, "type", "t", "all", "Filter on type (image, chart, file, sigs, atts, sbom)") - f.BoolVar(&o.ListRepos, "list-repos", false, "List all repository names") - - // TODO: Regex/globbing + f.StringVarP(&o.OutputFormat, "output", "o", "table", "(Optional) Specify the output format (table | json)") + f.StringVarP(&o.TypeFilter, "type", "t", "all", "(Optional) Filter on content type (image | chart | file | sigs | atts | sbom)") + f.BoolVar(&o.ListRepos, "list-repos", false, "(Optional) List all repository names") } diff --git a/internal/flags/load.go b/internal/flags/load.go index 7c13c35..adefc1b 100644 --- a/internal/flags/load.go +++ b/internal/flags/load.go @@ -14,5 +14,5 @@ func (o *LoadOpts) AddFlags(cmd *cobra.Command) { // On Windows, the default is GetTempPath, returning the first non-empty // value from %TMP%, %TEMP%, %USERPROFILE%, or the Windows directory. // On Plan 9, the default is /tmp. - f.StringVarP(&o.TempOverride, "tempdir", "t", "", "overrides the default directory for temporary files, as returned by your OS.") + f.StringVarP(&o.TempOverride, "tempdir", "t", "", "(Optional) Override the default temporary directiory determined by the OS") } diff --git a/internal/flags/login.go b/internal/flags/login.go index e4940e4..a7bece5 100644 --- a/internal/flags/login.go +++ b/internal/flags/login.go @@ -10,7 +10,7 @@ type LoginOpts struct { func (o *LoginOpts) AddFlags(cmd *cobra.Command) { f := cmd.Flags() - f.StringVarP(&o.Username, "username", "u", "", "Username to use for authentication") - f.StringVarP(&o.Password, "password", "p", "", "Password to use for authentication") - f.BoolVar(&o.PasswordStdin, "password-stdin", false, "Password to use for authentication (from stdin)") + f.StringVarP(&o.Username, "username", "u", "", "(Optional) Username to use for authentication") + f.StringVarP(&o.Password, "password", "p", "", "(Optional) Password to use for authentication") + f.BoolVar(&o.PasswordStdin, "password-stdin", false, "(Optional) Password to use for authentication (from stdin)") } diff --git a/internal/flags/save.go b/internal/flags/save.go index c1d66ae..a175cb9 100644 --- a/internal/flags/save.go +++ b/internal/flags/save.go @@ -10,5 +10,5 @@ type SaveOpts struct { func (o *SaveOpts) AddFlags(cmd *cobra.Command) { f := cmd.Flags() - f.StringVarP(&o.FileName, "filename", "f", "haul.tar.zst", "Name of archive") + f.StringVarP(&o.FileName, "filename", "f", "haul.tar.zst", "(Optional) Specify the name of outputted archive") } diff --git a/internal/flags/serve.go b/internal/flags/serve.go index fcbce8a..452b57c 100644 --- a/internal/flags/serve.go +++ b/internal/flags/serve.go @@ -23,13 +23,13 @@ type ServeRegistryOpts struct { func (o *ServeRegistryOpts) AddFlags(cmd *cobra.Command) { f := cmd.Flags() - f.IntVarP(&o.Port, "port", "p", 5000, "Port used to accept incoming connections") - f.StringVar(&o.RootDir, "directory", "registry", "Directory to use for backend. Defaults to $PWD/registry") - f.StringVarP(&o.ConfigFile, "config", "c", "", "Path to config file, overrides all other flags") - f.BoolVar(&o.ReadOnly, "readonly", true, "Run the registry as readonly") + f.IntVarP(&o.Port, "port", "p", 5000, "(Optional) Specify the port to use for incoming connections") + f.StringVar(&o.RootDir, "directory", "registry", "(Optional) Directory to use for backend. Defaults to $PWD/registry") + f.StringVarP(&o.ConfigFile, "config", "c", "", "(Optional) Location of config file (overrides all flags)") + f.BoolVar(&o.ReadOnly, "readonly", true, "(Optional) Run the registry as readonly") - f.StringVar(&o.TLSCert, "tls-cert", "", "Location of the TLS Certificate") - f.StringVar(&o.TLSKey, "tls-key", "", "Location of the TLS Key") + f.StringVar(&o.TLSCert, "tls-cert", "", "(Optional) Location of the TLS Certificate to use for server authenication") + f.StringVar(&o.TLSKey, "tls-key", "", "(Optional) Location of the TLS Key to use for server authenication") cmd.MarkFlagsRequiredTogether("tls-cert", "tls-key") } @@ -76,12 +76,12 @@ type ServeFilesOpts struct { func (o *ServeFilesOpts) AddFlags(cmd *cobra.Command) { f := cmd.Flags() - f.IntVarP(&o.Port, "port", "p", 8080, "Port used to accept incoming connections") - f.IntVarP(&o.Timeout, "timeout", "t", 60, "Timeout duration for HTTP Requests in seconds for both reads/writes") - f.StringVar(&o.RootDir, "directory", "fileserver", "Directory to use for backend. Defaults to $PWD/fileserver") + f.IntVarP(&o.Port, "port", "p", 8080, "(Optional) Specify the port to use for incoming connections") + f.IntVarP(&o.Timeout, "timeout", "t", 60, "(Optional) Timeout duration for HTTP Requests in seconds for both reads/writes") + f.StringVar(&o.RootDir, "directory", "fileserver", "(Optional) Directory to use for backend. Defaults to $PWD/fileserver") - f.StringVar(&o.TLSCert, "tls-cert", "", "Location of the TLS Certificate") - f.StringVar(&o.TLSKey, "tls-key", "", "Location of the TLS Key") + f.StringVar(&o.TLSCert, "tls-cert", "", "(Optional) Location of the TLS Certificate to use for server authenication") + f.StringVar(&o.TLSKey, "tls-key", "", "(Optional) Location of the TLS Key to use for server authenication") cmd.MarkFlagsRequiredTogether("tls-cert", "tls-key") } diff --git a/internal/flags/store.go b/internal/flags/store.go index cf22c73..1d9dc90 100644 --- a/internal/flags/store.go +++ b/internal/flags/store.go @@ -19,7 +19,7 @@ type StoreRootOpts struct { func (o *StoreRootOpts) AddFlags(cmd *cobra.Command) { pf := cmd.PersistentFlags() - pf.StringVarP(&o.StoreDir, "store", "s", consts.DefaultStoreName, "Location to create store at") + pf.StringVarP(&o.StoreDir, "store", "s", consts.DefaultStoreName, "(Optional) Specify the directory to use for the content store") pf.StringVar(&o.CacheDir, "cache", "", "(deprecated flag and currently not used)") } diff --git a/internal/flags/sync.go b/internal/flags/sync.go index 30bae39..7ba419d 100644 --- a/internal/flags/sync.go +++ b/internal/flags/sync.go @@ -15,10 +15,10 @@ type SyncOpts struct { func (o *SyncOpts) AddFlags(cmd *cobra.Command) { f := cmd.Flags() - f.StringSliceVarP(&o.ContentFiles, "files", "f", []string{}, "Path(s) to local content files (Manifests). i.e. '--files ./rke2-files.yml") - f.StringVarP(&o.Key, "key", "k", "", "(Optional) Path to the key for signature verification") - f.StringSliceVar(&o.Products, "products", []string{}, "(Optional) Feature for RGS Carbide customers to fetch collections and content from the Carbide Registry. i.e. '--product rancher=v2.8.5,rke2=v1.28.11+rke2r1'") - f.StringVarP(&o.Platform, "platform", "p", "", "(Optional) Specific platform to save. i.e. linux/amd64. Defaults to all if flag is omitted.") - f.StringVarP(&o.Registry, "registry", "r", "", "(Optional) Default pull registry for image refs that are not specifying a registry name.") - f.StringVarP(&o.ProductRegistry, "product-registry", "c", "", "(Optional) Specific Product Registry to use. Defaults to RGS Carbide Registry (rgcrprod.azurecr.us).") + f.StringSliceVarP(&o.ContentFiles, "files", "f", []string{}, "Location of content manifests (files)... i.e. --files ./rke2-files.yaml") + f.StringVarP(&o.Key, "key", "k", "", "(Optional) Location of public key to use for signature verification") + f.StringSliceVar(&o.Products, "products", []string{}, "(Optional) Specify the product name to fetch collections from the product registry i.e. rancher=v2.8.5,rke2=v1.28.11+rke2r1") + f.StringVarP(&o.Platform, "platform", "p", "", "(Optional) Specify the platform of the image... i.e linux/amd64 (defaults to all)") + f.StringVarP(&o.Registry, "registry", "r", "", "(Optional) Specify the registry of the image for images that do not alredy define one") + f.StringVarP(&o.ProductRegistry, "product-registry", "c", "", "(Optional) Specify the product registry. Defaults to RGS Carbide Registry (rgcrprod.azurecr.us)") } From 01201091096f4c46bfcec866222ac46806345a65 Mon Sep 17 00:00:00 2001 From: Zack Brady Date: Sat, 31 Aug 2024 23:02:55 -0400 Subject: [PATCH 2/4] fixed typos --- cmd/hauler/cli/store.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/hauler/cli/store.go b/cmd/hauler/cli/store.go index 21d294e..3afa6d8 100644 --- a/cmd/hauler/cli/store.go +++ b/cmd/hauler/cli/store.go @@ -322,7 +322,7 @@ func addStoreAddChart() *cobra.Command { cmd := &cobra.Command{ Use: "chart", Short: "Add a helm chart to the store", - Example: "# fetch local helm chart\nhauler store add chart path/to/chart/directory\n\n# fetch local compressed helm chart\nhauler store add chart path/to/chart.tar.gz\n\n# fetch remote oci helm chart\nhauler store add chart hauler-helm --repo oci://ghcr.io/hauler-dev\n\n# fetch remote oci helm chart with version\nhauler store add chart hauler-helm --repo oci://ghcr.io/hauler-dev --version 1.0.6\n\n# fetch remote helm chart\nhauler store add chart rancher --repo https://releases.rancher.com/server-charts/stable\n\n# fetch remote helm chart with specific version\nhauler store add chart rancher --repo https://releases.rancher.com/server-charts/latest --version 2.9.1", + Example: "# fetch local helm chart\nhauler store add chart path/to/chart/directory --repo .\n\n# fetch local compressed helm chart\nhauler store add chart path/to/chart.tar.gz --repo .\n\n# fetch remote oci helm chart\nhauler store add chart hauler-helm --repo oci://ghcr.io/hauler-dev\n\n# fetch remote oci helm chart with version\nhauler store add chart hauler-helm --repo oci://ghcr.io/hauler-dev --version 1.0.6\n\n# fetch remote helm chart\nhauler store add chart rancher --repo https://releases.rancher.com/server-charts/stable\n\n# fetch remote helm chart with specific version\nhauler store add chart rancher --repo https://releases.rancher.com/server-charts/latest --version 2.9.1", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() From 0da2257fb9ee87b57fc2b2e11cce29e6cc431121 Mon Sep 17 00:00:00 2001 From: Zack Brady Date: Fri, 13 Sep 2024 08:54:03 -0400 Subject: [PATCH 3/4] updated commands base on feedback --- cmd/hauler/cli/store.go | 76 ++++++++++++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 20 deletions(-) diff --git a/cmd/hauler/cli/store.go b/cmd/hauler/cli/store.go index 3afa6d8..e0dfa02 100644 --- a/cmd/hauler/cli/store.go +++ b/cmd/hauler/cli/store.go @@ -16,7 +16,7 @@ func addStore(parent *cobra.Command) { cmd := &cobra.Command{ Use: "store", Aliases: []string{"s"}, - Short: "Interact with the embedded content store", + Short: "Interact with the content store", RunE: func(cmd *cobra.Command, args []string) error { return cmd.Help() }, @@ -42,7 +42,7 @@ func addStoreExtract() *cobra.Command { cmd := &cobra.Command{ Use: "extract", - Short: "Extract individual content outside the store to disk", + Short: "Extract artifacts from the store to disk", Aliases: []string{"x"}, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -66,7 +66,7 @@ func addStoreSync() *cobra.Command { cmd := &cobra.Command{ Use: "sync", - Short: "Sync content to the embedded content store", + Short: "Sync content to the content store", RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() @@ -110,7 +110,7 @@ func addStoreLoad() *cobra.Command { func addStoreServe() *cobra.Command { cmd := &cobra.Command{ Use: "serve", - Short: "Expose the local content store via an OCI Compliant Registry or Fileserver", + Short: "Expose the content store via an OCI Compliant Registry or Fileserver", RunE: func(cmd *cobra.Command, args []string) error { return cmd.Help() }, @@ -123,12 +123,12 @@ func addStoreServe() *cobra.Command { return cmd } -// RegistryCmd serves the embedded registry +// RegistryCmd serves the registry func addStoreServeRegistry() *cobra.Command { o := &flags.ServeRegistryOpts{StoreRootOpts: rootStoreOpts} cmd := &cobra.Command{ Use: "registry", - Short: "Expose the embedded OCI Compliant Registry", + Short: "Expose the OCI Compliant Registry", RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() @@ -151,7 +151,7 @@ func addStoreServeFiles() *cobra.Command { o := &flags.ServeFilesOpts{StoreRootOpts: rootStoreOpts} cmd := &cobra.Command{ Use: "fileserver", - Short: "Expose the embedded Fileserver", + Short: "Expose the Fileserver", RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() @@ -229,7 +229,7 @@ func addStoreCopy() *cobra.Command { cmd := &cobra.Command{ Use: "copy", - Short: "Copy all store content outside the store", + Short: "Copy all store content to another location", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() @@ -269,10 +269,17 @@ func addStoreAddFile() *cobra.Command { o := &flags.AddFileOpts{StoreRootOpts: rootStoreOpts} cmd := &cobra.Command{ - Use: "file", - Short: "Add a file to the store", - Example: "# fetch local file\nhauler store add file file.txt\n\n# fetch remote file\nhauler store add file https://get.rke2.io/install.sh\n\n# fetch remote file and assign new name\nhauler store add file https://get.hauler.dev --name hauler-install.sh", - Args: cobra.ExactArgs(1), + Use: "file", + Short: "Add a file to the store", + Example: `# fetch local file +hauler store add file file.txt + +# fetch remote file +hauler store add file https://get.rke2.io/install.sh + +# fetch remote file and assign new name +hauler store add file https://get.hauler.dev --name hauler-install.sh`, + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() @@ -293,10 +300,23 @@ func addStoreAddImage() *cobra.Command { o := &flags.AddImageOpts{StoreRootOpts: rootStoreOpts} cmd := &cobra.Command{ - Use: "image", - Short: "Add a image to the store", - Example: "# fetch image\nhauler store add image busybox\n\n# fetch image with repository and tag\nhauler store add image library/busybox:stable\n\n# fetch image with full image reference and specific platform\nhauler store add image ghcr.io/hauler-dev/hauler-debug:v1.0.7 --platform linux/amd74\n\n# fetch image with full image reference via digest\nhauler store add image gcr.io/distroless/base@sha256:7fa7445dfbebae4f4b7ab0e6ef99276e96075ae42584af6286ba080750d6dfe5\n\n# fetch image with full image reference, specific platform, and signature verification\nhauler store add image rgcrprod.azurecr.us/hauler/rke2-manifest.yaml:v1.28.12-rke2r1 --platform linux/amd64 --key carbide-key.pub", - Args: cobra.ExactArgs(1), + Use: "image", + Short: "Add a image to the store", + Example: `# fetch image +hauler store add image busybox + +# fetch image with repository and tag +hauler store add image library/busybox:stable + +# fetch image with full image reference and specific platform +hauler store add image ghcr.io/hauler-dev/hauler-debug:v1.0.7 --platform linux/amd64 + +# fetch image with full image reference via digest +hauler store add image gcr.io/distroless/base@sha256:7fa7445dfbebae4f4b7ab0e6ef99276e96075ae42584af6286ba080750d6dfe5 + +# fetch image with full image reference, specific platform, and signature verification +hauler store add image rgcrprod.azurecr.us/hauler/rke2-manifest.yaml:v1.28.12-rke2r1 --platform linux/amd64 --key carbide-key.pub`, + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() @@ -320,10 +340,26 @@ func addStoreAddChart() *cobra.Command { } cmd := &cobra.Command{ - Use: "chart", - Short: "Add a helm chart to the store", - Example: "# fetch local helm chart\nhauler store add chart path/to/chart/directory --repo .\n\n# fetch local compressed helm chart\nhauler store add chart path/to/chart.tar.gz --repo .\n\n# fetch remote oci helm chart\nhauler store add chart hauler-helm --repo oci://ghcr.io/hauler-dev\n\n# fetch remote oci helm chart with version\nhauler store add chart hauler-helm --repo oci://ghcr.io/hauler-dev --version 1.0.6\n\n# fetch remote helm chart\nhauler store add chart rancher --repo https://releases.rancher.com/server-charts/stable\n\n# fetch remote helm chart with specific version\nhauler store add chart rancher --repo https://releases.rancher.com/server-charts/latest --version 2.9.1", - Args: cobra.ExactArgs(1), + Use: "chart", + Short: "Add a helm chart to the store", + Example: `# fetch local helm chart +hauler store add chart path/to/chart/directory --repo . + +# fetch local compressed helm chart +hauler store add chart path/to/chart.tar.gz --repo . + +# fetch remote oci helm chart +hauler store add chart hauler-helm --repo oci://ghcr.io/hauler-dev + +# fetch remote oci helm chart with version +hauler store add chart hauler-helm --repo oci://ghcr.io/hauler-dev --version 1.0.6 + +# fetch remote helm chart +hauler store add chart rancher --repo https://releases.rancher.com/server-charts/stable + +# fetch remote helm chart with specific version +hauler store add chart rancher --repo https://releases.rancher.com/server-charts/latest --version 2.9.1`, + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() From 845cf6cd56de158ae22eee56b5b4416960f965f3 Mon Sep 17 00:00:00 2001 From: Zack Brady Date: Fri, 20 Sep 2024 17:41:31 -0400 Subject: [PATCH 4/4] more updates based on feedback --- cmd/hauler/cli/completion.go | 11 +++++------ cmd/hauler/cli/store.go | 8 ++++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cmd/hauler/cli/completion.go b/cmd/hauler/cli/completion.go index c27edca..bc44b9c 100644 --- a/cmd/hauler/cli/completion.go +++ b/cmd/hauler/cli/completion.go @@ -10,7 +10,7 @@ import ( func addCompletion(parent *cobra.Command) { cmd := &cobra.Command{ Use: "completion", - Short: "Generate autocompletion scripts for various shells", + Short: "Generate auto-completion scripts for various shells", } cmd.AddCommand( @@ -26,7 +26,7 @@ func addCompletion(parent *cobra.Command) { func addCompletionZsh() *cobra.Command { cmd := &cobra.Command{ Use: "zsh", - Short: "Generates completion scripts for zsh", + Short: "Generates auto-completion scripts for zsh", Example: `To load completion run . <(hauler completion zsh) @@ -55,7 +55,7 @@ func addCompletionZsh() *cobra.Command { func addCompletionBash() *cobra.Command { cmd := &cobra.Command{ Use: "bash", - Short: "Generates completion scripts for bash", + Short: "Generates auto-completion scripts for bash", Example: `To load completion run . <(hauler completion bash) @@ -74,7 +74,7 @@ func addCompletionBash() *cobra.Command { func addCompletionFish() *cobra.Command { cmd := &cobra.Command{ Use: "fish", - Short: "Generates completion scripts for fish", + Short: "Generates auto-completion scripts for fish", Example: `To configure your fish shell to load completions for each session write this script to your completions dir: hauler completion fish > ~/.config/fish/completions/hauler.fish @@ -90,8 +90,7 @@ func addCompletionFish() *cobra.Command { func addCompletionPowershell() *cobra.Command { cmd := &cobra.Command{ Use: "powershell", - Short: "Generates completion scripts for powershell", - Long: `The completion sub-command generates completion scripts for powershell.`, + Short: "Generates auto-completion scripts for powershell", Example: `To load completion run . <(hauler completion powershell) diff --git a/cmd/hauler/cli/store.go b/cmd/hauler/cli/store.go index e0dfa02..c4fae8e 100644 --- a/cmd/hauler/cli/store.go +++ b/cmd/hauler/cli/store.go @@ -42,7 +42,7 @@ func addStoreExtract() *cobra.Command { cmd := &cobra.Command{ Use: "extract", - Short: "Extract artifacts from the store to disk", + Short: "Extract artifacts from the content store to disk", Aliases: []string{"x"}, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { @@ -110,7 +110,7 @@ func addStoreLoad() *cobra.Command { func addStoreServe() *cobra.Command { cmd := &cobra.Command{ Use: "serve", - Short: "Expose the content store via an OCI Compliant Registry or Fileserver", + Short: "Serve the content store via an OCI Compliant Registry or Fileserver", RunE: func(cmd *cobra.Command, args []string) error { return cmd.Help() }, @@ -128,7 +128,7 @@ func addStoreServeRegistry() *cobra.Command { o := &flags.ServeRegistryOpts{StoreRootOpts: rootStoreOpts} cmd := &cobra.Command{ Use: "registry", - Short: "Expose the OCI Compliant Registry", + Short: "Serve the OCI Compliant Registry", RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() @@ -151,7 +151,7 @@ func addStoreServeFiles() *cobra.Command { o := &flags.ServeFilesOpts{StoreRootOpts: rootStoreOpts} cmd := &cobra.Command{ Use: "fileserver", - Short: "Expose the Fileserver", + Short: "Serve the Fileserver", RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context()