Skip to content

Commit

Permalink
fix: Remove unnecessary error handling (#961)
Browse files Browse the repository at this point in the history
Inside the ConfigureDefaultLimaYaml() function, there is a process to
write to the config file as follows:

    ```
if err := afero.WriteFile(lca.fs, lca.limaDefaultConfigPath,
limaCfgBytes, 0o600); err != nil {
return fmt.Errorf("failed to write to the lima config file: %w", err)
    }

    if err != nil {
    	return fmt.Errorf("unable to apply override config: %w", err)
    }
    ```

The current implementation has two error checks to determine if the file
can be written.

The err object in the second part is guaranteed to be nil due to the
previous if statement.

Therefore, this fix removes the unnecessary second error check.

Issue #, if available: N/A

*Description of changes:* The details are described in this commit
message.

*Testing done:* N/A



- [x] I've reviewed the guidance in CONTRIBUTING.md


#### License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

Signed-off-by: Hayato Kiwata <[email protected]>
  • Loading branch information
haytok authored May 28, 2024
1 parent d3c4165 commit f441fc9
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions pkg/config/lima_config_applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@ func (lca *limaConfigApplier) ConfigureDefaultLimaYaml() error {
return fmt.Errorf("failed to write to the lima config file: %w", err)
}

if err != nil {
return fmt.Errorf("unable to apply override config: %w", err)
}

return nil
}

Expand Down

0 comments on commit f441fc9

Please sign in to comment.