Skip to content

Commit 4fc162a

Browse files
Add golint support for M1 macs (darwin/arm64 arch) (#5435)
* Add darwin/arm64 golint support for M1 macs * Fix comment spaces for golint/gocritic * Use of ReplaceAll for golint/gocritic * Fix os.Exit will occur, defer os.Exit(0) won't run * Remove defer for os.Exit(0) Co-authored-by: Gaurav <[email protected]> * fix test Co-authored-by: Gaurav <[email protected]> Co-authored-by: gsquared94 <[email protected]>
1 parent 4588f51 commit 4fc162a

36 files changed

+85
-87
lines changed

cmd/skaffold/app/cmd/cmd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ func setFlagsFromEnvVariables(rootCmd *cobra.Command) {
249249
}
250250

251251
func FlagToEnvVarName(f *pflag.Flag) string {
252-
return fmt.Sprintf("SKAFFOLD_%s", strings.Replace(strings.ToUpper(f.Name), "-", "_", -1))
252+
return fmt.Sprintf("SKAFFOLD_%s", strings.ReplaceAll(strings.ToUpper(f.Name), "-", "_"))
253253
}
254254

255255
func setUpLogs(stdErr io.Writer, level string, timestamp bool) error {

cmd/skaffold/app/cmd/flags.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type Flag struct {
5454
// When adding a new flag to the registry, please specify the
5555
// command/commands to which the flag belongs in `DefinedOn` field.
5656
// If the flag is a global flag, or belongs to all the subcommands,
57-
/// specify "all"
57+
// specify "all"
5858
// FlagAddMethod is method which defines a flag value with specified
5959
// name, default value, and usage string. e.g. `StringVar`, `BoolVar`
6060
var flagRegistry = []Flag{

hack/golangci-lint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ set -e -o pipefail
1818

1919
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2020
BIN=${DIR}/bin
21-
VERSION=1.30.0
21+
VERSION=1.37.1
2222

2323
function install_linter() {
2424
echo "Installing GolangCI-Lint"

hack/install_golint.sh

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ is_supported_platform() {
6464
found=1
6565
case "$platform" in
6666
darwin/amd64) found=0 ;;
67+
darwin/arm64) found=0 ;;
6768
darwin/386) found=0 ;;
6869
windows/amd64) found=0 ;;
6970
windows/386) found=0 ;;

hack/man/man_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ func TestPrintMan(t *testing.T) {
4242
// Compare to current man page
4343
header, err := ioutil.ReadFile(filepath.Join("..", "..", "docs", "content", "en", "docs", "references", "cli", "index_header"))
4444
testutil.CheckError(t, false, err)
45-
header = bytes.Replace(header, []byte("\r\n"), []byte("\n"), -1)
45+
header = bytes.ReplaceAll(header, []byte("\r\n"), []byte("\n"))
4646

4747
expected, err := ioutil.ReadFile(filepath.Join("..", "..", "docs", "content", "en", "docs", "references", "cli", "_index.md"))
4848
testutil.CheckError(t, false, err)
49-
expected = bytes.Replace(expected, []byte("\r\n"), []byte("\n"), -1)
49+
expected = bytes.ReplaceAll(expected, []byte("\r\n"), []byte("\n"))
5050

5151
if string(expected) != string(header)+output {
5252
t.Error("You have skaffold command changes but haven't generated the CLI reference docs. Please run ./hack/generate-man.sh and commit the results!")

hack/schemas/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func generateSchema(root string, dryRun bool, version schema.Version) (bool, err
159159
return false, fmt.Errorf("unable to check that file exists %q: %w", output, err)
160160
}
161161

162-
current = bytes.Replace(current, []byte("\r\n"), []byte("\n"), -1)
162+
current = bytes.ReplaceAll(current, []byte("\r\n"), []byte("\n"))
163163

164164
if !dryRun {
165165
if err := ioutil.WriteFile(output, buf, os.ModePerm); err != nil {
@@ -172,7 +172,7 @@ func generateSchema(root string, dryRun bool, version schema.Version) (bool, err
172172
}
173173

174174
func yamlFieldName(field *ast.Field) string {
175-
tag := strings.Replace(field.Tag.Value, "`", "", -1)
175+
tag := strings.ReplaceAll(field.Tag.Value, "`", "")
176176
tags := reflect.StructTag(tag)
177177
yamlTag := tags.Get("yaml")
178178

@@ -292,7 +292,7 @@ func (g *schemaGenerator) newDefinition(name string, t ast.Expr, comment string,
292292
}
293293
}
294294

295-
description := strings.TrimSpace(strings.Replace(comment, "\n", " ", -1))
295+
description := strings.TrimSpace(strings.ReplaceAll(comment, "\n", " "))
296296

297297
// Extract default value
298298
if m := regexpDefaults.FindStringSubmatch(description); m != nil {

hack/schemas/main_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestGenerators(t *testing.T) {
6363
expected, err := ioutil.ReadFile(expectedOutput)
6464
t.CheckNoError(err)
6565

66-
expected = bytes.Replace(expected, []byte("\r\n"), []byte("\n"), -1)
66+
expected = bytes.ReplaceAll(expected, []byte("\r\n"), []byte("\n"))
6767

6868
schemaLoader := gojsonschema.NewBytesLoader(actual)
6969
_, err = gojsonschema.NewSchema(schemaLoader)

hack/struct-json/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func newDefinition(name string, t ast.Expr, comment string) *Definition {
9494
}
9595
}
9696

97-
description := strings.TrimSpace(strings.Replace(comment, "\n", " ", -1))
97+
description := strings.TrimSpace(strings.ReplaceAll(comment, "\n", " "))
9898
// Remove type prefix
9999
description = regexp.MustCompile("^"+ogName+" (\\*.*\\* )?((is (the )?)|(are (the )?)|(lists ))?").ReplaceAllString(description, "$1")
100100

integration/build_cluster_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func TestBuildKanikoWithExplicitRepo(t *testing.T) {
5555
skaffold.Build().WithRepo("").InDir("testdata/kaniko-explicit-repo").RunOrFail(t)
5656
}
5757

58-
//see integration/testdata/README.md for details
58+
// see integration/testdata/README.md for details
5959
func TestBuildInCluster(t *testing.T) {
6060
MarkIntegrationTest(t, NeedsGcp)
6161

integration/dev_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ func replaceInFile(target, replacement, filepath string) ([]byte, os.FileMode, e
315315
return nil, 0, err
316316
}
317317

318-
newContents := strings.Replace(string(original), target, replacement, -1)
318+
newContents := strings.ReplaceAll(string(original), target, replacement)
319319

320320
err = ioutil.WriteFile(filepath, []byte(newContents), 0)
321321

integration/rpc_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func TestEventLogHTTP(t *testing.T) {
144144
endpoint string
145145
}{
146146
{
147-
//TODO deprecate (https://github.com/GoogleContainerTools/skaffold/issues/3168)
147+
// TODO deprecate (https://github.com/GoogleContainerTools/skaffold/issues/3168)
148148
description: "/v1/event_log",
149149
endpoint: "/v1/event_log",
150150
},

integration/util.go

-2
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ func (k *NSKubernetesClient) waitForPods(podReady func(*v1.Pod) bool, podNames .
216216
select {
217217
case <-ctx.Done():
218218
k.printDiskFreeSpace()
219-
//k.debug("nodes")
220219
k.debug("pods")
221220
k.logs("pod", podNames)
222221
k.t.Fatalf("Timed out waiting for pods %v in namespace %q", podNames, k.ns)
@@ -312,7 +311,6 @@ func (k *NSKubernetesClient) waitForDeploymentsToStabilizeWithTimeout(timeout ti
312311
select {
313312
case <-ctx.Done():
314313
k.printDiskFreeSpace()
315-
//k.debug("nodes")
316314
k.debug("deployments.apps")
317315
k.debug("pods")
318316
k.logs("deployment.app", depNames)

pkg/skaffold/build/jib/init.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func validate(path string, enableGradleAnalysis bool) []ArtifactConfig {
133133
var results []ArtifactConfig
134134
for _, match := range matches {
135135
// Escape windows path separators
136-
line := bytes.Replace(match[1], []byte(`\`), []byte(`\\`), -1)
136+
line := bytes.ReplaceAll(match[1], []byte(`\`), []byte(`\\`))
137137
parsedJSON := jibJSON{}
138138
if err := json.Unmarshal(line, &parsedJSON); err != nil {
139139
logrus.Warnf("failed to parse jib json: %s", err.Error())

pkg/skaffold/build/jib/jib.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func refreshDependencyList(files *filesLists, cmd exec.Cmd) error {
205205
return errors.New("failed to get Jib dependencies")
206206
}
207207

208-
line := bytes.Replace(matches[1], []byte(`\`), []byte(`\\`), -1)
208+
line := bytes.ReplaceAll(matches[1], []byte(`\`), []byte(`\\`))
209209
return json.Unmarshal(line, &files)
210210
}
211211

pkg/skaffold/build/jib/sync_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,5 +300,5 @@ func getFileTime(file string, t *testing.T) time.Time {
300300

301301
// for paths that contain "\", they must be escaped in json strings
302302
func escapeBackslashes(path string) string {
303-
return strings.Replace(path, `\`, `\\`, -1)
303+
return strings.ReplaceAll(path, `\`, `\\`)
304304
}

pkg/skaffold/build/kaniko/types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const (
7979
VerbosityFlag = "--verbosity"
8080
// WhitelistVarRunFlag additional flag
8181
WhitelistVarRunFlag = "--whitelist-var-run"
82-
//DefaultImage is image used by the Kaniko pod by default
82+
// DefaultImage is image used by the Kaniko pod by default
8383
DefaultImage = "gcr.io/kaniko-project/executor:latest"
8484
// DefaultSecretName for kaniko pod
8585
DefaultSecretName = "kaniko-secret"

pkg/skaffold/build/tag/tag.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func GenerateFullyQualifiedImageName(t Tagger, workingDir, imageName string) (st
4949
if strings.Contains(tag, DeprecatedImageName) {
5050
warnings.Printf("{{.IMAGE_NAME}} is deprecated, envTemplate's template should only specify the tag value. See https://skaffold.dev/docs/pipeline-stages/taggers/")
5151

52-
return strings.Replace(tag, DeprecatedImageName, imageName, -1), nil
52+
return strings.ReplaceAll(tag, DeprecatedImageName, imageName), nil
5353
}
5454

5555
return fmt.Sprintf("%s:%s", imageName, tag), nil

pkg/skaffold/debug/transform_go_test.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ func TestTransformManifestDelve(t *testing.T) {
293293
}}}},
294294
true,
295295
&appsv1.Deployment{
296-
//ObjectMeta: metav1.ObjectMeta{
297-
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
298-
//},
296+
// ObjectMeta: metav1.ObjectMeta{
297+
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
298+
// },
299299
Spec: appsv1.DeploymentSpec{
300300
Replicas: int32p(1),
301301
Template: v1.PodTemplateSpec{
@@ -336,9 +336,9 @@ func TestTransformManifestDelve(t *testing.T) {
336336
}}}},
337337
true,
338338
&appsv1.ReplicaSet{
339-
//ObjectMeta: metav1.ObjectMeta{
339+
// ObjectMeta: metav1.ObjectMeta{
340340
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
341-
//},
341+
// },
342342
Spec: appsv1.ReplicaSetSpec{
343343
Replicas: int32p(1),
344344
Template: v1.PodTemplateSpec{
@@ -379,9 +379,9 @@ func TestTransformManifestDelve(t *testing.T) {
379379
}}}},
380380
true,
381381
&appsv1.StatefulSet{
382-
//ObjectMeta: metav1.ObjectMeta{
382+
// ObjectMeta: metav1.ObjectMeta{
383383
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
384-
//},
384+
// },
385385
Spec: appsv1.StatefulSetSpec{
386386
Replicas: int32p(1),
387387
Template: v1.PodTemplateSpec{
@@ -421,9 +421,9 @@ func TestTransformManifestDelve(t *testing.T) {
421421
}}}},
422422
true,
423423
&appsv1.DaemonSet{
424-
//ObjectMeta: metav1.ObjectMeta{
424+
// ObjectMeta: metav1.ObjectMeta{
425425
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
426-
//},
426+
// },
427427
Spec: appsv1.DaemonSetSpec{
428428
Template: v1.PodTemplateSpec{
429429
ObjectMeta: metav1.ObjectMeta{
@@ -462,9 +462,9 @@ func TestTransformManifestDelve(t *testing.T) {
462462
}}}},
463463
true,
464464
&batchv1.Job{
465-
//ObjectMeta: metav1.ObjectMeta{
465+
// ObjectMeta: metav1.ObjectMeta{
466466
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
467-
//},
467+
// },
468468
Spec: batchv1.JobSpec{
469469
Template: v1.PodTemplateSpec{
470470
ObjectMeta: metav1.ObjectMeta{
@@ -504,9 +504,9 @@ func TestTransformManifestDelve(t *testing.T) {
504504
}}}},
505505
true,
506506
&v1.ReplicationController{
507-
//ObjectMeta: metav1.ObjectMeta{
507+
// ObjectMeta: metav1.ObjectMeta{
508508
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
509-
//},
509+
// },
510510
Spec: v1.ReplicationControllerSpec{
511511
Replicas: int32p(1),
512512
Template: &v1.PodTemplateSpec{

pkg/skaffold/debug/transform_jvm_test.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,9 @@ func TestTransformManifestJVM(t *testing.T) {
280280
}}}}},
281281
true,
282282
&appsv1.Deployment{
283-
//ObjectMeta: metav1.ObjectMeta{
283+
// ObjectMeta: metav1.ObjectMeta{
284284
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
285-
//},
285+
// },
286286
Spec: appsv1.DeploymentSpec{
287287
Replicas: int32p(1),
288288
Template: v1.PodTemplateSpec{
@@ -312,9 +312,9 @@ func TestTransformManifestJVM(t *testing.T) {
312312
}}}}},
313313
true,
314314
&appsv1.ReplicaSet{
315-
//ObjectMeta: metav1.ObjectMeta{
315+
// ObjectMeta: metav1.ObjectMeta{
316316
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
317-
//},
317+
// },
318318
Spec: appsv1.ReplicaSetSpec{
319319
Replicas: int32p(1),
320320
Template: v1.PodTemplateSpec{
@@ -344,9 +344,9 @@ func TestTransformManifestJVM(t *testing.T) {
344344
}}}}},
345345
true,
346346
&appsv1.StatefulSet{
347-
//ObjectMeta: metav1.ObjectMeta{
347+
// ObjectMeta: metav1.ObjectMeta{
348348
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
349-
//},
349+
// },
350350
Spec: appsv1.StatefulSetSpec{
351351
Replicas: int32p(1),
352352
Template: v1.PodTemplateSpec{
@@ -375,9 +375,9 @@ func TestTransformManifestJVM(t *testing.T) {
375375
}}}}},
376376
true,
377377
&appsv1.DaemonSet{
378-
//ObjectMeta: metav1.ObjectMeta{
378+
// ObjectMeta: metav1.ObjectMeta{
379379
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
380-
//},
380+
// },
381381
Spec: appsv1.DaemonSetSpec{
382382
Template: v1.PodTemplateSpec{
383383
ObjectMeta: metav1.ObjectMeta{
@@ -405,9 +405,9 @@ func TestTransformManifestJVM(t *testing.T) {
405405
}}}}},
406406
true,
407407
&batchv1.Job{
408-
//ObjectMeta: metav1.ObjectMeta{
408+
// ObjectMeta: metav1.ObjectMeta{
409409
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
410-
//},
410+
// },
411411
Spec: batchv1.JobSpec{
412412
Template: v1.PodTemplateSpec{
413413
ObjectMeta: metav1.ObjectMeta{
@@ -436,9 +436,9 @@ func TestTransformManifestJVM(t *testing.T) {
436436
}}}}},
437437
true,
438438
&v1.ReplicationController{
439-
//ObjectMeta: metav1.ObjectMeta{
439+
// ObjectMeta: metav1.ObjectMeta{
440440
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
441-
//},
441+
// },
442442
Spec: v1.ReplicationControllerSpec{
443443
Replicas: int32p(1),
444444
Template: &v1.PodTemplateSpec{

pkg/skaffold/debug/transform_nodejs_test.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,9 @@ func TestTransformManifestNodeJS(t *testing.T) {
392392
}}}}}},
393393
true,
394394
&appsv1.Deployment{
395-
//ObjectMeta: metav1.ObjectMeta{
395+
// ObjectMeta: metav1.ObjectMeta{
396396
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
397-
//},
397+
// },
398398
Spec: appsv1.DeploymentSpec{
399399
Replicas: int32p(1),
400400
Template: v1.PodTemplateSpec{
@@ -469,9 +469,9 @@ func TestTransformManifestNodeJS(t *testing.T) {
469469
}}}}}},
470470
true,
471471
&appsv1.StatefulSet{
472-
//ObjectMeta: metav1.ObjectMeta{
472+
// ObjectMeta: metav1.ObjectMeta{
473473
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
474-
//},
474+
// },
475475
Spec: appsv1.StatefulSetSpec{
476476
Replicas: int32p(1),
477477
Template: v1.PodTemplateSpec{
@@ -508,9 +508,9 @@ func TestTransformManifestNodeJS(t *testing.T) {
508508
}}}}}},
509509
true,
510510
&appsv1.DaemonSet{
511-
//ObjectMeta: metav1.ObjectMeta{
511+
// ObjectMeta: metav1.ObjectMeta{
512512
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
513-
//},
513+
// },
514514
Spec: appsv1.DaemonSetSpec{
515515
Template: v1.PodTemplateSpec{
516516
ObjectMeta: metav1.ObjectMeta{
@@ -547,9 +547,9 @@ func TestTransformManifestNodeJS(t *testing.T) {
547547
}}}}}},
548548
true,
549549
&batchv1.Job{
550-
//ObjectMeta: metav1.ObjectMeta{
550+
// ObjectMeta: metav1.ObjectMeta{
551551
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
552-
//},
552+
// },
553553
Spec: batchv1.JobSpec{
554554
Template: v1.PodTemplateSpec{
555555
ObjectMeta: metav1.ObjectMeta{
@@ -588,9 +588,9 @@ func TestTransformManifestNodeJS(t *testing.T) {
588588
}}}}},
589589
true,
590590
&v1.ReplicationController{
591-
//ObjectMeta: metav1.ObjectMeta{
591+
// ObjectMeta: metav1.ObjectMeta{
592592
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
593-
//},
593+
// },
594594
Spec: v1.ReplicationControllerSpec{
595595
Replicas: int32p(1),
596596
Template: &v1.PodTemplateSpec{

0 commit comments

Comments
 (0)