@@ -139,6 +139,7 @@ var startCmdArgs struct {
139139 Foreground bool
140140 SaveConfig bool
141141 LegacyCPU int // for backward compatibility
142+ Template bool
142143 }
143144}
144145
@@ -171,6 +172,7 @@ func init() {
171172 startCmd .Flags ().BoolVarP (& startCmdArgs .Flags .Foreground , "foreground" , "f" , false , "Keep colima in the foreground" )
172173 startCmd .Flags ().StringVar (& startCmdArgs .Hostname , "hostname" , "" , "custom hostname for the virtual machine" )
173174 startCmd .Flags ().StringVarP (& startCmdArgs .DiskImage , "disk-image" , "i" , "" , "file path to a custom disk image" )
175+ startCmd .Flags ().BoolVar (& startCmdArgs .Flags .Template , "template" , false , "use the template file for initial configuration" )
174176
175177 // retain cpu flag for backward compatibility
176178 startCmd .Flags ().IntVar (& startCmdArgs .Flags .LegacyCPU , "cpu" , defaultCPU , "number of CPUs" )
@@ -410,13 +412,21 @@ func prepareConfig(cmd *cobra.Command) {
410412
411413 // if there is no existing settings
412414 if current .Empty () {
413- // attempt template
414- template , err := configmanager .LoadFrom (templateFile ())
415- if err != nil {
416- // use default config if there is no template or existing settings
415+ templateUsed := false
416+
417+ // attempt template if enabled
418+ if startCmdArgs .Flags .Template {
419+ template , err := configmanager .LoadFrom (templateFile ())
420+ if err == nil {
421+ current = template
422+ templateUsed = true
423+ }
424+ }
425+
426+ if ! templateUsed {
427+ // use default config if there is no template or template is disabled
417428 return
418429 }
419- current = template
420430 }
421431
422432 // set missing defaults in the current config
0 commit comments