From 6999380ee3edae9e9b1bc88fb30ec4aed413a0bc Mon Sep 17 00:00:00 2001 From: Christopher Fenner <26137398+CCFenner@users.noreply.github.com> Date: Thu, 24 Sep 2020 08:58:53 +0200 Subject: [PATCH] chore(go): simplify code using gofmt -s (#2065) --- cmd/abapEnvironmentRunATCCheck_test.go | 24 +++++------ cmd/checkmarxExecuteScan.go | 2 +- cmd/checkmarxExecuteScan_test.go | 24 +++++------ cmd/cloudFoundryCreateService_test.go | 36 ++++++++-------- cmd/cloudFoundryDeploy_test.go | 58 +++++++++++++------------- cmd/gctsExecuteABAPUnitTests_test.go | 2 +- cmd/kanikoExecute.go | 2 +- integration/integration_cli_test.go | 4 +- pkg/cloudfoundry/CloudFoundry_test.go | 12 +++--- pkg/config/config_test.go | 32 +++++++------- pkg/config/stepmeta_test.go | 2 +- pkg/config/vault_test.go | 2 +- pkg/http/http_test.go | 4 +- pkg/piperutils/stepResults_test.go | 4 +- pkg/protecode/protecode.go | 2 +- pkg/versioning/pip_test.go | 2 - pkg/yaml/yamlUtil_test.go | 4 +- 17 files changed, 107 insertions(+), 109 deletions(-) diff --git a/cmd/abapEnvironmentRunATCCheck_test.go b/cmd/abapEnvironmentRunATCCheck_test.go index 37ba353b8..ea283844b 100644 --- a/cmd/abapEnvironmentRunATCCheck_test.go +++ b/cmd/abapEnvironmentRunATCCheck_test.go @@ -325,12 +325,12 @@ func TestBuildATCCheckBody(t *testing.T) { "", ATCObjects{ Package: []Package{ - Package{Name: "testPackage", IncludeSubpackages: true}, - Package{Name: "testPackage2", IncludeSubpackages: false}, + {Name: "testPackage", IncludeSubpackages: true}, + {Name: "testPackage2", IncludeSubpackages: false}, }, SoftwareComponent: []SoftwareComponent{ - SoftwareComponent{Name: "testSoftwareComponent"}, - SoftwareComponent{Name: "testSoftwareComponent2"}, + {Name: "testSoftwareComponent"}, + {Name: "testSoftwareComponent2"}, }, }, } @@ -357,8 +357,8 @@ func TestBuildATCCheckBody(t *testing.T) { "", ATCObjects{ Package: []Package{ - Package{Name: "testPackage", IncludeSubpackages: true}, - Package{Name: "testPackage2", IncludeSubpackages: false}, + {Name: "testPackage", IncludeSubpackages: true}, + {Name: "testPackage2", IncludeSubpackages: false}, }, }, } @@ -386,8 +386,8 @@ func TestBuildATCCheckBody(t *testing.T) { "", ATCObjects{ SoftwareComponent: []SoftwareComponent{ - SoftwareComponent{Name: "testSoftwareComponent"}, - SoftwareComponent{Name: "testSoftwareComponent2"}, + {Name: "testSoftwareComponent"}, + {Name: "testSoftwareComponent2"}, }, }, } @@ -414,12 +414,12 @@ func TestBuildATCCheckBody(t *testing.T) { "TestConfiguration", ATCObjects{ SoftwareComponent: []SoftwareComponent{ - SoftwareComponent{Name: "testSoftwareComponent"}, - SoftwareComponent{Name: "testSoftwareComponent2"}, + {Name: "testSoftwareComponent"}, + {Name: "testSoftwareComponent2"}, }, Package: []Package{ - Package{Name: "testPackage", IncludeSubpackages: true}, - Package{Name: "testPackage2", IncludeSubpackages: false}, + {Name: "testPackage", IncludeSubpackages: true}, + {Name: "testPackage2", IncludeSubpackages: false}, }, }, } diff --git a/cmd/checkmarxExecuteScan.go b/cmd/checkmarxExecuteScan.go index 4b6d7e6f8..2099dd660 100644 --- a/cmd/checkmarxExecuteScan.go +++ b/cmd/checkmarxExecuteScan.go @@ -171,7 +171,7 @@ func verifyCxProjectCompliance(config checkmarxExecuteScanOptions, sys checkmarx xmlReportName := createReportName(workspace, "CxSASTResults_%v.xml") results := getDetailedResults(sys, xmlReportName, scanID) reports = append(reports, piperutils.Path{Target: xmlReportName}) - links := []piperutils.Path{piperutils.Path{Target: results["DeepLink"].(string), Name: "Checkmarx Web UI"}} + links := []piperutils.Path{{Target: results["DeepLink"].(string), Name: "Checkmarx Web UI"}} piperutils.PersistReportsAndLinks("checkmarxExecuteScan", workspace, reports, links) reportToInflux(results, influx) diff --git a/cmd/checkmarxExecuteScan_test.go b/cmd/checkmarxExecuteScan_test.go index 4ee452b91..165b2cef5 100644 --- a/cmd/checkmarxExecuteScan_test.go +++ b/cmd/checkmarxExecuteScan_test.go @@ -71,12 +71,12 @@ func (sys *systemMock) GetProjectByID(projectID int) (bool, checkmarx.Project) { func (sys *systemMock) GetProjectsByNameAndTeam(projectName, teamID string) []checkmarx.Project { if !sys.createProject || sys.previousPName == projectName { if strings.Contains(projectName, "PR-17") { - return []checkmarx.Project{checkmarx.Project{ID: 17, Name: projectName, TeamID: teamID, IsPublic: true}} + return []checkmarx.Project{{ID: 17, Name: projectName, TeamID: teamID, IsPublic: true}} } - return []checkmarx.Project{checkmarx.Project{ID: 19, Name: projectName, TeamID: teamID, IsPublic: true}} + return []checkmarx.Project{{ID: 19, Name: projectName, TeamID: teamID, IsPublic: true}} } if projectName == "Test" { - return []checkmarx.Project{checkmarx.Project{ID: 1, Name: projectName, TeamID: teamID, IsPublic: true}} + return []checkmarx.Project{{ID: 1, Name: projectName, TeamID: teamID, IsPublic: true}} } sys.previousPName = projectName return []checkmarx.Project{} @@ -100,7 +100,7 @@ func (sys *systemMock) GetResults(scanID int) checkmarx.ResultsStatistics { return checkmarx.ResultsStatistics{} } func (sys *systemMock) GetScans(projectID int) (bool, []checkmarx.ScanStatus) { - return true, []checkmarx.ScanStatus{checkmarx.ScanStatus{IsIncremental: true}, checkmarx.ScanStatus{IsIncremental: true}, checkmarx.ScanStatus{IsIncremental: true}, checkmarx.ScanStatus{IsIncremental: false}} + return true, []checkmarx.ScanStatus{{IsIncremental: true}, {IsIncremental: true}, {IsIncremental: true}, {IsIncremental: false}} } func (sys *systemMock) GetScanStatusAndDetail(scanID int) (string, checkmarx.ScanStatusDetail) { return "Finished", checkmarx.ScanStatusDetail{Stage: "Step 1 of 25", Step: "Scan something"} @@ -127,13 +127,13 @@ func (sys *systemMock) CreateBranch(projectID int, branchName string) int { return 18 } func (sys *systemMock) GetPresets() []checkmarx.Preset { - return []checkmarx.Preset{checkmarx.Preset{ID: 10078, Name: "SAP Java Default", OwnerName: "16"}, checkmarx.Preset{ID: 10048, Name: "SAP JS Default", OwnerName: "16"}} + return []checkmarx.Preset{{ID: 10078, Name: "SAP Java Default", OwnerName: "16"}, {ID: 10048, Name: "SAP JS Default", OwnerName: "16"}} } func (sys *systemMock) GetProjects() []checkmarx.Project { - return []checkmarx.Project{checkmarx.Project{ID: 15, Name: "OtherTest", TeamID: "16"}, checkmarx.Project{ID: 1, Name: "Test", TeamID: "16"}} + return []checkmarx.Project{{ID: 15, Name: "OtherTest", TeamID: "16"}, {ID: 1, Name: "Test", TeamID: "16"}} } func (sys *systemMock) GetTeams() []checkmarx.Team { - return []checkmarx.Team{checkmarx.Team{ID: "16", FullName: "OpenSource/Cracks/16"}, checkmarx.Team{ID: "15", FullName: "OpenSource/Cracks/15"}} + return []checkmarx.Team{{ID: "16", FullName: "OpenSource/Cracks/16"}, {ID: "15", FullName: "OpenSource/Cracks/15"}} } type systemMockForExistingProject struct { @@ -157,7 +157,7 @@ func (sys *systemMockForExistingProject) GetProjectByID(projectID int) (bool, ch return false, checkmarx.Project{} } func (sys *systemMockForExistingProject) GetProjectsByNameAndTeam(projectName, teamID string) []checkmarx.Project { - return []checkmarx.Project{checkmarx.Project{ID: 19, Name: projectName, TeamID: teamID, IsPublic: true}} + return []checkmarx.Project{{ID: 19, Name: projectName, TeamID: teamID, IsPublic: true}} } func (sys *systemMockForExistingProject) FilterTeamByName(teams []checkmarx.Team, teamName string) checkmarx.Team { return checkmarx.Team{ID: "16", FullName: "OpenSource/Cracks/16"} @@ -178,7 +178,7 @@ func (sys *systemMockForExistingProject) GetResults(scanID int) checkmarx.Result return checkmarx.ResultsStatistics{} } func (sys *systemMockForExistingProject) GetScans(projectID int) (bool, []checkmarx.ScanStatus) { - return true, []checkmarx.ScanStatus{checkmarx.ScanStatus{IsIncremental: true}, checkmarx.ScanStatus{IsIncremental: true}, checkmarx.ScanStatus{IsIncremental: true}, checkmarx.ScanStatus{IsIncremental: false}} + return true, []checkmarx.ScanStatus{{IsIncremental: true}, {IsIncremental: true}, {IsIncremental: true}, {IsIncremental: false}} } func (sys *systemMockForExistingProject) GetScanStatusAndDetail(scanID int) (string, checkmarx.ScanStatusDetail) { return "Finished", checkmarx.ScanStatusDetail{Stage: "", Step: ""} @@ -206,13 +206,13 @@ func (sys *systemMockForExistingProject) CreateBranch(projectID int, branchName return 0 } func (sys *systemMockForExistingProject) GetPresets() []checkmarx.Preset { - return []checkmarx.Preset{checkmarx.Preset{ID: 10078, Name: "SAP Java Default", OwnerName: "16"}, checkmarx.Preset{ID: 10048, Name: "SAP JS Default", OwnerName: "16"}} + return []checkmarx.Preset{{ID: 10078, Name: "SAP Java Default", OwnerName: "16"}, {ID: 10048, Name: "SAP JS Default", OwnerName: "16"}} } func (sys *systemMockForExistingProject) GetProjects() []checkmarx.Project { - return []checkmarx.Project{checkmarx.Project{ID: 1, Name: "TestExisting", TeamID: "16"}} + return []checkmarx.Project{{ID: 1, Name: "TestExisting", TeamID: "16"}} } func (sys *systemMockForExistingProject) GetTeams() []checkmarx.Team { - return []checkmarx.Team{checkmarx.Team{ID: "16", FullName: "OpenSource/Cracks/16"}, checkmarx.Team{ID: "15", FullName: "OpenSource/Cracks/15"}} + return []checkmarx.Team{{ID: "16", FullName: "OpenSource/Cracks/16"}, {ID: "15", FullName: "OpenSource/Cracks/15"}} } func TestFilterFileGlob(t *testing.T) { diff --git a/cmd/cloudFoundryCreateService_test.go b/cmd/cloudFoundryCreateService_test.go index 3fe397f5a..ffa7edde0 100644 --- a/cmd/cloudFoundryCreateService_test.go +++ b/cmd/cloudFoundryCreateService_test.go @@ -37,9 +37,9 @@ func TestCloudFoundryCreateService(t *testing.T) { } error := runCloudFoundryCreateService(&config, &telemetryData, cf) if assert.NoError(t, error) { - assert.Equal(t, []mock.ExecCall{mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, - mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName"}}, - mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, + assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, + {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName"}}, + {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, m.Calls) } }) @@ -59,9 +59,9 @@ func TestCloudFoundryCreateService(t *testing.T) { } error := runCloudFoundryCreateService(&config, &telemetryData, cf) if assert.NoError(t, error) { - assert.Equal(t, []mock.ExecCall{mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, - mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName", "-t", "testTag, testTag2"}}, - mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, + assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, + {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName", "-t", "testTag, testTag2"}}, + {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, m.Calls) } }) @@ -80,9 +80,9 @@ func TestCloudFoundryCreateService(t *testing.T) { } error := runCloudFoundryCreateService(&config, &telemetryData, cf) if assert.NoError(t, error) { - assert.Equal(t, []mock.ExecCall{mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, - mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName", "-b", "testBroker"}}, - mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, + assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, + {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName", "-b", "testBroker"}}, + {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, m.Calls) } }) @@ -101,9 +101,9 @@ func TestCloudFoundryCreateService(t *testing.T) { } error := runCloudFoundryCreateService(&config, &telemetryData, cf) if assert.NoError(t, error) { - assert.Equal(t, []mock.ExecCall{mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, - mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName", "-c", "testConfig.json"}}, - mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, + assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, + {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service", "testService", "testPlan", "testName", "-c", "testConfig.json"}}, + {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, m.Calls) } }) @@ -161,9 +161,9 @@ func TestCloudFoundryCreateService(t *testing.T) { } error := runCloudFoundryCreateService(&config, &telemetryData, cf) if assert.NoError(t, error) { - assert.Equal(t, []mock.ExecCall{mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, - mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service-push", "--no-push", "--service-manifest", "manifestTest.yml", "--var", "name1=Test1", "--var", "name2=Test2"}}, - mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, + assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, + {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service-push", "--no-push", "--service-manifest", "manifestTest.yml", "--var", "name1=Test1", "--var", "name2=Test2"}}, + {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, m.Calls) } }) @@ -218,9 +218,9 @@ func TestCloudFoundryCreateService(t *testing.T) { } error := runCloudFoundryCreateService(&config, &telemetryData, cf) if assert.NoError(t, error) { - assert.Equal(t, []mock.ExecCall{mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, - mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service-push", "--no-push", "--service-manifest", "manifestTest.yml", "--vars-file", "varsTest.yml", "--vars-file", "varsTest2.yml"}}, - mock.ExecCall{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, + assert.Equal(t, []mock.ExecCall{{Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"login", "-a", "https://api.endpoint.com", "-o", "testOrg", "-s", "testSpace", "-u", "testUser", "-p", "testPassword"}}, + {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"create-service-push", "--no-push", "--service-manifest", "manifestTest.yml", "--vars-file", "varsTest.yml", "--vars-file", "varsTest2.yml"}}, + {Execution: (*mock.Execution)(nil), Async: false, Exec: "cf", Params: []string{"logout"}}}, m.Calls) } }) diff --git a/cmd/cloudFoundryDeploy_test.go b/cmd/cloudFoundryDeploy_test.go index 1d70688c7..0081d723a 100644 --- a/cmd/cloudFoundryDeploy_test.go +++ b/cmd/cloudFoundryDeploy_test.go @@ -263,8 +263,8 @@ func TestCfDeployment(t *testing.T) { withLoginAndLogout(t, func(t *testing.T) { assert.Equal(t, []mock.ExecCall{ - mock.ExecCall{Exec: "cf", Params: []string{"plugins"}}, - mock.ExecCall{Exec: "cf", Params: []string{"push", "-f", "manifest.yml"}}, + {Exec: "cf", Params: []string{"plugins"}}, + {Exec: "cf", Params: []string{"push", "-f", "manifest.yml"}}, }, s.Calls) }) }) @@ -341,8 +341,8 @@ func TestCfDeployment(t *testing.T) { withLoginAndLogout(t, func(t *testing.T) { assert.Equal(t, []mock.ExecCall{ - mock.ExecCall{Exec: "cf", Params: []string{"plugins"}}, - mock.ExecCall{Exec: "cf", Params: []string{"push", + {Exec: "cf", Params: []string{"plugins"}}, + {Exec: "cf", Params: []string{"push", "testAppName", "--docker-image", "repo/image:tag", @@ -380,8 +380,8 @@ func TestCfDeployment(t *testing.T) { withLoginAndLogout(t, func(t *testing.T) { assert.Equal(t, []mock.ExecCall{ - mock.ExecCall{Exec: "cf", Params: []string{"plugins"}}, - mock.ExecCall{Exec: "cf", Params: []string{"push", + {Exec: "cf", Params: []string{"plugins"}}, + {Exec: "cf", Params: []string{"push", "testAppName", "--docker-image", "repo/image:tag", @@ -427,8 +427,8 @@ func TestCfDeployment(t *testing.T) { withLoginAndLogout(t, func(t *testing.T) { assert.Equal(t, []mock.ExecCall{ - mock.ExecCall{Exec: "cf", Params: []string{"plugins"}}, - mock.ExecCall{Exec: "cf", Params: []string{ + {Exec: "cf", Params: []string{"plugins"}}, + {Exec: "cf", Params: []string{ "blue-green-deploy", "testAppName", "--delete-old-apps", @@ -469,8 +469,8 @@ func TestCfDeployment(t *testing.T) { withLoginAndLogout(t, func(t *testing.T) { assert.Equal(t, []mock.ExecCall{ - mock.ExecCall{Exec: "cf", Params: []string{"plugins"}}, - mock.ExecCall{Exec: "cf", Params: []string{ + {Exec: "cf", Params: []string{"plugins"}}, + {Exec: "cf", Params: []string{ "push", "-f", "test-manifest.yml", @@ -528,14 +528,14 @@ func TestCfDeployment(t *testing.T) { withLoginAndLogout(t, func(t *testing.T) { assert.Equal(t, []mock.ExecCall{ - mock.ExecCall{Exec: "cf", Params: []string{"plugins"}}, - mock.ExecCall{Exec: "cf", Params: []string{ + {Exec: "cf", Params: []string{"plugins"}}, + {Exec: "cf", Params: []string{ "blue-green-deploy", "myTestApp", "-f", "test-manifest.yml", }}, - mock.ExecCall{Exec: "cf", Params: []string{ + {Exec: "cf", Params: []string{ "stop", "myTestApp-old", // MIGRATE FFROM GROOVY: in contrast to groovy there is not redirect of everything &> to a file since we @@ -589,7 +589,7 @@ func TestCfDeployment(t *testing.T) { return manifestMock{ manifestFileName: "test-manifest.yml", apps: []map[string]interface{}{ - map[string]interface{}{ + { "name": "app1", "no-route": true, }, @@ -609,8 +609,8 @@ func TestCfDeployment(t *testing.T) { withLoginAndLogout(t, func(t *testing.T) { assert.Equal(t, []mock.ExecCall{ - mock.ExecCall{Exec: "cf", Params: []string{"plugins"}}, - mock.ExecCall{Exec: "cf", Params: []string{ + {Exec: "cf", Params: []string{"plugins"}}, + {Exec: "cf", Params: []string{ "push", "myTestApp", "-f", @@ -711,8 +711,8 @@ func TestCfDeployment(t *testing.T) { withLoginAndLogout(t, func(t *testing.T) { assert.Equal(t, []mock.ExecCall{ - mock.ExecCall{Exec: "cf", Params: []string{"plugins"}}, - mock.ExecCall{Exec: "cf", Params: []string{ + {Exec: "cf", Params: []string{"plugins"}}, + {Exec: "cf", Params: []string{ "push", "myTestApp", "-f", @@ -748,7 +748,7 @@ func TestCfDeployment(t *testing.T) { return manifestMock{ manifestFileName: "test-manifest.yml", apps: []map[string]interface{}{ - map[string]interface{}{ + { "there-is": "no-app-name", }, }, @@ -795,8 +795,8 @@ func TestCfDeployment(t *testing.T) { withLoginAndLogout(t, func(t *testing.T) { assert.Equal(t, []mock.ExecCall{ - mock.ExecCall{Exec: "cf", Params: []string{"plugins"}}, - mock.ExecCall{Exec: "cf", Params: []string{ + {Exec: "cf", Params: []string{"plugins"}}, + {Exec: "cf", Params: []string{ "bg-deploy", "target/test.mtar", "-f", @@ -836,7 +836,7 @@ func TestCfDeployment(t *testing.T) { return manifestMock{ manifestFileName: "test-manifest.yml", apps: []map[string]interface{}{ - map[string]interface{}{ + { "name": "myApp", }, }, @@ -857,8 +857,8 @@ func TestCfDeployment(t *testing.T) { // Revisit: we don't verify a log message in case of a non existing vars file assert.Equal(t, []mock.ExecCall{ - mock.ExecCall{Exec: "cf", Params: []string{"plugins"}}, - mock.ExecCall{Exec: "cf", Params: []string{ + {Exec: "cf", Params: []string{"plugins"}}, + {Exec: "cf", Params: []string{ "push", "testAppName", "--var", @@ -896,7 +896,7 @@ func TestCfDeployment(t *testing.T) { return manifestMock{ manifestFileName: "test-manifest.yml", apps: []map[string]interface{}{ - map[string]interface{}{ + { "name": "myApp", }, }, @@ -916,8 +916,8 @@ func TestCfDeployment(t *testing.T) { // Revisit: we don't verify a log message in case of a non existing vars file assert.Equal(t, []mock.ExecCall{ - mock.ExecCall{Exec: "cf", Params: []string{"plugins"}}, - mock.ExecCall{Exec: "cf", Params: []string{ + {Exec: "cf", Params: []string{"plugins"}}, + {Exec: "cf", Params: []string{ "push", "testAppName", "--vars-file", @@ -966,8 +966,8 @@ func TestCfDeployment(t *testing.T) { withLoginAndLogout(t, func(t *testing.T) { assert.Equal(t, s.Calls, []mock.ExecCall{ - mock.ExecCall{Exec: "cf", Params: []string{"plugins"}}, - mock.ExecCall{Exec: "cf", Params: []string{"deploy", "xyz.mtar", "-f"}}}) + {Exec: "cf", Params: []string{"plugins"}}, + {Exec: "cf", Params: []string{"deploy", "xyz.mtar", "-f"}}}) }) } diff --git a/cmd/gctsExecuteABAPUnitTests_test.go b/cmd/gctsExecuteABAPUnitTests_test.go index ecf3bd56a..e26dc4859 100644 --- a/cmd/gctsExecuteABAPUnitTests_test.go +++ b/cmd/gctsExecuteABAPUnitTests_test.go @@ -21,7 +21,7 @@ func TestDiscoverySuccess(t *testing.T) { httpClient := httpMockGcts{ StatusCode: 200, - Header: map[string][]string{"x-csrf-token": []string{"ZegUEgfa50R7ZfGGxOtx2A=="}}, + Header: map[string][]string{"x-csrf-token": {"ZegUEgfa50R7ZfGGxOtx2A=="}}, ResponseBody: ` diff --git a/cmd/kanikoExecute.go b/cmd/kanikoExecute.go index 17630d222..da0967118 100644 --- a/cmd/kanikoExecute.go +++ b/cmd/kanikoExecute.go @@ -19,7 +19,7 @@ func kanikoExecute(config kanikoExecuteOptions, telemetryData *telemetry.CustomD // for command execution use Command c := command.Command{ ErrorCategoryMapping: map[string][]string{ - log.ErrorConfiguration.String(): []string{ + log.ErrorConfiguration.String(): { "unsupported status code 401", }, }, diff --git a/integration/integration_cli_test.go b/integration/integration_cli_test.go index 9eb3ddfc3..fbf762568 100644 --- a/integration/integration_cli_test.go +++ b/integration/integration_cli_test.go @@ -51,13 +51,13 @@ cd /test tempDir: "/test", }, Networks: []string{networkName}, - NetworkAliases: map[string][]string{networkName: []string{"karma"}}, + NetworkAliases: map[string][]string{networkName: {"karma"}}, } reqSel := testcontainers.ContainerRequest{ Image: "selenium/standalone-chrome", Networks: []string{networkName}, - NetworkAliases: map[string][]string{networkName: []string{"selenium"}}, + NetworkAliases: map[string][]string{networkName: {"selenium"}}, } provider, err := testcontainers.ProviderDocker.GetProvider() diff --git a/pkg/cloudfoundry/CloudFoundry_test.go b/pkg/cloudfoundry/CloudFoundry_test.go index cf296e1cb..5f3ead471 100644 --- a/pkg/cloudfoundry/CloudFoundry_test.go +++ b/pkg/cloudfoundry/CloudFoundry_test.go @@ -79,7 +79,7 @@ func TestCloudFoundryLogin(t *testing.T) { if assert.EqualError(t, err, "Failed to login to Cloud Foundry: wrong password or account does not exist") { assert.False(t, cf.loggedIn) assert.Equal(t, []mock.ExecCall{ - mock.ExecCall{Exec: "cf", Params: []string{ + {Exec: "cf", Params: []string{ "login", "-a", "https://api.endpoint.com", "-o", "testOrg", @@ -109,7 +109,7 @@ func TestCloudFoundryLogin(t *testing.T) { if assert.NoError(t, err) { assert.True(t, cf.loggedIn) assert.Equal(t, []mock.ExecCall{ - mock.ExecCall{Exec: "cf", Params: []string{ + {Exec: "cf", Params: []string{ "login", "-a", "https://api.endpoint.com", "-o", "testOrg", @@ -142,7 +142,7 @@ func TestCloudFoundryLogin(t *testing.T) { if assert.NoError(t, err) { assert.True(t, cf.loggedIn) assert.Equal(t, []mock.ExecCall{ - mock.ExecCall{Exec: "cf", Params: []string{ + {Exec: "cf", Params: []string{ "login", "-a", "https://api.endpoint.com", "-o", "testOrg", @@ -205,7 +205,7 @@ func TestCloudFoundryReadServiceKeyAbapEnvironment(t *testing.T) { //then if assert.NoError(t, err) { assert.Equal(t, []mock.ExecCall{ - mock.ExecCall{Exec: "cf", Params: []string{ + {Exec: "cf", Params: []string{ "login", "-a", "https://api.endpoint.com", "-o", "testOrg", @@ -213,8 +213,8 @@ func TestCloudFoundryReadServiceKeyAbapEnvironment(t *testing.T) { "-u", "testUser", "-p", "testPassword", }}, - mock.ExecCall{Exec: "cf", Params: []string{"service-key", "testInstance", "testServiceKeyName"}}, - mock.ExecCall{Exec: "cf", Params: []string{"logout"}}, + {Exec: "cf", Params: []string{"service-key", "testInstance", "testServiceKeyName"}}, + {Exec: "cf", Params: []string{"logout"}}, }, m.Calls) } assert.Equal(t, ` {"sap.cloud.service":"com.sap.cloud.abap","url": "`+testURL+`" ,"systemid":"H01","abap":{"username":"`+username+`","password":"`+password+`","communication_scenario_id": "SAP_COM_0510","communication_arrangement_id": "SK_I6CBIRFZPPJDKYNATQA32W","communication_system_id": "SK_I6CBIRFZPPJDKYNATQA32W","communication_inbound_user_id": "CC0000000001","communication_inbound_user_auth_mode": "2"},"binding":{"env": "cf","version": "0.0.1.1","type": "basic","id": "i6cBiRfZppJdKynaTqa32W"},"preserve_host_header": true}`, abapServiceKey) diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index daafde8c0..fd73761c8 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -249,7 +249,7 @@ steps: t.Run("Consider defaults from step config", func(t *testing.T) { var c Config - stepParams := []StepParameters{StepParameters{Name: "p0", Scope: []string{"GENERAL"}, Type: "string", Default: "p0_step_default", Aliases: []Alias{{Name: "p0_alias"}}}} + stepParams := []StepParameters{{Name: "p0", Scope: []string{"GENERAL"}, Type: "string", Default: "p0_step_default", Aliases: []Alias{{Name: "p0_alias"}}}} testConf := "general:\n p1: p1_conf" stepConfig, err := c.GetStepConfig(nil, "", ioutil.NopCloser(strings.NewReader(testConf)), nil, false, StepFilters{General: []string{"p0", "p1"}}, stepParams, nil, nil, "stage1", "step1", []Alias{}) @@ -263,8 +263,8 @@ steps: var c Config stepParams := []StepParameters{ - StepParameters{Name: "p0", Scope: []string{"GENERAL"}, Type: "bool", Aliases: []Alias{}}, - StepParameters{Name: "p1", Scope: []string{"GENERAL"}, Type: "string", Aliases: []Alias{{Name: "p0/subParam"}}}} + {Name: "p0", Scope: []string{"GENERAL"}, Type: "bool", Aliases: []Alias{}}, + {Name: "p1", Scope: []string{"GENERAL"}, Type: "string", Aliases: []Alias{{Name: "p0/subParam"}}}} testConf := "general:\n p0: true" stepConfig, err := c.GetStepConfig(nil, "", ioutil.NopCloser(strings.NewReader(testConf)), nil, false, StepFilters{General: []string{"p0", "p1"}}, stepParams, nil, nil, "stage1", "step1", []Alias{{}}) @@ -278,7 +278,7 @@ steps: var c Config secrets := []StepSecrets{ - StepSecrets{Name: "p0", Type: "string", Aliases: []Alias{{Name: "p1/subParam"}}}} + {Name: "p0", Type: "string", Aliases: []Alias{{Name: "p1/subParam"}}}} testConf := "" paramJSON := "{\"p1\":{\"subParam\":\"p1_value\"}}" @@ -415,18 +415,18 @@ func TestApplyAliasConfig(t *testing.T) { }, }, Stages: map[string]map[string]interface{}{ - "stage1": map[string]interface{}{ + "stage1": { "p3_notused": "p3_stage", "p4_alias": "p4_stage", }, }, Steps: map[string]map[string]interface{}{ - "step1": map[string]interface{}{ + "step1": { "p5_notused": "p5_step", "p6_alias": "p6_step", "p7": "p7_step", }, - "stepAlias1": map[string]interface{}{ + "stepAlias1": { "p7": "p7_stepAlias", "p8_alias": "p8_stepAlias", "p9": "p9_stepAlias", @@ -491,15 +491,15 @@ func TestCopyStepAliasConfig(t *testing.T) { t.Run("Step config available", func(t *testing.T) { c := Config{ Steps: map[string]map[string]interface{}{ - "step1": map[string]interface{}{ + "step1": { "p1": "p1_step", "p2": "p2_step", }, - "stepAlias1": map[string]interface{}{ + "stepAlias1": { "p2": "p2_stepAlias", "p3": "p3_stepAlias", }, - "stepAlias2": map[string]interface{}{ + "stepAlias2": { "p3": "p3_stepAlias2", "p4": "p4_stepAlias2", }, @@ -508,17 +508,17 @@ func TestCopyStepAliasConfig(t *testing.T) { expected := Config{ Steps: map[string]map[string]interface{}{ - "step1": map[string]interface{}{ + "step1": { "p1": "p1_step", "p2": "p2_step", "p3": "p3_stepAlias", "p4": "p4_stepAlias2", }, - "stepAlias1": map[string]interface{}{ + "stepAlias1": { "p2": "p2_stepAlias", "p3": "p3_stepAlias", }, - "stepAlias2": map[string]interface{}{ + "stepAlias2": { "p3": "p3_stepAlias2", "p4": "p4_stepAlias2", }, @@ -532,7 +532,7 @@ func TestCopyStepAliasConfig(t *testing.T) { t.Run("Step config not available", func(t *testing.T) { c := Config{ Steps: map[string]map[string]interface{}{ - "stepAlias1": map[string]interface{}{ + "stepAlias1": { "p2": "p2_stepAlias", }, }, @@ -540,10 +540,10 @@ func TestCopyStepAliasConfig(t *testing.T) { expected := Config{ Steps: map[string]map[string]interface{}{ - "step1": map[string]interface{}{ + "step1": { "p2": "p2_stepAlias", }, - "stepAlias1": map[string]interface{}{ + "stepAlias1": { "p2": "p2_stepAlias", }, }, diff --git a/pkg/config/stepmeta_test.go b/pkg/config/stepmeta_test.go index 9e74436c1..e3a705969 100644 --- a/pkg/config/stepmeta_test.go +++ b/pkg/config/stepmeta_test.go @@ -262,7 +262,7 @@ func TestGetContextParameterFilters(t *testing.T) { Spec: StepSpec{ Inputs: StepInputs{ Parameters: []StepParameters{ - StepParameters{ResourceRef: []ResourceReference{ResourceReference{Type: "vaultSecret"}}}, + {ResourceRef: []ResourceReference{{Type: "vaultSecret"}}}, }, }, }, diff --git a/pkg/config/vault_test.go b/pkg/config/vault_test.go index 302f7d2f1..0a8665247 100644 --- a/pkg/config/vault_test.go +++ b/pkg/config/vault_test.go @@ -97,7 +97,7 @@ func stepParam(name string, refType string, refPaths ...string) StepParameters { return StepParameters{ Name: name, ResourceRef: []ResourceReference{ - ResourceReference{ + { Type: refType, Paths: refPaths, }, diff --git a/pkg/http/http_test.go b/pkg/http/http_test.go index 9358b5647..622501141 100644 --- a/pkg/http/http_test.go +++ b/pkg/http/http_test.go @@ -48,7 +48,7 @@ func TestSendRequest(t *testing.T) { expected string }{ {client: Client{logger: log.Entry().WithField("package", "SAP/jenkins-library/pkg/http")}, method: "GET", expected: "OK"}, - {client: Client{logger: log.Entry().WithField("package", "SAP/jenkins-library/pkg/http")}, method: "GET", header: map[string][]string{"Testheader": []string{"Test1", "Test2"}}, expected: "OK"}, + {client: Client{logger: log.Entry().WithField("package", "SAP/jenkins-library/pkg/http")}, method: "GET", header: map[string][]string{"Testheader": {"Test1", "Test2"}}, expected: "OK"}, {client: Client{logger: log.Entry().WithField("package", "SAP/jenkins-library/pkg/http")}, cookies: []*http.Cookie{{Name: "TestCookie1", Value: "TestValue1"}, {Name: "TestCookie2", Value: "TestValue2"}}, method: "GET", expected: "OK"}, {client: Client{logger: log.Entry().WithField("package", "SAP/jenkins-library/pkg/http"), username: "TestUser", password: "TestPwd"}, method: "GET", expected: "OK"}, } @@ -166,7 +166,7 @@ func TestUploadRequest(t *testing.T) { }{ {clientOptions: ClientOptions{}, method: "PUT", expected: "OK"}, {clientOptions: ClientOptions{}, method: "POST", expected: "OK"}, - {clientOptions: ClientOptions{}, method: "POST", header: map[string][]string{"Testheader": []string{"Test1", "Test2"}}, expected: "OK"}, + {clientOptions: ClientOptions{}, method: "POST", header: map[string][]string{"Testheader": {"Test1", "Test2"}}, expected: "OK"}, {clientOptions: ClientOptions{}, cookies: []*http.Cookie{{Name: "TestCookie1", Value: "TestValue1"}, {Name: "TestCookie2", Value: "TestValue2"}}, method: "POST", expected: "OK"}, {clientOptions: ClientOptions{Username: "TestUser", Password: "TestPwd"}, method: "POST", expected: "OK"}, } diff --git a/pkg/piperutils/stepResults_test.go b/pkg/piperutils/stepResults_test.go index d8088a5d0..884a1c73d 100644 --- a/pkg/piperutils/stepResults_test.go +++ b/pkg/piperutils/stepResults_test.go @@ -18,8 +18,8 @@ func TestPersistReportAndLinks(t *testing.T) { // clean up tmp dir defer os.RemoveAll(workspace) - reports := []Path{Path{Target: "testFile1.json", Mandatory: true}, Path{Target: "testFile2.json"}} - links := []Path{Path{Target: "https://1234568.com/test", Name: "Weblink"}} + reports := []Path{{Target: "testFile1.json", Mandatory: true}, {Target: "testFile2.json"}} + links := []Path{{Target: "https://1234568.com/test", Name: "Weblink"}} PersistReportsAndLinks("checkmarxExecuteScan", workspace, reports, links) reportsJSONPath := filepath.Join(workspace, "checkmarxExecuteScan_reports.json") diff --git a/pkg/protecode/protecode.go b/pkg/protecode/protecode.go index 27fe43682..41c167919 100644 --- a/pkg/protecode/protecode.go +++ b/pkg/protecode/protecode.go @@ -312,7 +312,7 @@ func (pc *Protecode) UploadScanFile(cleanupMode, group, filePath, fileName strin // DeclareFetchURL configures the fetch url for the protecode scan func (pc *Protecode) DeclareFetchURL(cleanupMode, group, fetchURL string) *ResultData { deleteBinary := (cleanupMode == "binary" || cleanupMode == "complete") - headers := map[string][]string{"Group": {group}, "Delete-Binary": {fmt.Sprintf("%v", deleteBinary)}, "Url": {fetchURL}, "Content-Type": []string{"application/json"}} + headers := map[string][]string{"Group": {group}, "Delete-Binary": {fmt.Sprintf("%v", deleteBinary)}, "Url": {fetchURL}, "Content-Type": {"application/json"}} protecodeURL := fmt.Sprintf("%v/api/fetch/", pc.serverURL) r, err := pc.sendAPIRequest(http.MethodPost, protecodeURL, headers) diff --git a/pkg/versioning/pip_test.go b/pkg/versioning/pip_test.go index 74b9ce700..34f757803 100644 --- a/pkg/versioning/pip_test.go +++ b/pkg/versioning/pip_test.go @@ -1,3 +1 @@ package versioning - -import () diff --git a/pkg/yaml/yamlUtil_test.go b/pkg/yaml/yamlUtil_test.go index c64afcd40..4638dda5e 100644 --- a/pkg/yaml/yamlUtil_test.go +++ b/pkg/yaml/yamlUtil_test.go @@ -76,7 +76,7 @@ func TestFilesRelated(t *testing.T) { setupFileMock(map[string][]byte{ "manifest.yml": []byte("a: dummy"), - "replacements.yml": []byte{}, + "replacements.yml": {}, }) updated, err := Substitute("manifest.yml", map[string]interface{}{}, []string{"replacements.yml"}) @@ -95,7 +95,7 @@ func TestFilesRelated(t *testing.T) { setupFileMock(map[string][]byte{ "manifest.yml": []byte("a: dummy"), - "replacements.yml": []byte{}, + "replacements.yml": {}, }) _traverse = func(interface{}, map[string]interface{}) (interface{}, bool, error) {