Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pkg/commands/utils/build_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,16 @@ func extractImageConfig(dockerClient *client.Client, ctx context.Context, imageT
return nil, "", fmt.Errorf("failed to inspect base image: %w", err)
}

originalCmd := inspectResp.Config.Cmd
if len(originalCmd) == 0 && len(inspectResp.Config.Entrypoint) > 0 {
originalCmd = inspectResp.Config.Entrypoint
// Combine Entrypoint and Cmd to get full command
cmd := []string{}
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Use var cmd []string instead of cmd := []string{} to avoid allocating an empty slice that will be immediately replaced by append operations. This is more idiomatic and slightly more efficient.

Suggested change
cmd := []string{}
var cmd []string

Copilot uses AI. Check for mistakes.
if len(inspectResp.Config.Entrypoint) > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a test for this whole function?

cmd = append(cmd, inspectResp.Config.Entrypoint...)
}
if len(inspectResp.Config.Cmd) > 0 {
cmd = append(cmd, inspectResp.Config.Cmd...)
}

return originalCmd, inspectResp.Config.User, nil
return cmd, inspectResp.Config.User, nil
}

// extractDigestFromRepoDigest extracts the sha256 digest from a Docker repo digest string
Expand Down