@@ -35,9 +35,11 @@ import (
35
35
"github.com/zarf-dev/zarf/src/types"
36
36
)
37
37
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
+ )
41
43
42
44
const (
43
45
registryKey = "registry"
@@ -455,7 +457,9 @@ func (o *clearCacheOptions) run(cmd *cobra.Command, _ []string) error {
455
457
return nil
456
458
}
457
459
458
- type downloadInitOptions struct {}
460
+ type downloadInitOptions struct {
461
+ version string
462
+ }
459
463
460
464
func newDownloadInitCommand () * cobra.Command {
461
465
o := & downloadInitOptions {}
@@ -467,13 +471,17 @@ func newDownloadInitCommand() *cobra.Command {
467
471
}
468
472
469
473
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)" )
471
475
return cmd
472
476
}
473
477
474
478
func (o * downloadInitOptions ) run (cmd * cobra.Command , _ []string ) error {
479
+ if o .version == "" {
480
+ o .version = config .CLIVersion
481
+ }
482
+
475
483
ctx := cmd .Context ()
476
- url := zoci .GetInitPackageURL (config . CLIVersion )
484
+ url := zoci .GetInitPackageURL (o . version )
477
485
remote , err := zoci .NewRemote (ctx , url , oci .PlatformForArch (config .GetArch ()))
478
486
if err != nil {
479
487
return fmt .Errorf ("unable to download the init package: %w" , err )
0 commit comments