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

Add golint support for M1 macs (darwin/arm64 arch) #5435

Merged
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
2 changes: 1 addition & 1 deletion cmd/skaffold/app/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func setFlagsFromEnvVariables(rootCmd *cobra.Command) {
}

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

func setUpLogs(stdErr io.Writer, level string, timestamp bool) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/skaffold/app/cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type Flag struct {
// When adding a new flag to the registry, please specify the
// command/commands to which the flag belongs in `DefinedOn` field.
// If the flag is a global flag, or belongs to all the subcommands,
/// specify "all"
// specify "all"
// FlagAddMethod is method which defines a flag value with specified
// name, default value, and usage string. e.g. `StringVar`, `BoolVar`
var flagRegistry = []Flag{
Expand Down
2 changes: 1 addition & 1 deletion hack/golangci-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set -e -o pipefail

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BIN=${DIR}/bin
VERSION=1.30.0
VERSION=1.37.1

function install_linter() {
echo "Installing GolangCI-Lint"
Expand Down
1 change: 1 addition & 0 deletions hack/install_golint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ is_supported_platform() {
found=1
case "$platform" in
darwin/amd64) found=0 ;;
darwin/arm64) found=0 ;;
darwin/386) found=0 ;;
windows/amd64) found=0 ;;
windows/386) found=0 ;;
Expand Down
4 changes: 2 additions & 2 deletions hack/man/man_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ func TestPrintMan(t *testing.T) {
// Compare to current man page
header, err := ioutil.ReadFile(filepath.Join("..", "..", "docs", "content", "en", "docs", "references", "cli", "index_header"))
testutil.CheckError(t, false, err)
header = bytes.Replace(header, []byte("\r\n"), []byte("\n"), -1)
header = bytes.ReplaceAll(header, []byte("\r\n"), []byte("\n"))

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

if string(expected) != string(header)+output {
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!")
Expand Down
6 changes: 3 additions & 3 deletions hack/schemas/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func generateSchema(root string, dryRun bool, version schema.Version) (bool, err
return false, fmt.Errorf("unable to check that file exists %q: %w", output, err)
}

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

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

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

Expand Down Expand Up @@ -292,7 +292,7 @@ func (g *schemaGenerator) newDefinition(name string, t ast.Expr, comment string,
}
}

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

// Extract default value
if m := regexpDefaults.FindStringSubmatch(description); m != nil {
Expand Down
2 changes: 1 addition & 1 deletion hack/schemas/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestGenerators(t *testing.T) {
expected, err := ioutil.ReadFile(expectedOutput)
t.CheckNoError(err)

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

schemaLoader := gojsonschema.NewBytesLoader(actual)
_, err = gojsonschema.NewSchema(schemaLoader)
Expand Down
2 changes: 1 addition & 1 deletion hack/struct-json/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func newDefinition(name string, t ast.Expr, comment string) *Definition {
}
}

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

Expand Down
2 changes: 1 addition & 1 deletion integration/build_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestBuildKanikoWithExplicitRepo(t *testing.T) {
skaffold.Build().WithRepo("").InDir("testdata/kaniko-explicit-repo").RunOrFail(t)
}

//see integration/testdata/README.md for details
// see integration/testdata/README.md for details
func TestBuildInCluster(t *testing.T) {
MarkIntegrationTest(t, NeedsGcp)

Expand Down
2 changes: 1 addition & 1 deletion integration/dev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func replaceInFile(target, replacement, filepath string) ([]byte, os.FileMode, e
return nil, 0, err
}

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

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

Expand Down
2 changes: 1 addition & 1 deletion integration/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func TestEventLogHTTP(t *testing.T) {
endpoint string
}{
{
//TODO deprecate (https://github.com/GoogleContainerTools/skaffold/issues/3168)
// TODO deprecate (https://github.com/GoogleContainerTools/skaffold/issues/3168)
description: "/v1/event_log",
endpoint: "/v1/event_log",
},
Expand Down
2 changes: 0 additions & 2 deletions integration/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ func (k *NSKubernetesClient) waitForPods(podReady func(*v1.Pod) bool, podNames .
select {
case <-ctx.Done():
k.printDiskFreeSpace()
//k.debug("nodes")
k.debug("pods")
k.logs("pod", podNames)
k.t.Fatalf("Timed out waiting for pods %v in namespace %q", podNames, k.ns)
Expand Down Expand Up @@ -312,7 +311,6 @@ func (k *NSKubernetesClient) waitForDeploymentsToStabilizeWithTimeout(timeout ti
select {
case <-ctx.Done():
k.printDiskFreeSpace()
//k.debug("nodes")
k.debug("deployments.apps")
k.debug("pods")
k.logs("deployment.app", depNames)
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/build/jib/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func validate(path string, enableGradleAnalysis bool) []ArtifactConfig {
var results []ArtifactConfig
for _, match := range matches {
// Escape windows path separators
line := bytes.Replace(match[1], []byte(`\`), []byte(`\\`), -1)
line := bytes.ReplaceAll(match[1], []byte(`\`), []byte(`\\`))
parsedJSON := jibJSON{}
if err := json.Unmarshal(line, &parsedJSON); err != nil {
logrus.Warnf("failed to parse jib json: %s", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/build/jib/jib.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func refreshDependencyList(files *filesLists, cmd exec.Cmd) error {
return errors.New("failed to get Jib dependencies")
}

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

Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/build/jib/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,5 +300,5 @@ func getFileTime(file string, t *testing.T) time.Time {

// for paths that contain "\", they must be escaped in json strings
func escapeBackslashes(path string) string {
return strings.Replace(path, `\`, `\\`, -1)
return strings.ReplaceAll(path, `\`, `\\`)
}
2 changes: 1 addition & 1 deletion pkg/skaffold/build/kaniko/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const (
VerbosityFlag = "--verbosity"
// WhitelistVarRunFlag additional flag
WhitelistVarRunFlag = "--whitelist-var-run"
//DefaultImage is image used by the Kaniko pod by default
// DefaultImage is image used by the Kaniko pod by default
DefaultImage = "gcr.io/kaniko-project/executor:latest"
// DefaultSecretName for kaniko pod
DefaultSecretName = "kaniko-secret"
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/build/tag/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func GenerateFullyQualifiedImageName(t Tagger, workingDir, imageName string) (st
if strings.Contains(tag, DeprecatedImageName) {
warnings.Printf("{{.IMAGE_NAME}} is deprecated, envTemplate's template should only specify the tag value. See https://skaffold.dev/docs/pipeline-stages/taggers/")

return strings.Replace(tag, DeprecatedImageName, imageName, -1), nil
return strings.ReplaceAll(tag, DeprecatedImageName, imageName), nil
}

return fmt.Sprintf("%s:%s", imageName, tag), nil
Expand Down
26 changes: 13 additions & 13 deletions pkg/skaffold/debug/transform_go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ func TestTransformManifestDelve(t *testing.T) {
}}}},
true,
&appsv1.Deployment{
//ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
//},
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
// },
Spec: appsv1.DeploymentSpec{
Replicas: int32p(1),
Template: v1.PodTemplateSpec{
Expand Down Expand Up @@ -336,9 +336,9 @@ func TestTransformManifestDelve(t *testing.T) {
}}}},
true,
&appsv1.ReplicaSet{
//ObjectMeta: metav1.ObjectMeta{
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
//},
// },
Spec: appsv1.ReplicaSetSpec{
Replicas: int32p(1),
Template: v1.PodTemplateSpec{
Expand Down Expand Up @@ -379,9 +379,9 @@ func TestTransformManifestDelve(t *testing.T) {
}}}},
true,
&appsv1.StatefulSet{
//ObjectMeta: metav1.ObjectMeta{
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
//},
// },
Spec: appsv1.StatefulSetSpec{
Replicas: int32p(1),
Template: v1.PodTemplateSpec{
Expand Down Expand Up @@ -421,9 +421,9 @@ func TestTransformManifestDelve(t *testing.T) {
}}}},
true,
&appsv1.DaemonSet{
//ObjectMeta: metav1.ObjectMeta{
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
//},
// },
Spec: appsv1.DaemonSetSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -462,9 +462,9 @@ func TestTransformManifestDelve(t *testing.T) {
}}}},
true,
&batchv1.Job{
//ObjectMeta: metav1.ObjectMeta{
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
//},
// },
Spec: batchv1.JobSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -504,9 +504,9 @@ func TestTransformManifestDelve(t *testing.T) {
}}}},
true,
&v1.ReplicationController{
//ObjectMeta: metav1.ObjectMeta{
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
//},
// },
Spec: v1.ReplicationControllerSpec{
Replicas: int32p(1),
Template: &v1.PodTemplateSpec{
Expand Down
24 changes: 12 additions & 12 deletions pkg/skaffold/debug/transform_jvm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ func TestTransformManifestJVM(t *testing.T) {
}}}}},
true,
&appsv1.Deployment{
//ObjectMeta: metav1.ObjectMeta{
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
//},
// },
Spec: appsv1.DeploymentSpec{
Replicas: int32p(1),
Template: v1.PodTemplateSpec{
Expand Down Expand Up @@ -312,9 +312,9 @@ func TestTransformManifestJVM(t *testing.T) {
}}}}},
true,
&appsv1.ReplicaSet{
//ObjectMeta: metav1.ObjectMeta{
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
//},
// },
Spec: appsv1.ReplicaSetSpec{
Replicas: int32p(1),
Template: v1.PodTemplateSpec{
Expand Down Expand Up @@ -344,9 +344,9 @@ func TestTransformManifestJVM(t *testing.T) {
}}}}},
true,
&appsv1.StatefulSet{
//ObjectMeta: metav1.ObjectMeta{
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
//},
// },
Spec: appsv1.StatefulSetSpec{
Replicas: int32p(1),
Template: v1.PodTemplateSpec{
Expand Down Expand Up @@ -375,9 +375,9 @@ func TestTransformManifestJVM(t *testing.T) {
}}}}},
true,
&appsv1.DaemonSet{
//ObjectMeta: metav1.ObjectMeta{
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
//},
// },
Spec: appsv1.DaemonSetSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -405,9 +405,9 @@ func TestTransformManifestJVM(t *testing.T) {
}}}}},
true,
&batchv1.Job{
//ObjectMeta: metav1.ObjectMeta{
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
//},
// },
Spec: batchv1.JobSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -436,9 +436,9 @@ func TestTransformManifestJVM(t *testing.T) {
}}}}},
true,
&v1.ReplicationController{
//ObjectMeta: metav1.ObjectMeta{
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
//},
// },
Spec: v1.ReplicationControllerSpec{
Replicas: int32p(1),
Template: &v1.PodTemplateSpec{
Expand Down
20 changes: 10 additions & 10 deletions pkg/skaffold/debug/transform_nodejs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,9 @@ func TestTransformManifestNodeJS(t *testing.T) {
}}}}}},
true,
&appsv1.Deployment{
//ObjectMeta: metav1.ObjectMeta{
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
//},
// },
Spec: appsv1.DeploymentSpec{
Replicas: int32p(1),
Template: v1.PodTemplateSpec{
Expand Down Expand Up @@ -469,9 +469,9 @@ func TestTransformManifestNodeJS(t *testing.T) {
}}}}}},
true,
&appsv1.StatefulSet{
//ObjectMeta: metav1.ObjectMeta{
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
//},
// },
Spec: appsv1.StatefulSetSpec{
Replicas: int32p(1),
Template: v1.PodTemplateSpec{
Expand Down Expand Up @@ -508,9 +508,9 @@ func TestTransformManifestNodeJS(t *testing.T) {
}}}}}},
true,
&appsv1.DaemonSet{
//ObjectMeta: metav1.ObjectMeta{
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
//},
// },
Spec: appsv1.DaemonSetSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -547,9 +547,9 @@ func TestTransformManifestNodeJS(t *testing.T) {
}}}}}},
true,
&batchv1.Job{
//ObjectMeta: metav1.ObjectMeta{
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
//},
// },
Spec: batchv1.JobSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -588,9 +588,9 @@ func TestTransformManifestNodeJS(t *testing.T) {
}}}}},
true,
&v1.ReplicationController{
//ObjectMeta: metav1.ObjectMeta{
// ObjectMeta: metav1.ObjectMeta{
// Labels: map[string]string{"debug.cloud.google.com/enabled": `yes`},
//},
// },
Spec: v1.ReplicationControllerSpec{
Replicas: int32p(1),
Template: &v1.PodTemplateSpec{
Expand Down
Loading