@@ -118,15 +118,10 @@ func editAction(cmd *cobra.Command, args []string) error {
118118 return err
119119 }
120120 if err := limayaml .Validate (y , true ); err != nil {
121- rejectedYAML := "lima.REJECTED.yaml"
122- if writeErr := os .WriteFile (rejectedYAML , yBytes , 0o644 ); writeErr != nil {
123- return fmt .Errorf ("the YAML is invalid, attempted to save the buffer as %q but failed: %w: %w" , rejectedYAML , writeErr , err )
124- }
125- // TODO: may need to support editing the rejected YAML
126- return fmt .Errorf ("the YAML is invalid, saved the buffer as %q: %w" , rejectedYAML , err )
121+ return saveRejectedYAML (yBytes , err )
127122 }
128123
129- if err := limayaml .ValidateYAMLAgainstLatest (yBytes , yContent ); err != nil {
124+ if err := limayaml .ValidateYAMLAgainstLatestConfig (yBytes , yContent ); err != nil {
130125 return saveRejectedYAML (yBytes , err )
131126 }
132127
@@ -177,6 +172,7 @@ func editBashComplete(cmd *cobra.Command, _ []string, _ string) ([]string, cobra
177172 return bashCompleteInstanceNames (cmd )
178173}
179174
175+ // saveRejectedYAML writes the rejected config and returns an error.
180176func saveRejectedYAML (y []byte , origErr error ) error {
181177 rejectedYAML := "lima.REJECTED.yaml"
182178 if writeErr := os .WriteFile (rejectedYAML , y , 0o644 ); writeErr != nil {
0 commit comments