Skip to content

Commit

Permalink
chore: simplify go code using gofmt
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Dupeyron <[email protected]>
  • Loading branch information
Calchan committed Jul 5, 2023
1 parent 7dae6c9 commit a0c02eb
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 52 deletions.
10 changes: 5 additions & 5 deletions applicationset/generators/pull_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestPullRequestGithubGenerateParams(t *testing.T) {
return pullrequest.NewFakeService(
ctx,
[]*pullrequest.PullRequest{
&pullrequest.PullRequest{
{
Number: 1,
Branch: "branch1",
TargetBranch: "master",
Expand Down Expand Up @@ -56,7 +56,7 @@ func TestPullRequestGithubGenerateParams(t *testing.T) {
return pullrequest.NewFakeService(
ctx,
[]*pullrequest.PullRequest{
&pullrequest.PullRequest{
{
Number: 2,
Branch: "feat/areally+long_pull_request_name_to_test_argo_slugification_and_branch_name_shortening_feature",
TargetBranch: "feat/anotherreally+long_pull_request_name_to_test_argo_slugification_and_branch_name_shortening_feature",
Expand Down Expand Up @@ -85,7 +85,7 @@ func TestPullRequestGithubGenerateParams(t *testing.T) {
return pullrequest.NewFakeService(
ctx,
[]*pullrequest.PullRequest{
&pullrequest.PullRequest{
{
Number: 1,
Branch: "a-very-short-sha",
TargetBranch: "master",
Expand Down Expand Up @@ -125,7 +125,7 @@ func TestPullRequestGithubGenerateParams(t *testing.T) {
return pullrequest.NewFakeService(
ctx,
[]*pullrequest.PullRequest{
&pullrequest.PullRequest{
{
Number: 1,
Branch: "branch1",
TargetBranch: "master",
Expand Down Expand Up @@ -162,7 +162,7 @@ func TestPullRequestGithubGenerateParams(t *testing.T) {
return pullrequest.NewFakeService(
ctx,
[]*pullrequest.PullRequest{
&pullrequest.PullRequest{
{
Number: 1,
Branch: "branch1",
TargetBranch: "master",
Expand Down
6 changes: 3 additions & 3 deletions applicationset/services/pull_request/gitea_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ func TestGetGiteaPRLabelNames(t *testing.T) {
{
Name: "PR has labels",
PullLabels: []*gitea.Label{
&gitea.Label{Name: "label1"},
&gitea.Label{Name: "label2"},
&gitea.Label{Name: "label3"},
{Name: "label1"},
{Name: "label2"},
{Name: "label3"},
},
ExpectedResult: []string{"label1", "label2", "label3"},
},
Expand Down
24 changes: 12 additions & 12 deletions applicationset/services/pull_request/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,29 @@ func TestContainLabels(t *testing.T) {
Name: "Match labels",
Labels: []string{"label1", "label2"},
PullLabels: []*github.Label{
&github.Label{Name: toPtr("label1")},
&github.Label{Name: toPtr("label2")},
&github.Label{Name: toPtr("label3")},
{Name: toPtr("label1")},
{Name: toPtr("label2")},
{Name: toPtr("label3")},
},
Expect: true,
},
{
Name: "Not match labels",
Labels: []string{"label1", "label4"},
PullLabels: []*github.Label{
&github.Label{Name: toPtr("label1")},
&github.Label{Name: toPtr("label2")},
&github.Label{Name: toPtr("label3")},
{Name: toPtr("label1")},
{Name: toPtr("label2")},
{Name: toPtr("label3")},
},
Expect: false,
},
{
Name: "No specify",
Labels: []string{},
PullLabels: []*github.Label{
&github.Label{Name: toPtr("label1")},
&github.Label{Name: toPtr("label2")},
&github.Label{Name: toPtr("label3")},
{Name: toPtr("label1")},
{Name: toPtr("label2")},
{Name: toPtr("label3")},
},
Expect: true,
},
Expand All @@ -68,9 +68,9 @@ func TestGetGitHubPRLabelNames(t *testing.T) {
{
Name: "PR has labels",
PullLabels: []*github.Label{
&github.Label{Name: toPtr("label1")},
&github.Label{Name: toPtr("label2")},
&github.Label{Name: toPtr("label3")},
{Name: toPtr("label1")},
{Name: toPtr("label2")},
{Name: toPtr("label3")},
},
ExpectedResult: []string{"label1", "label2", "label3"},
},
Expand Down
4 changes: 2 additions & 2 deletions cmd/argocd/commands/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ func Test_groupObjsByKey(t *testing.T) {
}

expected := map[kube.ResourceKey]*unstructured.Unstructured{
kube.ResourceKey{Group: "", Kind: "Pod", Namespace: "default", Name: "pod-name"}: localObjs[0],
kube.ResourceKey{Group: "apiextensions.k8s.io", Kind: "CustomResourceDefinition", Namespace: "", Name: "certificates.cert-manager.io"}: localObjs[1],
{Group: "", Kind: "Pod", Namespace: "default", Name: "pod-name"}: localObjs[0],
{Group: "apiextensions.k8s.io", Kind: "CustomResourceDefinition", Namespace: "", Name: "certificates.cert-manager.io"}: localObjs[1],
}

objByKey := groupObjsByKey(localObjs, liveObjs, "default")
Expand Down
18 changes: 9 additions & 9 deletions cmd/argocd/commands/applicationset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ func TestPrintApplicationSetTable(t *testing.T) {
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
v1alpha1.ApplicationSetGenerator{
{
Git: &v1alpha1.GitGenerator{
RepoURL: "https://github.com/argoproj/argo-cd.git",
Revision: "head",
Directories: []v1alpha1.GitDirectoryGeneratorItem{
v1alpha1.GitDirectoryGeneratorItem{
{
Path: "applicationset/examples/git-generator-directory/cluster-addons/*",
},
},
Expand All @@ -60,7 +60,7 @@ func TestPrintApplicationSetTable(t *testing.T) {
},
Status: v1alpha1.ApplicationSetStatus{
Conditions: []v1alpha1.ApplicationSetCondition{
v1alpha1.ApplicationSetCondition{
{
Status: v1alpha1.ApplicationSetConditionStatusTrue,
Type: v1alpha1.ApplicationSetConditionResourcesUpToDate,
},
Expand All @@ -75,12 +75,12 @@ func TestPrintApplicationSetTable(t *testing.T) {
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
v1alpha1.ApplicationSetGenerator{
{
Git: &v1alpha1.GitGenerator{
RepoURL: "https://github.com/argoproj/argo-cd.git",
Revision: "head",
Directories: []v1alpha1.GitDirectoryGeneratorItem{
v1alpha1.GitDirectoryGeneratorItem{
{
Path: "applicationset/examples/git-generator-directory/cluster-addons/*",
},
},
Expand All @@ -95,7 +95,7 @@ func TestPrintApplicationSetTable(t *testing.T) {
},
Status: v1alpha1.ApplicationSetStatus{
Conditions: []v1alpha1.ApplicationSetCondition{
v1alpha1.ApplicationSetCondition{
{
Status: v1alpha1.ApplicationSetConditionStatusTrue,
Type: v1alpha1.ApplicationSetConditionResourcesUpToDate,
},
Expand All @@ -118,12 +118,12 @@ func TestPrintAppSetSummaryTable(t *testing.T) {
},
Spec: v1alpha1.ApplicationSetSpec{
Generators: []v1alpha1.ApplicationSetGenerator{
v1alpha1.ApplicationSetGenerator{
{
Git: &v1alpha1.GitGenerator{
RepoURL: "https://github.com/argoproj/argo-cd.git",
Revision: "head",
Directories: []v1alpha1.GitDirectoryGeneratorItem{
v1alpha1.GitDirectoryGeneratorItem{
{
Path: "applicationset/examples/git-generator-directory/cluster-addons/*",
},
},
Expand All @@ -138,7 +138,7 @@ func TestPrintAppSetSummaryTable(t *testing.T) {
},
Status: v1alpha1.ApplicationSetStatus{
Conditions: []v1alpha1.ApplicationSetCondition{
v1alpha1.ApplicationSetCondition{
{
Status: v1alpha1.ApplicationSetConditionStatusTrue,
Type: v1alpha1.ApplicationSetConditionResourcesUpToDate,
},
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/notification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestNotificationsListServices(t *testing.T) {
SetParamInNotificationConfigMap("service.webhook.test", "url: https://test.com").
Then().Services(func(services *notification.ServiceList, err error) {
assert.Nil(t, err)
assert.Equal(t, []*notification.Service{&notification.Service{Name: pointer.String("test")}}, services.Items)
assert.Equal(t, []*notification.Service{{Name: pointer.String("test")}}, services.Items)
})
}

Expand All @@ -25,7 +25,7 @@ func TestNotificationsListTemplates(t *testing.T) {
SetParamInNotificationConfigMap("template.app-created", "email:\n subject: Application {{.app.metadata.name}} has been created.\nmessage: Application {{.app.metadata.name}} has been created.\nteams:\n title: Application {{.app.metadata.name}} has been created.\n").
Then().Templates(func(templates *notification.TemplateList, err error) {
assert.Nil(t, err)
assert.Equal(t, []*notification.Template{&notification.Template{Name: pointer.String("app-created")}}, templates.Items)
assert.Equal(t, []*notification.Template{{Name: pointer.String("app-created")}}, templates.Items)
})
}

Expand All @@ -35,6 +35,6 @@ func TestNotificationsListTriggers(t *testing.T) {
SetParamInNotificationConfigMap("trigger.on-created", "- description: Application is created.\n oncePer: app.metadata.name\n send:\n - app-created\n when: \"true\"\n").
Then().Triggers(func(triggers *notification.TriggerList, err error) {
assert.Nil(t, err)
assert.Equal(t, []*notification.Trigger{&notification.Trigger{Name: pointer.String("on-created")}}, triggers.Items)
assert.Equal(t, []*notification.Trigger{{Name: pointer.String("on-created")}}, triggers.Items)
})
}
8 changes: 4 additions & 4 deletions util/db/helmrepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ func (db *db) getHelmRepo(repoURL string, helmRepositories []settings.HelmRepoCr
Name: repoInfo.Name,
}
err := db.unmarshalFromSecretsStr(map[*SecretMaperValidation]*v1.SecretKeySelector{
&SecretMaperValidation{Dest: &repo.Username, Transform: StripCRLFCharacter}: repoInfo.UsernameSecret,
&SecretMaperValidation{Dest: &repo.Password, Transform: StripCRLFCharacter}: repoInfo.PasswordSecret,
&SecretMaperValidation{Dest: &repo.TLSClientCertData, Transform: StripCRLFCharacter}: repoInfo.CertSecret,
&SecretMaperValidation{Dest: &repo.TLSClientCertKey, Transform: StripCRLFCharacter}: repoInfo.KeySecret,
{Dest: &repo.Username, Transform: StripCRLFCharacter}: repoInfo.UsernameSecret,
{Dest: &repo.Password, Transform: StripCRLFCharacter}: repoInfo.PasswordSecret,
{Dest: &repo.TLSClientCertData, Transform: StripCRLFCharacter}: repoInfo.CertSecret,
{Dest: &repo.TLSClientCertKey, Transform: StripCRLFCharacter}: repoInfo.KeySecret,
}, make(map[string]*v1.Secret))
return repo, err
}
Expand Down
28 changes: 14 additions & 14 deletions util/db/repository_legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,13 @@ func (l *legacyRepositoryBackend) credentialsToRepository(repoInfo settings.Repo
Proxy: repoInfo.Proxy,
}
err := l.db.unmarshalFromSecretsStr(map[*SecretMaperValidation]*apiv1.SecretKeySelector{
&SecretMaperValidation{Dest: &repo.Username, Transform: StripCRLFCharacter}: repoInfo.UsernameSecret,
&SecretMaperValidation{Dest: &repo.Password, Transform: StripCRLFCharacter}: repoInfo.PasswordSecret,
&SecretMaperValidation{Dest: &repo.SSHPrivateKey, Transform: StripCRLFCharacter}: repoInfo.SSHPrivateKeySecret,
&SecretMaperValidation{Dest: &repo.TLSClientCertData, Transform: StripCRLFCharacter}: repoInfo.TLSClientCertDataSecret,
&SecretMaperValidation{Dest: &repo.TLSClientCertKey, Transform: StripCRLFCharacter}: repoInfo.TLSClientCertKeySecret,
&SecretMaperValidation{Dest: &repo.GithubAppPrivateKey, Transform: StripCRLFCharacter}: repoInfo.GithubAppPrivateKeySecret,
&SecretMaperValidation{Dest: &repo.GCPServiceAccountKey, Transform: StripCRLFCharacter}: repoInfo.GCPServiceAccountKey,
{Dest: &repo.Username, Transform: StripCRLFCharacter}: repoInfo.UsernameSecret,
{Dest: &repo.Password, Transform: StripCRLFCharacter}: repoInfo.PasswordSecret,
{Dest: &repo.SSHPrivateKey, Transform: StripCRLFCharacter}: repoInfo.SSHPrivateKeySecret,
{Dest: &repo.TLSClientCertData, Transform: StripCRLFCharacter}: repoInfo.TLSClientCertDataSecret,
{Dest: &repo.TLSClientCertKey, Transform: StripCRLFCharacter}: repoInfo.TLSClientCertKeySecret,
{Dest: &repo.GithubAppPrivateKey, Transform: StripCRLFCharacter}: repoInfo.GithubAppPrivateKeySecret,
{Dest: &repo.GCPServiceAccountKey, Transform: StripCRLFCharacter}: repoInfo.GCPServiceAccountKey,
}, make(map[string]*apiv1.Secret))
return repo, err
}
Expand All @@ -407,13 +407,13 @@ func (l *legacyRepositoryBackend) credentialsToRepositoryCredentials(repoInfo se
EnableOCI: repoInfo.EnableOCI,
}
err := l.db.unmarshalFromSecretsStr(map[*SecretMaperValidation]*apiv1.SecretKeySelector{
&SecretMaperValidation{Dest: &creds.Username}: repoInfo.UsernameSecret,
&SecretMaperValidation{Dest: &creds.Password}: repoInfo.PasswordSecret,
&SecretMaperValidation{Dest: &creds.SSHPrivateKey}: repoInfo.SSHPrivateKeySecret,
&SecretMaperValidation{Dest: &creds.TLSClientCertData}: repoInfo.TLSClientCertDataSecret,
&SecretMaperValidation{Dest: &creds.TLSClientCertKey}: repoInfo.TLSClientCertKeySecret,
&SecretMaperValidation{Dest: &creds.GithubAppPrivateKey}: repoInfo.GithubAppPrivateKeySecret,
&SecretMaperValidation{Dest: &creds.GCPServiceAccountKey}: repoInfo.GCPServiceAccountKey,
{Dest: &creds.Username}: repoInfo.UsernameSecret,
{Dest: &creds.Password}: repoInfo.PasswordSecret,
{Dest: &creds.SSHPrivateKey}: repoInfo.SSHPrivateKeySecret,
{Dest: &creds.TLSClientCertData}: repoInfo.TLSClientCertDataSecret,
{Dest: &creds.TLSClientCertKey}: repoInfo.TLSClientCertKeySecret,
{Dest: &creds.GithubAppPrivateKey}: repoInfo.GithubAppPrivateKeySecret,
{Dest: &creds.GCPServiceAccountKey}: repoInfo.GCPServiceAccountKey,
}, make(map[string]*apiv1.Secret))
return creds, err
}
Expand Down

0 comments on commit a0c02eb

Please sign in to comment.