Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 1 addition & 4 deletions internal/deployer/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import (
)

// runKubectl is a thin wrapper around k8s.RunKubectl that injects the deployer's logger.
//
// TODO(ROX-34499): perhaps this should not return a pointer so that the lack of nil checks elsewhere
// is robust?
func (d *Deployer) runKubectl(ctx context.Context, opts k8s.KubectlOptions) (*k8s.KubectlResult, error) {
func (d *Deployer) runKubectl(ctx context.Context, opts k8s.KubectlOptions) (k8s.KubectlResult, error) {
return k8s.RunKubectl(ctx, d.logger, opts)
}
10 changes: 5 additions & 5 deletions internal/k8s/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type KubectlResult struct {
}

// RunKubectl executes a kubectl command with automatic retries on transient errors
func RunKubectl(ctx context.Context, log *logger.Logger, opts KubectlOptions) (*KubectlResult, error) {
func RunKubectl(ctx context.Context, log *logger.Logger, opts KubectlOptions) (KubectlResult, error) {
if opts.MaxAttempts <= 0 {
opts.MaxAttempts = 3
}
Expand Down Expand Up @@ -88,14 +88,14 @@ func RunKubectl(ctx context.Context, log *logger.Logger, opts KubectlOptions) (*
lastErr = err

if err == nil {
return &KubectlResult{
return KubectlResult{
Stdout: stdout.String(),
Stderr: lastStderr,
}, nil
}

if opts.IgnoreErrors {
return &KubectlResult{
return KubectlResult{
Stdout: stdout.String(),
Stderr: lastStderr,
}, nil
Expand All @@ -111,7 +111,7 @@ func RunKubectl(ctx context.Context, log *logger.Logger, opts KubectlOptions) (*
}

if !isRetryable || attempt == opts.MaxAttempts {
return &KubectlResult{
return KubectlResult{
Stdout: stdout.String(),
Stderr: lastStderr,
}, fmt.Errorf("kubectl command failed: %w", err)
Expand All @@ -122,7 +122,7 @@ func RunKubectl(ctx context.Context, log *logger.Logger, opts KubectlOptions) (*
}
}

return &KubectlResult{
return KubectlResult{
Stdout: "",
Stderr: lastStderr,
}, fmt.Errorf("kubectl command failed after %d attempts: %w", opts.MaxAttempts, lastErr)
Expand Down
Loading