Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled the whitespace linter. #5889

Merged
merged 1 commit into from
Dec 20, 2022
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
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ linters:
- unconvert
- depguard
- unused
# TODO: enable whitespace linter
#- whitespace
- whitespace
output:
uniq-by-line: false
issues:
Expand Down
2 changes: 0 additions & 2 deletions cmd/entrypoint/subcommands/subcommands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func TestProcessSuccessfulSubcommands(t *testing.T) {
t.Errorf("unexpected return value from step-init command w/ params: %v", returnValue)
}
})

}

// TestProcessIgnoresNonSubcommands checks that any input to Process which
Expand All @@ -84,7 +83,6 @@ func TestProcessIgnoresNonSubcommands(t *testing.T) {
})

t.Run(DecodeScriptCommand, func(t *testing.T) {

if err := Process([]string{DecodeScriptCommand}); err != nil {
t.Errorf("unexpected error processing command with 0 additional args: %v", err)
}
Expand Down
1 change: 0 additions & 1 deletion cmd/imagedigestexporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func main() {
Value: imageResource.URL,
ResourceName: imageResource.Name,
})

}

if err := termination.WriteMessage(*terminationMessagePath, output); err != nil {
Expand Down
3 changes: 0 additions & 3 deletions pkg/apis/pipeline/v1/container_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

// Step runs a subcomponent of a Task
type Step struct {

// Name of the Step specified as a DNS_LABEL.
// Each Step in a Task must have a unique name.
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
Expand Down Expand Up @@ -191,7 +190,6 @@ func (s *Step) SetContainerFields(c corev1.Container) {

// StepTemplate is a template for a Step
type StepTemplate struct {

// Image reference name.
// More info: https://kubernetes.io/docs/concepts/containers/images
// This field is optional to allow higher level config management to default or override
Expand Down Expand Up @@ -308,7 +306,6 @@ func (s *StepTemplate) ToK8sContainer() *corev1.Container {

// Sidecar has nearly the same data structure as Step but does not have the ability to timeout.
type Sidecar struct {

// Name of the Sidecar specified as a DNS_LABEL.
// Each Sidecar in a Task must have a unique name (DNS_LABEL).
// Cannot be updated.
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1/pipeline_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ func taskContainsResult(resultExpression string, pipelineTaskNames sets.String,
if strings.HasPrefix(value, "finally") && !pipelineFinallyTaskNames.Has(pipelineTaskName) {
return false
}

}
}
return true
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1/pipelinerun_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ func TestPipelineRunTimeouts(t *testing.T) {
expectedTasksTimeout: &metav1.Duration{Duration: 10 * time.Minute},
expectedFinallyTimeout: &metav1.Duration{Duration: 50 * time.Minute},
}, {

name: "pipeline and finally timeout set",
timeouts: &v1.TimeoutFields{Pipeline: &metav1.Duration{Duration: time.Hour}, Finally: &metav1.Duration{Duration: 10 * time.Minute}},
expectedTasksTimeout: &metav1.Duration{Duration: 50 * time.Minute},
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1/pipelinerun_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ func validateSpecStatus(status PipelineRunSpecStatus) *apis.FieldError {
PipelineRunSpecStatusCancelledRunFinally,
PipelineRunSpecStatusStoppedRunFinally,
PipelineRunSpecStatusPending), "status")

}

func validateTimeoutDuration(field string, d *metav1.Duration) (errs *apis.FieldError) {
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1/result_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ func TestResultsValidateError(t *testing.T) {
if d := cmp.Diff(tt.expectedError.Error(), err.Error(), cmpopts.IgnoreUnexported(apis.FieldError{})); d != "" {
t.Errorf("TaskSpec.Validate() errors diff %s", diff.PrintWantGot(d))
}

})
}
}
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1/task_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func (*Task) GetGroupVersionKind() schema.GroupVersionKind {

// TaskSpec defines the desired state of Task.
type TaskSpec struct {

// Params is a list of input parameters required to run the task. Params
// must be supplied as inputs in TaskRuns unless they declare a default
// value.
Expand Down
2 changes: 0 additions & 2 deletions pkg/apis/pipeline/v1/task_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ func validateStepObjectUsageAsWhole(step Step, prefix string, vars sets.String)
}
for i, arg := range step.Args {
errs = errs.Also(validateTaskNoObjectReferenced(arg, prefix, vars).ViaFieldIndex("args", i))

}
for _, env := range step.Env {
errs = errs.Also(validateTaskNoObjectReferenced(env.Value, prefix, vars).ViaFieldKey("env", env.Name))
Expand Down Expand Up @@ -475,7 +474,6 @@ func validateStepArrayUsage(step Step, prefix string, vars sets.String) *apis.Fi
}
for i, arg := range step.Args {
errs = errs.Also(validateTaskArraysIsolated(arg, prefix, vars).ViaFieldIndex("args", i))

}
for _, env := range step.Env {
errs = errs.Also(validateTaskNoArrayReferenced(env.Value, prefix, vars).ViaFieldKey("env", env.Name))
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1/task_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,6 @@ func TestStepOnError(t *testing.T) {
}
})
}

}

