Skip to content

Commit c9eb9e1

Browse files
committed
fix ST1003 go naming style errors
1 parent b9f777d commit c9eb9e1

File tree

5 files changed

+47
-47
lines changed

5 files changed

+47
-47
lines changed

experiment/gerrit-onboarder/onboarder.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ func ensureUUID(groupsFile, uuid, group string) (string, error) {
150150
return "", fmt.Errorf("UUID, %s, already in use for group %s", uuid, value)
151151
}
152152
// Group name already in use with different UUID
153-
for cur_id, groupName := range groupsMap {
153+
for curID, groupName := range groupsMap {
154154
if groupName == group {
155-
return "", fmt.Errorf("%s already used as group name for %s", group, cur_id)
155+
return "", fmt.Errorf("%s already used as group name for %s", group, curID)
156156
}
157157
}
158158

@@ -282,12 +282,12 @@ func labelAccessExistsFunc(groupName string) func(map[string][]string) bool {
282282
}
283283
}
284284

285-
func verifyInTree(workDir, host, cur_branch string, configMap map[string][]string, verify func(map[string][]string) bool) (bool, error) {
285+
func verifyInTree(workDir, host, curBranch string, configMap map[string][]string, verify func(map[string][]string) bool) (bool, error) {
286286
if verify(configMap) {
287287
return true, nil
288288
} else if inheritance := getInheritedRepo(configMap); inheritance != "" {
289-
parent_branch := cur_branch + "_parent"
290-
if err := fetchMetaConfig(host, inheritance, parent_branch, workDir); err != nil {
289+
parentBranch := curBranch + "_parent"
290+
if err := fetchMetaConfig(host, inheritance, parentBranch, workDir); err != nil {
291291
// This likely won't happen, but if the fail is due to switching branches, we want to fail
292292
if strings.Contains(err.Error(), "failed to switch") {
293293
return false, fmt.Errorf("unable to fetch refs/meta/config for %s: %w", inheritance, err)
@@ -300,28 +300,28 @@ func verifyInTree(workDir, host, cur_branch string, configMap map[string][]strin
300300
return false, fmt.Errorf("failed to read project.config file: %w", err)
301301
}
302302
newConfig, _ := configToMap(string(data))
303-
ret, err := verifyInTree(workDir, host, parent_branch, newConfig, verify)
303+
ret, err := verifyInTree(workDir, host, parentBranch, newConfig, verify)
304304
if err != nil {
305305
return false, fmt.Errorf("failed to check if lines in config for %s/%s: %w", host, inheritance, err)
306306
}
307-
if err := execInDir(os.Stdout, os.Stderr, workDir, "git", "checkout", cur_branch); err != nil {
308-
return false, fmt.Errorf("failed to checkout %s, %w", cur_branch, err)
307+
if err := execInDir(os.Stdout, os.Stderr, workDir, "git", "checkout", curBranch); err != nil {
308+
return false, fmt.Errorf("failed to checkout %s, %w", curBranch, err)
309309
}
310-
if err := execInDir(os.Stdout, os.Stderr, workDir, "git", "branch", "-D", parent_branch); err != nil {
311-
return false, fmt.Errorf("failed to delete %s branch, %w", parent_branch, err)
310+
if err := execInDir(os.Stdout, os.Stderr, workDir, "git", "branch", "-D", parentBranch); err != nil {
311+
return false, fmt.Errorf("failed to delete %s branch, %w", parentBranch, err)
312312
}
313313
return ret, nil
314314
}
315315
return false, nil
316316
}
317317

318-
func ensureProjectConfig(workDir, config, host, cur_branch, groupName string) (string, error) {
318+
func ensureProjectConfig(workDir, config, host, curBranch, groupName string) (string, error) {
319319
configMap, orderedKeys := configToMap(config)
320320

321321
// Check that prow automation robot has access to refs/*
322322
accessLines := []string{}
323323
readAccessLine := fmt.Sprintf(prowReadAccessFormat, groupName)
324-
prowReadAccess, err := verifyInTree(workDir, host, cur_branch, configMap, lineInMatchingHeaderFunc(accessRefsRegex, readAccessLine))
324+
prowReadAccess, err := verifyInTree(workDir, host, curBranch, configMap, lineInMatchingHeaderFunc(accessRefsRegex, readAccessLine))
325325
if err != nil {
326326
return "", fmt.Errorf("failed to check if needed lines in config: %w", err)
327327
}
@@ -331,7 +331,7 @@ func ensureProjectConfig(workDir, config, host, cur_branch, groupName string) (s
331331

332332
// Check that the line "label-verified" = ... group GROUPNAME exists under ANY header
333333
labelAccessLine := fmt.Sprintf(prowLabelAccessFormat, groupName)
334-
prowLabelAccess, err := verifyInTree(workDir, host, cur_branch, configMap, labelAccessExistsFunc(groupName))
334+
prowLabelAccess, err := verifyInTree(workDir, host, curBranch, configMap, labelAccessExistsFunc(groupName))
335335
if err != nil {
336336
return "", fmt.Errorf("failed to check if needed lines in config: %w", err)
337337
}
@@ -341,7 +341,7 @@ func ensureProjectConfig(workDir, config, host, cur_branch, groupName string) (s
341341
configMap, orderedKeys = addSection(accessHeader, configMap, orderedKeys, accessLines)
342342

343343
// We need to be less exact with the Label-Verified header so we are just checking if it exists anywhere:
344-
labelExists, err := verifyInTree(workDir, host, cur_branch, configMap, labelExists)
344+
labelExists, err := verifyInTree(workDir, host, curBranch, configMap, labelExists)
345345
if err != nil {
346346
return "", fmt.Errorf("failed to check if needed lines in config: %w", err)
347347
}
@@ -352,13 +352,13 @@ func ensureProjectConfig(workDir, config, host, cur_branch, groupName string) (s
352352

353353
}
354354

355-
func updatePojectConfig(workDir, host, cur_branch, groupName string) error {
355+
func updatePojectConfig(workDir, host, curBranch, groupName string) error {
356356
data, err := os.ReadFile(path.Join(workDir, projectConfigFile))
357357
if err != nil {
358358
return fmt.Errorf("failed to read project.config file: %w", err)
359359
}
360360

361-
newData, err := ensureProjectConfig(workDir, string(data), host, cur_branch, groupName)
361+
newData, err := ensureProjectConfig(workDir, string(data), host, curBranch, groupName)
362362
if err != nil {
363363
return fmt.Errorf("failed to ensure updated project config: %w", err)
364364
}

gopherage/cmd/metadata/metadata.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131

3232
const (
3333
// From https://github.com/kubernetes/test-infra/blob/master/prow/jobs.md#job-environment-variables
34-
repo_owner = "REPO_OWNER"
34+
repoOwner = "REPO_OWNER"
3535
)
3636

3737
type Flags struct {
@@ -106,7 +106,7 @@ func MakeCommand() *cobra.Command {
106106
Source: Flags.source,
107107
ReplaceRoot: Flags.replace,
108108
}
109-
WriteJson(Flags, metadata)
109+
WriteJSON(Flags, metadata)
110110
},
111111
}
112112
absCmd.Flags().StringVarP(&Flags.outputFile, "output", "o", "-", "output file")
@@ -136,7 +136,7 @@ func MakeCommand() *cobra.Command {
136136
ChangeNum: Flags.changeNum,
137137
PatchSet: Flags.patchSet,
138138
}
139-
WriteJson(Flags, metadata)
139+
WriteJSON(Flags, metadata)
140140
},
141141
}
142142
incCmd.Flags().StringVarP(&Flags.outputFile, "output", "o", "-", "output file")
@@ -166,10 +166,10 @@ func gitCommand(args ...string) (string, error) {
166166

167167
func ValidateBase(Flags *Flags, cmd *cobra.Command, env envFetcher) error {
168168
if Flags.project == "" {
169-
project := env(repo_owner)
169+
project := env(repoOwner)
170170
if project == "" {
171171
cmd.Usage()
172-
return fmt.Errorf("Failed to collect project from ENV: (%s) not found", repo_owner)
172+
return fmt.Errorf("Failed to collect project from ENV: (%s) not found", repoOwner)
173173
}
174174
Flags.project = project
175175
}
@@ -209,7 +209,7 @@ func ValidateAbs(Flags *Flags, r gitRunner) error {
209209
return nil
210210
}
211211

212-
func WriteJson(Flags *Flags, m Metadata) error {
212+
func WriteJSON(Flags *Flags, m Metadata) error {
213213
var file io.WriteCloser
214214

215215
j, err := json.Marshal(m)

kubetest/aksengine.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,8 +1173,8 @@ func (c *aksEngineDeployer) DumpClusterLogs(localPath, gcsPath string) error {
11731173
}
11741174

11751175
logDumperWindows := func() error {
1176-
const winLogDumpScriptUrl string = "https://raw.githubusercontent.com/kubernetes-sigs/windows-testing/master/scripts/win-ci-logs-collector.sh"
1177-
winLogDumpScript, err := downloadFromURL(winLogDumpScriptUrl, path.Join(c.outputDir, "win-ci-logs-collector.sh"), 2)
1176+
const winLogDumpScriptURL string = "https://raw.githubusercontent.com/kubernetes-sigs/windows-testing/master/scripts/win-ci-logs-collector.sh"
1177+
winLogDumpScript, err := downloadFromURL(winLogDumpScriptURL, path.Join(c.outputDir, "win-ci-logs-collector.sh"), 2)
11781178

11791179
masterFQDN := fmt.Sprintf("%s.%s.cloudapp.azure.com", c.dnsPrefix, c.location)
11801180
if err != nil {
@@ -1245,9 +1245,9 @@ func (c *aksEngineDeployer) TestSetup() error {
12451245
}
12461246

12471247
// Download repo-list that defines repositories for Windows test images.
1248-
downloadUrl, ok := os.LookupEnv("KUBE_TEST_REPO_LIST_DOWNLOAD_LOCATION")
1248+
downloadURL, ok := os.LookupEnv("KUBE_TEST_REPO_LIST_DOWNLOAD_LOCATION")
12491249
if !ok {
1250-
// Env value for downloadUrl is not set, nothing to do
1250+
// Env value for downloadURL is not set, nothing to do
12511251
log.Printf("KUBE_TEST_REPO_LIST_DOWNLOAD_LOCATION not set. Using default test image repos.")
12521252
return nil
12531253
}
@@ -1259,11 +1259,11 @@ func (c *aksEngineDeployer) TestSetup() error {
12591259
}
12601260
defer f.Close()
12611261

1262-
log.Printf("downloading %v from %v.", downloadPath, downloadUrl)
1263-
err = httpRead(downloadUrl, f)
1262+
log.Printf("downloading %v from %v.", downloadPath, downloadURL)
1263+
err = httpRead(downloadURL, f)
12641264

12651265
if err != nil {
1266-
return fmt.Errorf("url=%s failed get %v: %v.", downloadUrl, downloadPath, err)
1266+
return fmt.Errorf("url=%s failed get %v: %v.", downloadURL, downloadPath, err)
12671267
}
12681268
f.Chmod(0744)
12691269
if err := os.Setenv("KUBE_TEST_REPO_LIST", downloadPath); err != nil {

kubetest/gke_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import (
2424
"testing"
2525
)
2626

27-
func newGkeDeployerFactory(instance_group_prefix string) (*gkeDeployer, error) {
27+
func newGkeDeployerFactory(instanceGroupPrefix string) (*gkeDeployer, error) {
2828
flag.Set("gke-environment", "staging")
29-
if instance_group_prefix != "" {
30-
flag.Set("gke-instance-group-prefix", instance_group_prefix)
29+
if instanceGroupPrefix != "" {
30+
flag.Set("gke-instance-group-prefix", instanceGroupPrefix)
3131
} else {
3232
flag.Set("gke-instance-group-prefix", "gke")
3333
}
@@ -63,15 +63,15 @@ func TestParseInstanceGroupsFromGcloud(t *testing.T) {
6363
cases := []struct {
6464
name string
6565
input string
66-
instance_group_prefix string
66+
instanceGroupPrefix string
6767
expected []*ig
6868
expectedError bool
6969
}{
7070
// Zonal
7171
{
7272
name: "One instance group with default prefix",
7373
input: urlZoneADefault,
74-
instance_group_prefix: "",
74+
instanceGroupPrefix: "",
7575
expected: []*ig{
7676
{
7777
path: `zones/us-central1-a/instanceGroupManagers/gke-default-pool-6f8ec327-grp`,
@@ -83,16 +83,16 @@ func TestParseInstanceGroupsFromGcloud(t *testing.T) {
8383
expectedError: false,
8484
},
8585
{
86-
name: "One instance group with default prefix, but not matching instance_group_prefix",
86+
name: "One instance group with default prefix, but not matching instanceGroupPrefix",
8787
input: urlZoneADefault,
88-
instance_group_prefix: "test",
88+
instanceGroupPrefix: "test",
8989
expected: nil,
9090
expectedError: true,
9191
},
9292
{
9393
name: "One instance group with test prefix",
9494
input: urlZoneATest,
95-
instance_group_prefix: "test",
95+
instanceGroupPrefix: "test",
9696
expected: []*ig{
9797
{
9898
path: `zones/us-central1-a/instanceGroupManagers/test-default-pool-6f8ec327-grp`,
@@ -107,7 +107,7 @@ func TestParseInstanceGroupsFromGcloud(t *testing.T) {
107107
{
108108
name: "Three instance groups with default prefix",
109109
input: strings.Join([]string{urlZoneADefault, urlZoneBDefault, urlZoneCDefault}, ";"),
110-
instance_group_prefix: "",
110+
instanceGroupPrefix: "",
111111
expected: []*ig{
112112
{
113113
path: `zones/us-central1-a/instanceGroupManagers/gke-default-pool-6f8ec327-grp`,
@@ -131,16 +131,16 @@ func TestParseInstanceGroupsFromGcloud(t *testing.T) {
131131
expectedError: false,
132132
},
133133
{
134-
name: "Three instance groups with default prefix, but not matching instance_group_prefix",
134+
name: "Three instance groups with default prefix, but not matching instanceGroupPrefix",
135135
input: strings.Join([]string{urlZoneADefault, urlZoneBDefault, urlZoneCDefault}, ";"),
136-
instance_group_prefix: "test",
136+
instanceGroupPrefix: "test",
137137
expected: nil,
138138
expectedError: true,
139139
},
140140
{
141141
name: "Three instance groups with test prefix",
142142
input: strings.Join([]string{urlZoneATest, urlZoneBTest, urlZoneCTest}, ";"),
143-
instance_group_prefix: "test",
143+
instanceGroupPrefix: "test",
144144
expected: []*ig{
145145
{
146146
path: `zones/us-central1-a/instanceGroupManagers/test-default-pool-6f8ec327-grp`,
@@ -167,7 +167,7 @@ func TestParseInstanceGroupsFromGcloud(t *testing.T) {
167167

168168
for _, tc := range cases {
169169
t.Run(tc.name, func(t *testing.T) {
170-
deployer, err := newGkeDeployerFactory(tc.instance_group_prefix)
170+
deployer, err := newGkeDeployerFactory(tc.instanceGroupPrefix)
171171
if err != nil {
172172
t.Errorf("Error creating gke deployer: %v", err)
173173
}

kubetest/kops.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -873,15 +873,15 @@ func parseKubeconfig(kubeconfigPath string) (*kubeconfig, error) {
873873
}
874874

875875
// setupGCEStateStore is used to create a 1-off state bucket in the active GCP project
876-
func setupGCEStateStore(projectId string) (*string, error) {
876+
func setupGCEStateStore(projectID string) (*string, error) {
877877
ctx := context.Background()
878878
client, err := storage.NewClient(ctx)
879879
if err != nil {
880880
return nil, fmt.Errorf("error building storage API client: %w", err)
881881
}
882-
name := gceBucketName(projectId)
882+
name := gceBucketName(projectID)
883883
bkt := client.Bucket(name)
884-
if err := bkt.Create(ctx, projectId, nil); err != nil {
884+
if err := bkt.Create(ctx, projectID, nil); err != nil {
885885
return nil, err
886886
}
887887
log.Printf("Created new GCS bucket for state store: %s\n.", name)
@@ -890,9 +890,9 @@ func setupGCEStateStore(projectId string) (*string, error) {
890890
}
891891

892892
// gceBucketName generates a name for GCE state store bucket
893-
func gceBucketName(projectId string) string {
893+
func gceBucketName(projectID string) string {
894894
b := make([]byte, 2)
895895
cryptorand.Read(b)
896896
s := hex.EncodeToString(b)
897-
return strings.Join([]string{projectId, "state", s}, "-")
897+
return strings.Join([]string{projectID, "state", s}, "-")
898898
}

0 commit comments

Comments
 (0)