Skip to content

Commit ea4882e

Browse files
committed
initial commit for version flag in download init
Signed-off-by: Josh Brewer <[email protected]>
1 parent a70c12f commit ea4882e

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/cmd/zarf_tools.go

+14-6
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ import (
3535
"github.com/zarf-dev/zarf/src/types"
3636
)
3737

38-
var subAltNames []string
39-
var outputDirectory string
40-
var updateCredsInitOpts types.ZarfInitOptions
38+
var (
39+
subAltNames []string
40+
outputDirectory string
41+
updateCredsInitOpts types.ZarfInitOptions
42+
)
4143

4244
const (
4345
registryKey = "registry"
@@ -455,7 +457,9 @@ func (o *clearCacheOptions) run(cmd *cobra.Command, _ []string) error {
455457
return nil
456458
}
457459

458-
type downloadInitOptions struct{}
460+
type downloadInitOptions struct {
461+
version string
462+
}
459463

460464
func newDownloadInitCommand() *cobra.Command {
461465
o := &downloadInitOptions{}
@@ -467,13 +471,17 @@ func newDownloadInitCommand() *cobra.Command {
467471
}
468472

469473
cmd.Flags().StringVarP(&outputDirectory, "output-directory", "o", "", lang.CmdToolsDownloadInitFlagOutputDirectory)
470-
474+
cmd.Flags().StringVarP(&o.version, "version", "v", o.version, "Specify version to download (defaults to current CLI version)")
471475
return cmd
472476
}
473477

474478
func (o *downloadInitOptions) run(cmd *cobra.Command, _ []string) error {
479+
if o.version == "" {
480+
o.version = config.CLIVersion
481+
}
482+
475483
ctx := cmd.Context()
476-
url := zoci.GetInitPackageURL(config.CLIVersion)
484+
url := zoci.GetInitPackageURL(o.version)
477485
remote, err := zoci.NewRemote(ctx, url, oci.PlatformForArch(config.GetArch()))
478486
if err != nil {
479487
return fmt.Errorf("unable to download the init package: %w", err)

0 commit comments

Comments
 (0)