// TestIncompatibleAPIVersions exercises validation of fields that
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1/workspace_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ func TestWorkspaceBindingValidateValid(t *testing.T) {
}
})
}

}

func TestWorkspaceBindingValidateInvalid(t *testing.T) {
Expand Down
3 changes: 0 additions & 3 deletions pkg/apis/pipeline/v1beta1/container_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

// Step runs a subcomponent of a Task
type Step struct {

// Name of the Step specified as a DNS_LABEL.
// Each Step in a Task must have a unique name.
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
Expand Down Expand Up @@ -271,7 +270,6 @@ func (s *Step) SetContainerFields(c corev1.Container) {

// StepTemplate is a template for a Step
type StepTemplate struct {

// Deprecated. This field will be removed in a future release.
// Default name for each Step specified as a DNS_LABEL.
// Each Step in a Task must have a unique name.
Expand Down Expand Up @@ -489,7 +487,6 @@ func (s *StepTemplate) ToK8sContainer() *corev1.Container {

// Sidecar has nearly the same data structure as Step but does not have the ability to timeout.
type Sidecar struct {

// Name of the Sidecar specified as a DNS_LABEL.
// Each Sidecar in a Task must have a unique name (DNS_LABEL).
// Cannot be updated.
Expand Down
2 changes: 0 additions & 2 deletions pkg/apis/pipeline/v1beta1/pipeline_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ func taskContainsResult(resultExpression string, pipelineTaskNames sets.String,
if strings.HasPrefix(value, "finally") && !pipelineFinallyTaskNames.Has(pipelineTaskName) {
return false
}

}
}
return true
Expand Down Expand Up @@ -425,7 +424,6 @@ func validateDeclaredResources(resources []PipelineDeclaredResource, tasks []Pip
required = append(required, output.Resource)
}
}

}
for _, t := range finalTasks {
if t.Resources != nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1beta1/pipelinerun_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ func TestPipelineRunTimeouts(t *testing.T) {
expectedTasksTimeout: &metav1.Duration{Duration: 10 * time.Minute},
expectedFinallyTimeout: &metav1.Duration{Duration: 50 * time.Minute},
}, {

name: "pipeline and finally timeout set",
timeouts: &v1beta1.TimeoutFields{Pipeline: &metav1.Duration{Duration: time.Hour}, Finally: &metav1.Duration{Duration: 10 * time.Minute}},
expectedTasksTimeout: &metav1.Duration{Duration: 50 * time.Minute},
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1beta1/pipelinerun_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ func validateSpecStatus(status PipelineRunSpecStatus) *apis.FieldError {
PipelineRunSpecStatusCancelledRunFinally,
PipelineRunSpecStatusStoppedRunFinally,
PipelineRunSpecStatusPending), "status")

}

func validateTimeoutDuration(field string, d *metav1.Duration) (errs *apis.FieldError) {
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1beta1/resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ type ResultType int
// of string, and then fail the running TaskRun because it doesn't know how to interpret
// the string value that the TaskRun's entrypoint will emit when it completes.
func (r *ResultType) UnmarshalJSON(data []byte) error {

var asInt int
var intErr error

Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1beta1/resource_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ func TestApplyTaskModifier_AlreadyAdded(t *testing.T) {
}

func TestPipelineResourceResult_UnmarshalJSON(t *testing.T) {

testcases := []struct {
name string
data string
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1beta1/resource_types_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func validateTaskRunResources(ctx context.Context, resources []TaskResourceBindi
if r.ResourceSpec != nil && r.ResourceSpec.Validate(ctx) != nil {
return r.ResourceSpec.Validate(ctx)
}

}
return nil
}
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1beta1/result_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ func TestResultsValidateError(t *testing.T) {
if d := cmp.Diff(tt.expectedError.Error(), err.Error(), cmpopts.IgnoreUnexported(apis.FieldError{})); d != "" {
t.Errorf("TaskSpec.Validate() errors diff %s", diff.PrintWantGot(d))
}

})
}
}
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1beta1/resultref.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ func stripVarSubExpression(expression string) string {
// - Output: "", "", 0, "", error
// TODO: may use regex for each type to handle possible reference formats
func parseExpression(substitutionExpression string) (string, string, int, string, error) {

if looksLikeResultRef(substitutionExpression) {
subExpressions := strings.Split(substitutionExpression, ".")
// For string result: tasks.<taskName>.results.<stringResultName>
Expand Down
2 changes: 0 additions & 2 deletions pkg/apis/pipeline/v1beta1/task_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ func validateStepObjectUsageAsWhole(step Step, prefix string, vars sets.String)
}
for i, arg := range step.Args {
errs = errs.Also(validateTaskNoObjectReferenced(arg, prefix, vars).ViaFieldIndex("args", i))

}
for _, env := range step.Env {
errs = errs.Also(validateTaskNoObjectReferenced(env.Value, prefix, vars).ViaFieldKey("env", env.Name))
Expand Down Expand Up @@ -496,7 +495,6 @@ func validateStepArrayUsage(step Step, prefix string, vars sets.String) *apis.Fi
}
for i, arg := range step.Args {
errs = errs.Also(validateTaskArraysIsolated(arg, prefix, vars).ViaFieldIndex("args", i))

}
for _, env := range step.Env {
errs = errs.Also(validateTaskNoArrayReferenced(env.Value, prefix, vars).ViaFieldKey("env", env.Name))
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1beta1/taskrun_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,6 @@ func TestResources_Validate(t *testing.T) {
}
})
}

}

func TestResources_Invalidate(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1beta1/workspace_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ func TestWorkspaceBindingValidateValid(t *testing.T) {
}
})
}

}

