-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Description
Description
There's a redundant validation for error in the toAPIBuildOptions function in the compose/build.go file.
The initialsed err is never allotted a value and is still being checked. We should be able to safely remove this check.
CodeSnippet:
func (opts buildOptions) toAPIBuildOptions(services []string) (api.BuildOptions, error) {
var SSHKeys []types.SSHKey
var err error
if opts.ssh != "" {
id, path, found := strings.Cut(opts.ssh, "=")
if !found && id != "default" {
return api.BuildOptions{}, fmt.Errorf("invalid ssh key %q", opts.ssh)
}
SSHKeys = append(SSHKeys, types.SSHKey{
ID: id,
Path: path,
})
if err != nil {
return api.BuildOptions{}, err
}
}
builderName := opts.builder
if builderName == "" {
builderName = os.Getenv("BUILDX_BUILDER")
}
uiMode := ui.Mode
if uiMode == ui.ModeJSON {
uiMode = "rawjson"
}
return api.BuildOptions{
Pull: opts.pull,
Push: opts.push,
Progress: uiMode,
Args: types.NewMappingWithEquals(opts.args),
NoCache: opts.noCache,
Quiet: opts.quiet,
Services: services,
Deps: opts.deps,
SSHs: SSHKeys,
Builder: builderName,
}, nil
}
Steps To Reproduce
NA
Compose Version
NA
Docker Environment
NA
Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels