@@ -128,9 +128,11 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
128128
129129 const yBytesLimit = 4 * 1024 * 1024 // 4MiB
130130
131- if ok , u := guessarg .SeemsTemplateURL (arg ); ok {
131+ isTemplateURL , templateURL := guessarg .SeemsTemplateURL (arg )
132+ switch {
133+ case isTemplateURL :
132134 // No need to use SecureJoin here. https://github.com/lima-vm/lima/pull/805#discussion_r853411702
133- templateName := filepath .Join (u .Host , u .Path )
135+ templateName := filepath .Join (templateURL .Host , templateURL .Path )
134136 logrus .Debugf ("interpreting argument %q as a template name %q" , arg , templateName )
135137 if st .instName == "" {
136138 // e.g., templateName = "deprecated/centos-7" , st.instName = "centos-7"
@@ -140,7 +142,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
140142 if err != nil {
141143 return nil , err
142144 }
143- } else if guessarg .SeemsHTTPURL (arg ) {
145+ case guessarg .SeemsHTTPURL (arg ):
144146 if st .instName == "" {
145147 st .instName , err = guessarg .InstNameFromURL (arg )
146148 if err != nil {
@@ -161,7 +163,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
161163 if err != nil {
162164 return nil , err
163165 }
164- } else if guessarg .SeemsFileURL (arg ) {
166+ case guessarg .SeemsFileURL (arg ):
165167 if st .instName == "" {
166168 st .instName , err = guessarg .InstNameFromURL (arg )
167169 if err != nil {
@@ -178,7 +180,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
178180 if err != nil {
179181 return nil , err
180182 }
181- } else if guessarg .SeemsYAMLPath (arg ) {
183+ case guessarg .SeemsYAMLPath (arg ):
182184 if st .instName == "" {
183185 st .instName , err = guessarg .InstNameFromYAMLPath (arg )
184186 if err != nil {
@@ -195,7 +197,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
195197 if err != nil {
196198 return nil , err
197199 }
198- } else if arg == "-" {
200+ case arg == "-" :
199201 if st .instName == "" {
200202 return nil , errors .New ("must pass instance name with --name when reading template from stdin" )
201203 }
@@ -209,7 +211,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
209211 return nil , errors .New ("cannot use --tty=true and read template from stdin together" )
210212 }
211213 tty = false
212- } else {
214+ default :
213215 if arg == "" {
214216 if st .instName == "" {
215217 st .instName = DefaultInstanceName
0 commit comments