@@ -32,7 +32,6 @@ func getDownloadCmd(config *crcConfig.Config) *cobra.Command {
3232 Short : "Download a specific CRC bundle" ,
3333 Long : "Download a specific CRC bundle from the mirrors. If no version or architecture is specified, the bundle for the current CRC version will be downloaded." ,
3434 RunE : func (cmd * cobra.Command , args []string ) error {
35- verbose , _ := cmd .Flags ().GetBool ("verbose" )
3635 force , _ := cmd .Flags ().GetBool ("force" )
3736 presetStr , _ := cmd .Flags ().GetString ("preset" )
3837
@@ -47,10 +46,9 @@ func getDownloadCmd(config *crcConfig.Config) *cobra.Command {
4746 preset = crcConfig .GetPreset (config )
4847 }
4948
50- return runDownload (args , preset , verbose , force )
49+ return runDownload (args , preset , force )
5150 },
5251 }
53- downloadCmd .Flags ().BoolP ("verbose" , "v" , false , "Show detailed download information" )
5452 downloadCmd .Flags ().BoolP ("force" , "f" , false , "Overwrite existing bundle if present" )
5553 downloadCmd .Flags ().StringP ("preset" , "p" , "" , "Target preset (openshift, okd, microshift)" )
5654
@@ -214,15 +212,15 @@ func runList(args []string, config *crcConfig.Config) error {
214212}
215213
216214func isBundleCached (preset crcPreset.Preset , version string ) bool {
217- bundleName := constructBundleName (preset , version , runtime . GOARCH )
215+ bundleName := constants . BundleForPreset (preset , version )
218216 bundlePath := filepath .Join (constants .MachineCacheDir , bundleName )
219217 if _ , err := os .Stat (bundlePath ); err == nil {
220218 return true
221219 }
222220 return false
223221}
224222
225- func runDownload (args []string , preset crcPreset.Preset , verbose bool , force bool ) error {
223+ func runDownload (args []string , preset crcPreset.Preset , force bool ) error {
226224 // Disk space check (simple check for ~10GB free)
227225 // This is a basic check, more robust checking would require syscall/windows specific implementations
228226 // We skip this for now to avoid adding heavy OS-specific deps, assuming user manages disk space or download fails naturally.
@@ -237,10 +235,8 @@ func runDownload(args []string, preset crcPreset.Preset, verbose bool, force boo
237235 }
238236 }
239237
240- if verbose {
241- logging .Infof ("Source: %s" , constants .GetDefaultBundleDownloadURL (preset ))
242- logging .Infof ("Destination: %s" , defaultBundlePath )
243- }
238+ logging .Debugf ("Source: %s" , constants .GetDefaultBundleDownloadURL (preset ))
239+ logging .Debugf ("Destination: %s" , defaultBundlePath )
244240 // For default bundle, we use the existing logic which handles verification internally
245241 _ , err := bundle .Download (context .Background (), preset , defaultBundlePath , false )
246242 return err
@@ -250,13 +246,11 @@ func runDownload(args []string, preset crcPreset.Preset, verbose bool, force boo
250246 version := args [0 ]
251247
252248 // Check if version is partial (Major.Minor) and resolve it if necessary
253- resolvedVersion , err := resolveOpenShiftVersion (preset , version , verbose )
249+ resolvedVersion , err := resolveOpenShiftVersion (preset , version )
254250 if err != nil {
255251 logging .Warnf ("Could not resolve version %s: %v. Trying with original version string." , version , err )
256252 } else if resolvedVersion != version {
257- if verbose {
258- logging .Infof ("Resolved version %s to %s" , version , resolvedVersion )
259- }
253+ logging .Debugf ("Resolved version %s to %s" , version , resolvedVersion )
260254 version = resolvedVersion
261255 }
262256
@@ -265,7 +259,7 @@ func runDownload(args []string, preset crcPreset.Preset, verbose bool, force boo
265259 architecture = args [1 ]
266260 }
267261
268- bundleName := constructBundleName (preset , version , architecture )
262+ bundleName := constants . BundleName (preset , version , architecture )
269263 bundlePath := filepath .Join (constants .MachineCacheDir , bundleName )
270264
271265 if ! force {
@@ -281,10 +275,8 @@ func runDownload(args []string, preset crcPreset.Preset, verbose bool, force boo
281275 sigURL := fmt .Sprintf ("%s%s" , baseVersionURL , "sha256sum.txt.sig" )
282276
283277 logging .Infof ("Downloading bundle: %s" , bundleName )
284- if verbose {
285- logging .Infof ("Source: %s" , bundleURL )
286- logging .Infof ("Destination: %s" , constants .MachineCacheDir )
287- }
278+ logging .Debugf ("Source: %s" , bundleURL )
279+ logging .Debugf ("Destination: %s" , constants .MachineCacheDir )
288280
289281 // Implement verification logic
290282 logging .Infof ("Verifying signature for %s..." , version )
@@ -334,30 +326,6 @@ func getVerifiedHashForCustomVersion(sigURL string, bundleName string) (string,
334326 return "" , fmt .Errorf ("hash for %s not found in signature file" , bundleName )
335327}
336328
337- func constructBundleName (preset crcPreset.Preset , version string , architecture string ) string {
338- var bundleName strings.Builder
339- bundleName .WriteString ("crc" )
340-
341- switch preset {
342- case crcPreset .OKD :
343- bundleName .WriteString ("_okd" )
344- case crcPreset .Microshift :
345- bundleName .WriteString ("_microshift" )
346- }
347-
348- switch runtime .GOOS {
349- case "darwin" :
350- bundleName .WriteString ("_vfkit" )
351- case "linux" :
352- bundleName .WriteString ("_libvirt" )
353- case "windows" :
354- bundleName .WriteString ("_hyperv" )
355- }
356-
357- fmt .Fprintf (& bundleName , "_%s_%s.crcbundle" , version , architecture )
358- return bundleName .String ()
359- }
360-
361329func fetchAvailableVersions (preset crcPreset.Preset ) ([]* semver.Version , error ) {
362330 // Base URL for the preset (e.g., https://mirror.openshift.com/pub/openshift-v4/clients/crc/bundles/openshift)
363331 baseURL := fmt .Sprintf ("https://mirror.openshift.com/pub/openshift-v4/clients/crc/bundles/%s/" , preset .String ())
@@ -433,7 +401,7 @@ func fetchAvailableVersions(preset crcPreset.Preset) ([]*semver.Version, error)
433401 return versions , nil
434402}
435403
436- func resolveOpenShiftVersion (preset crcPreset.Preset , inputVersion string , verbose bool ) (string , error ) {
404+ func resolveOpenShiftVersion (preset crcPreset.Preset , inputVersion string ) (string , error ) {
437405 // If input already looks like a full version (Major.Minor.Patch), return as is
438406 fullVersionRegex := regexp .MustCompile (`^\d+\.\d+\.\d+$` )
439407 if fullVersionRegex .MatchString (inputVersion ) {
@@ -446,9 +414,7 @@ func resolveOpenShiftVersion(preset crcPreset.Preset, inputVersion string, verbo
446414 return inputVersion , nil
447415 }
448416
449- if verbose {
450- logging .Infof ("Resolving latest version for %s..." , inputVersion )
451- }
417+ logging .Debugf ("Resolving latest version for %s..." , inputVersion )
452418
453419 versions , err := fetchAvailableVersions (preset )
454420 if err != nil {
0 commit comments