Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 4 additions & 3 deletions cmd/upgrade_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,14 @@ func (uc *UpgradeCommand) process(ctx context.Context, path config.UpgradePath)
testCommand = version.TestCommand
}

if version.TestSubPath == "" {
version.TestSubPath = "testing"
workspace := uc.config.OperatorConfig.Workspace
if version.TestSubPath != "" {
workspace = fmt.Sprintf("%s/%s", uc.config.OperatorConfig.Workspace, version.TestSubPath)
Comment on lines +206 to +208
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

The workspace path construction duplicates uc.config.OperatorConfig.Workspace. Consider using filepath.Join() for cross-platform path handling and store the base workspace in a variable to avoid repetition.

Suggested change
workspace := uc.config.OperatorConfig.Workspace
if version.TestSubPath != "" {
workspace = fmt.Sprintf("%s/%s", uc.config.OperatorConfig.Workspace, version.TestSubPath)
baseWorkspace := uc.config.OperatorConfig.Workspace
workspace := baseWorkspace
if version.TestSubPath != "" {
workspace = filepath.Join(baseWorkspace, version.TestSubPath)

Copilot uses AI. Check for mistakes.
}

// Execute test commands
if err := uc.execCommand(ctx,
fmt.Sprintf("%s/%s", uc.config.OperatorConfig.Workspace, version.TestSubPath),
workspace,
testCommand); err != nil {
return fmt.Errorf("failed to execute test command: %v", err)
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Command struct {
Name string
Args []string
Dir string
Env []string
}

// CommandResult represents the result of a command execution
Expand Down Expand Up @@ -43,6 +44,14 @@ func RunCommand(ctx context.Context, cmd Command) CommandResult {
runCmd := exec.CommandContext(ctx, cmd.Name, cmd.Args...)
runCmd.Dir = cmd.Dir

// Inherit current process environment variables
runCmd.Env = os.Environ()

// Add custom environment variables if specified
if len(cmd.Env) > 0 {
runCmd.Env = append(runCmd.Env, cmd.Env...)
}

// Create buffers to capture output
var stdoutBuf, stderrBuf bytes.Buffer

Expand Down