func TestWorkspaceBindingValidateInvalid(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ func TestResourceValidation_Invalid(t *testing.T) {
}, {
name: "missing spec",
res: &v1alpha1.PipelineResource{

ObjectMeta: metav1.ObjectMeta{
Name: "temp",
},
Expand Down Expand Up @@ -300,5 +299,4 @@ func TestAllowedGCSStorageType(t *testing.T) {
}
})
}

}
1 change: 0 additions & 1 deletion pkg/apis/validate/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
)

func TestMetadataInvalidLongName(t *testing.T) {

invalidMetas := []*metav1.ObjectMeta{
{Name: strings.Repeat("s", validate.MaxLength+1)},
{Name: "bad,name"},
Expand Down
1 change: 0 additions & 1 deletion pkg/artifacts/artifact_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ func TestNeedsPVC(t *testing.T) {
}
})
}

}

func TestInitializeArtifactStorage(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pkg/artifacts/artifacts_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ func InitializeArtifactStorage(ctx context.Context, images pipeline.Images, pr *
// CleanupArtifactStorage will delete the PipelineRun's artifact storage PVC if it exists. The PVC is created for using
// an output workspace or artifacts from one Task to another Task. No other PVCs will be impacted by this cleanup.
func CleanupArtifactStorage(ctx context.Context, pr *v1beta1.PipelineRun, c kubernetes.Interface) error {

if needsPVC(ctx) {
err := deletePVC(ctx, pr, c)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/internal/affinityassistant/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func TestNewTransformer(t *testing.T) {
}

func TestNewTransformerWithNodeAffinity(t *testing.T) {

nodeAffinity := &corev1.NodeAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: &corev1.NodeSelector{
NodeSelectorTerms: []corev1.NodeSelectorTerm{{
Expand Down
2 changes: 0 additions & 2 deletions pkg/internal/computeresources/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,6 @@ func cmpRequestsAndLimits(t *testing.T, want, got corev1.PodSpec) {
t.Errorf("Expected %d init containers, got %d", len(want.InitContainers), len(got.InitContainers))
} else {
for i, c := range got.InitContainers {

// compare name only if present in "want" so we can be sure which container gets which resources
if want.InitContainers[i].Name != "" {
if d := cmp.Diff(want.InitContainers[i].Name, c.Name); d != "" {
Expand All @@ -963,7 +962,6 @@ func cmpRequestsAndLimits(t *testing.T, want, got corev1.PodSpec) {
t.Errorf("Expected %d containers, got %d", len(want.Containers), len(got.Containers))
} else {
for i, c := range got.Containers {

// compare name only if present in "want" so we can be sure which container gets which resources
if want.Containers[i].Name != "" {
if d := cmp.Diff(want.Containers[i].Name, c.Name); d != "" {
Expand Down
1 change: 0 additions & 1 deletion pkg/pipelinerunmetrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ func nilInsertTag(task, taskrun string) []tag.Mutator {
// count for number of PipelineRuns succeed or failed
// returns an error if its failed to log the metrics
func (r *Recorder) DurationAndCount(pr *v1beta1.PipelineRun, beforeCondition *apis.Condition) error {

if !r.initialized {
return fmt.Errorf("ignoring the metrics recording for %s , failed to initialize the metrics recorder", pr.Name)
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/pipelinerunmetrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ func TestRecordPipelineRunDurationCount(t *testing.T) {
} else {
metricstest.CheckStatsNotReported(t, "pipelinerun_count")
}

})
}
}
Expand Down Expand Up @@ -374,7 +373,6 @@ func TestRecordRunningPipelineRunsCount(t *testing.T) {
t.Errorf("RunningPipelineRuns: %v", err)
}
metricstest.CheckLastValueData(t, "running_pipelineruns_count", map[string]string{}, 1)

}

func unregisterMetrics() {
Expand Down
1 change: 0 additions & 1 deletion pkg/pod/entrypoint_lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func resolveEntrypoints(ctx context.Context, cache EntrypointCache, namespace, s
// can skip lookups while resolving the same TaskRun.
localCache := map[name.Reference]imageData{}
for i, s := range steps {

// If the command is already specified, there's nothing to resolve.
if len(s.Command) > 0 {
continue
Expand Down
2 changes: 0 additions & 2 deletions pkg/pod/entrypoint_lookup_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ func TestGetImageWithImagePullSecrets(t *testing.T) {
if (err != nil) != tc.wantErr {
t.Fatalf("get() = %+v, %v, wantErr %t", i, err, tc.wantErr)
}

})

}
}

Expand Down
1 change: 0 additions & 1 deletion pkg/pod/entrypoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ func TestEntryPointOnError(t *testing.T) {
}
})
}

}

func TestEntryPointStepOutputConfigs(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/pod/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1279,7 +1279,6 @@ _EOF_
{
desc: "setting host aliases",
ts: v1beta1.TaskSpec{

Steps: []v1beta1.Step{
{
Name: "host-aliases",
Expand Down Expand Up @@ -1948,7 +1947,6 @@ _EOF_
}

func TestPodBuildwithAlphaAPIEnabled(t *testing.T) {

placeScriptsContainer := corev1.Container{
Name: "place-scripts",
Image: "busybox",
Expand Down
1 change: 0 additions & 1 deletion pkg/pod/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ cat > ${scriptfile} << '%s'

initContainer.Args[1] += fmt.Sprintf(initScriptDirective, tmpFile, heredoc, debugScript.content, heredoc)
}

}

return containers
Expand Down
Loading