@@ -164,28 +164,6 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
164164 if err := identifiers .Validate (tmpl .Name ); err != nil {
165165 return nil , fmt .Errorf ("argument must be either an instance name, a YAML file path, or a URL, got %q: %w" , tmpl .Name , err )
166166 }
167- inst , err := store .Inspect (tmpl .Name )
168- if err == nil {
169- if createOnly {
170- return nil , fmt .Errorf ("instance %q already exists" , tmpl .Name )
171- }
172- logrus .Infof ("Using the existing instance %q" , tmpl .Name )
173- yqExprs , err := editflags .YQExpressions (flags , false )
174- if err != nil {
175- return nil , err
176- }
177- if len (yqExprs ) > 0 {
178- yq := yqutil .Join (yqExprs )
179- inst , err = applyYQExpressionToExistingInstance (inst , yq )
180- if err != nil {
181- return nil , fmt .Errorf ("failed to apply yq expression %q to instance %q: %w" , yq , tmpl .Name , err )
182- }
183- }
184- return inst , nil
185- }
186- if ! errors .Is (err , os .ErrNotExist ) {
187- return nil , err
188- }
189167 if arg != "" && arg != DefaultInstanceName {
190168 logrus .Infof ("Creating an instance %q from template://default (Not from template://%s)" , tmpl .Name , tmpl .Name )
191169 logrus .Warnf ("This form is deprecated. Use `limactl create --name=%s template://default` instead" , tmpl .Name )
@@ -197,6 +175,29 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
197175 }
198176 }
199177
178+ inst , err := store .Inspect (tmpl .Name )
179+ if err == nil {
180+ if createOnly {
181+ return nil , fmt .Errorf ("instance %q already exists" , tmpl .Name )
182+ }
183+ logrus .Infof ("Using the existing instance %q" , tmpl .Name )
184+ yqExprs , err := editflags .YQExpressions (flags , false )
185+ if err != nil {
186+ return nil , err
187+ }
188+ if len (yqExprs ) > 0 {
189+ yq := yqutil .Join (yqExprs )
190+ inst , err = applyYQExpressionToExistingInstance (inst , yq )
191+ if err != nil {
192+ return nil , fmt .Errorf ("failed to apply yq expression %q to instance %q: %w" , yq , tmpl .Name , err )
193+ }
194+ }
195+ return inst , nil
196+ }
197+ if ! errors .Is (err , os .ErrNotExist ) {
198+ return nil , err
199+ }
200+
200201 yqExprs , err := editflags .YQExpressions (flags , true )
201202 if err != nil {
202203 return nil , err
0 commit comments