From a5870e7ae8d9394e837aaf8ee75394abebf61772 Mon Sep 17 00:00:00 2001 From: Shwetha Gururaj Date: Mon, 22 Sep 2025 16:51:30 -0400 Subject: [PATCH 1/3] Migrate to golangci v2 --- .github/workflows/golangci-lint.yml | 5 +- .golangci.json | 159 ++++++++++++++---- Makefile | 2 +- actor/v7action/deployment_test.go | 3 +- actor/v7action/organization_quota_test.go | 4 +- actor/v7action/revisions_test.go | 3 +- api/cloudcontroller/ccv3/buildpack_test.go | 21 ++- api/cloudcontroller/ccv3/droplet_test.go | 4 +- api/cloudcontroller/ccv3/manifest_test.go | 12 +- api/cloudcontroller/ccv3/organization_test.go | 5 +- .../ccv3/paginated_resources_test.go | 3 +- api/cloudcontroller/ccv3/requester_test.go | 39 ++--- api/cloudcontroller/ccv3/space_test.go | 28 +-- api/uaa/prompts_test.go | 5 +- api/uaa/version_test.go | 5 +- command/v7/config_command_test.go | 3 +- command/v7/logs_command_test.go | 1 - command/v7/revisions_command_test.go | 3 +- command/v7/ssh_code_command_test.go | 4 +- util/configv3/json_config_test.go | 3 +- util/configv3/load_config_test.go | 21 +-- util/randomword/generator_test.go | 2 +- util/ui/prompt.go | 2 +- 23 files changed, 205 insertions(+), 132 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index db009a3dcd6..3a05765725a 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -3,7 +3,6 @@ name: golangci-lint on: push: tags: - - "v9.*" - "v8.*" pull_request: types: @@ -12,7 +11,6 @@ on: - synchronize branches: - main - - v9 - v8 paths-ignore: - "doc/**" @@ -35,8 +33,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v8 with: - version: v1.64 - args: -v --exclude-dirs cf --exclude-dirs fixtures --exclude-dirs plugin --exclude-dirs command/plugin + version: v2.4 format: name: Run go fmt runs-on: ubuntu-latest diff --git a/.golangci.json b/.golangci.json index ef9807d244b..18d18b4b6e7 100644 --- a/.golangci.json +++ b/.golangci.json @@ -1,45 +1,130 @@ { - "run": { - "concurrency": 4, - "timeout": "20m" + "formatters": { + "enable": [ + "goimports" + ], + "exclusions": { + "generated": "lax", + "paths": [ + "integration/helpers/fake_server.go", + "command/plugin/*.go$", + "third_party$", + "builtin$", + "examples$", + "cf", + "fixtures", + "plugin" + ] + } + }, + "issues": { + "max-same-issues": 0 }, "linters": { - "disable-all": true, + "default": "none", "enable": [ - "govet", - "goimports", "errcheck", + "govet", + "ineffassign", "staticcheck", - "unused", - "ineffassign" - ] - }, - "linters-settings": {}, - "issues": { - "max-same-issues": 0, - "exclude-files": [ - "integration/helpers/fake_server.go", - "command/plugin/*.go$" + "unused" ], - "exclude": [ - "Error return value of `client.GetApplicationTasks` is not checked", - "Error return value of `logger.output.Stop` is not checked", - "Error return value of `request.ResetBody` is not checked", - "Error return value of `GinkgoWriter.Write` is not checked", - "Error return value of `c.terminalHelper.RestoreTerminal` is not checked", - "U1000: field `allproxy` is unused", - "U1000: field `dockerPassword` is unused", - "U1000: field `envCFStagingTimeout` is unused", - "U1000: field `envCFStartupTimeout` is unused", - "U1000: field `relatedCommands` is unused", - "U1000: field `usage` is unused", - "SA5008: duplicate struct tag \"choice\"", - "`allproxy` is unused", - "`dockerPassword` is unused", - "`envCFStagingTimeout` is unused", - "`envCFStartupTimeout` is unused", - "`relatedCommands` is unused", - "`usage` is unused" - ] - } + "settings": { + "staticcheck": { + "checks": [ + "all", + "-S1002", + "-S1005", + "-S1007", + "-S1009", + "-S1011", + "-S1012", + "-S1016", + "-S1020", + "-S1039", + "-ST1001", + "-ST1003", + "-ST1005", + "-ST1012", + "-ST1016", + "-QF1001", + "-QF1002", + "-QF1003", + "-QF1004", + "-QF1008", + "-QF1012", + "-SA5008" + ] + } + }, + "exclusions": { + "generated": "lax", + "paths": [ + "integration/helpers/fake_server.go", + "command/plugin/*.go$", + "third_party$", + "builtin$", + "examples$", + "cf", + "fixtures", + "plugin" + ], + "presets": [ + "comments", + "common-false-positives", + "legacy", + "std-error-handling" + ], + "rules": [ + { + "linters": ["unused"], + "text": "field usage is unused" + }, + { + "linters": ["unused"], + "text": "field relatedCommands is unused" + }, + { + "linters": ["unused"], + "text": "field allproxy is unused" + }, + { + "linters": ["unused"], + "text": "field dockerPassword is unused" + }, + { + "linters": ["unused"], + "text": "field envCFStagingTimeout is unused" + }, + { + "linters": ["unused"], + "text": "field envCFStartupTimeout is unused" + }, + { + "linters": ["errcheck"], + "text": "Error return value of `GinkgoWriter.Write` is not checked" + }, + { + "linters": ["errcheck"], + "text": "Error return value of `client.GetApplicationTasks` is not checked" + }, + { + "linters": ["errcheck"], + "text": "Error return value of `logger.output.Stop` is not checked" + }, + { + "linters": ["errcheck"], + "text": "Error return value of `request.ResetBody` is not checked" + }, + { + "linters": ["errcheck"], + "text": "Error return value of `c.terminalHelper.RestoreTerminal` is not checked" + } + ] + } + }, + "run": { + "concurrency": 4 + }, + "version": "2" } diff --git a/Makefile b/Makefile index d04ae2048f7..01c7522e8c7 100644 --- a/Makefile +++ b/Makefile @@ -147,7 +147,7 @@ integration-tests-full-ci: install-test-deps integration-cleanup lint: format ## Runs all linters and formatters @echo "Running linters..." - golangci-lint run --exclude-dirs cf --exclude-dirs fixtures --exclude-dirs plugin --exclude-dirs command/plugin + golangci-lint run @echo "No lint errors!" # TODO: version specific tagging for all these builds diff --git a/actor/v7action/deployment_test.go b/actor/v7action/deployment_test.go index 33afe3c3312..7eb5469def3 100644 --- a/actor/v7action/deployment_test.go +++ b/actor/v7action/deployment_test.go @@ -4,7 +4,6 @@ import ( "errors" "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" . "code.cloudfoundry.org/cli/actor/v7action" "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" @@ -18,7 +17,7 @@ var _ = Describe("Deployment Actions", func() { var ( actor *Actor executeErr error - warnings v7action.Warnings + warnings Warnings returnedDeploymentGUID string fakeCloudControllerClient *v7actionfakes.FakeCloudControllerClient ) diff --git a/actor/v7action/organization_quota_test.go b/actor/v7action/organization_quota_test.go index 6b8e5defba6..7c6c71b594f 100644 --- a/actor/v7action/organization_quota_test.go +++ b/actor/v7action/organization_quota_test.go @@ -17,8 +17,8 @@ var _ = Describe("Organization Quota Actions", func() { var ( actor *Actor fakeCloudControllerClient *v7actionfakes.FakeCloudControllerClient - trueValue bool = true - falseValue bool = false + trueValue = true + falseValue = false ) BeforeEach(func() { diff --git a/actor/v7action/revisions_test.go b/actor/v7action/revisions_test.go index 2a8c74368d4..1a69d852974 100644 --- a/actor/v7action/revisions_test.go +++ b/actor/v7action/revisions_test.go @@ -5,7 +5,6 @@ import ( "strconv" "code.cloudfoundry.org/cli/actor/actionerror" - "code.cloudfoundry.org/cli/actor/v7action" . "code.cloudfoundry.org/cli/actor/v7action" "code.cloudfoundry.org/cli/actor/v7action/v7actionfakes" "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" @@ -403,7 +402,7 @@ var _ = Describe("Revisions Actions", func() { Describe("GetEnvironmentVariableGroupByRevision", func() { var ( actor *Actor - environmentVariablesGroup v7action.EnvironmentVariableGroup + environmentVariablesGroup EnvironmentVariableGroup executeErr error fakeCloudControllerClient *v7actionfakes.FakeCloudControllerClient fakeConfig *v7actionfakes.FakeConfig diff --git a/api/cloudcontroller/ccv3/buildpack_test.go b/api/cloudcontroller/ccv3/buildpack_test.go index 9ef09c56dc9..5a039307b04 100644 --- a/api/cloudcontroller/ccv3/buildpack_test.go +++ b/api/cloudcontroller/ccv3/buildpack_test.go @@ -17,7 +17,6 @@ import ( "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - . "code.cloudfoundry.org/cli/resources" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" . "github.com/onsi/gomega/ghttp" @@ -121,7 +120,7 @@ var _ = Describe("Buildpacks", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(buildpacks).To(ConsistOf( - Buildpack{ + resources.Buildpack{ Name: "ruby_buildpack", GUID: "guid1", Position: types.NullInt{Value: 1, IsSet: true}, @@ -129,9 +128,9 @@ var _ = Describe("Buildpacks", func() { Locked: types.NullBool{Value: false, IsSet: true}, Stack: "windows64", State: "AWAITING_UPLOAD", - Metadata: &Metadata{Labels: map[string]types.NullString{}}, + Metadata: &resources.Metadata{Labels: map[string]types.NullString{}}, }, - Buildpack{ + resources.Buildpack{ Name: "staticfile_buildpack", GUID: "guid2", Position: types.NullInt{Value: 2, IsSet: true}, @@ -139,9 +138,9 @@ var _ = Describe("Buildpacks", func() { Locked: types.NullBool{Value: true, IsSet: true}, Stack: "cflinuxfs4", State: "AWAITING_UPLOAD", - Metadata: &Metadata{Labels: map[string]types.NullString{}}, + Metadata: &resources.Metadata{Labels: map[string]types.NullString{}}, }, - Buildpack{ + resources.Buildpack{ Name: "go_buildpack", GUID: "guid3", Position: types.NullInt{Value: 3, IsSet: true}, @@ -149,7 +148,7 @@ var _ = Describe("Buildpacks", func() { Locked: types.NullBool{Value: false, IsSet: true}, Stack: "cflinuxfs4", State: "AWAITING_UPLOAD", - Metadata: &Metadata{Labels: map[string]types.NullString{}}, + Metadata: &resources.Metadata{Labels: map[string]types.NullString{}}, }, )) Expect(warnings).To(ConsistOf("this is a warning", "this is another warning")) @@ -203,9 +202,9 @@ var _ = Describe("Buildpacks", func() { Describe("CreateBuildpack", func() { var ( - inputBuildpack Buildpack + inputBuildpack resources.Buildpack - bp Buildpack + bp resources.Buildpack warnings Warnings executeErr error ) @@ -216,7 +215,7 @@ var _ = Describe("Buildpacks", func() { When("the buildpack is successfully created", func() { BeforeEach(func() { - inputBuildpack = Buildpack{ + inputBuildpack = resources.Buildpack{ Name: "some-buildpack", Stack: "some-stack", } @@ -259,7 +258,7 @@ var _ = Describe("Buildpacks", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(warnings).To(ConsistOf("this is a warning")) - expectedBuildpack := Buildpack{ + expectedBuildpack := resources.Buildpack{ GUID: "some-bp-guid", Name: "some-buildpack", Stack: "some-stack", diff --git a/api/cloudcontroller/ccv3/droplet_test.go b/api/cloudcontroller/ccv3/droplet_test.go index 2e8f9eed293..1c69755ef63 100644 --- a/api/cloudcontroller/ccv3/droplet_test.go +++ b/api/cloudcontroller/ccv3/droplet_test.go @@ -9,7 +9,7 @@ import ( "code.cloudfoundry.org/cli/api/cloudcontroller" "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" - "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" + . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" @@ -433,7 +433,7 @@ var _ = Describe("Droplet", func() { }) BeforeEach(func() { - requester.MakeRequestReceiveRawCalls(func(string, internal.Params, string) ([]byte, ccv3.Warnings, error) { + requester.MakeRequestReceiveRawCalls(func(string, internal.Params, string) ([]byte, Warnings, error) { return []byte{'d', 'r', 'o', 'p'}, Warnings{"some-warning"}, errors.New("some-error") }) }) diff --git a/api/cloudcontroller/ccv3/manifest_test.go b/api/cloudcontroller/ccv3/manifest_test.go index 4038a805562..38dec3c679c 100644 --- a/api/cloudcontroller/ccv3/manifest_test.go +++ b/api/cloudcontroller/ccv3/manifest_test.go @@ -6,7 +6,7 @@ import ( "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" + "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" @@ -17,7 +17,7 @@ import ( var _ = Describe("Application Manifest", func() { var ( - client *Client + client *ccv3.Client requester *ccv3fakes.FakeRequester ) @@ -31,7 +31,7 @@ var _ = Describe("Application Manifest", func() { appGUID string rawManifest []byte - warnings Warnings + warnings ccv3.Warnings executeErr error expectedYAML []byte @@ -48,7 +48,7 @@ var _ = Describe("Application Manifest", func() { When("getting the manifest is successful", func() { BeforeEach(func() { expectedYAML = []byte("---\n- banana") - requester.MakeRequestReceiveRawReturns(expectedYAML, Warnings{"this is a warning"}, nil) + requester.MakeRequestReceiveRawReturns(expectedYAML, ccv3.Warnings{"this is a warning"}, nil) }) It("makes the correct request", func() { @@ -84,7 +84,7 @@ var _ = Describe("Application Manifest", func() { requester.MakeRequestReceiveRawReturns( nil, - Warnings{"this is a warning"}, + ccv3.Warnings{"this is a warning"}, ccerror.MultiError{ResponseCode: http.StatusTeapot, Errors: errors}, ) @@ -117,7 +117,7 @@ var _ = Describe("Application Manifest", func() { rawManifest []byte manifestDiff resources.ManifestDiff - warnings Warnings + warnings ccv3.Warnings executeErr error ) diff --git a/api/cloudcontroller/ccv3/organization_test.go b/api/cloudcontroller/ccv3/organization_test.go index 1b7800dffce..9b698cfc9e9 100644 --- a/api/cloudcontroller/ccv3/organization_test.go +++ b/api/cloudcontroller/ccv3/organization_test.go @@ -6,7 +6,6 @@ import ( "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" - "code.cloudfoundry.org/cli/resources" . "code.cloudfoundry.org/cli/resources" "code.cloudfoundry.org/cli/types" . "github.com/onsi/ginkgo/v2" @@ -23,7 +22,7 @@ var _ = Describe("Organizations", func() { Describe("GetDefaultDomain", func() { var ( - defaultDomain resources.Domain + defaultDomain Domain warnings Warnings executeErr error orgGUID = "some-org-guid" @@ -61,7 +60,7 @@ var _ = Describe("Organizations", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(defaultDomain).To(Equal( - resources.Domain{Name: "domain-name-1", GUID: "domain-guid-1", Internal: types.NullBool{IsSet: true, Value: false}, + Domain{Name: "domain-name-1", GUID: "domain-guid-1", Internal: types.NullBool{IsSet: true, Value: false}, OrganizationGUID: "some-org-guid"}, )) Expect(warnings).To(ConsistOf("this is a warning")) diff --git a/api/cloudcontroller/ccv3/paginated_resources_test.go b/api/cloudcontroller/ccv3/paginated_resources_test.go index debe0ad1626..db69fa471e1 100644 --- a/api/cloudcontroller/ccv3/paginated_resources_test.go +++ b/api/cloudcontroller/ccv3/paginated_resources_test.go @@ -6,7 +6,6 @@ import ( "code.cloudfoundry.org/cli/api/cloudcontroller" . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" "code.cloudfoundry.org/cli/resources" - . "code.cloudfoundry.org/cli/resources" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -199,7 +198,7 @@ var _ = Describe("Paginated Resources", func() { resources.User{GUID: "user-guid-1", Username: "user-name-1", Origin: "uaa"}, )) Expect(page.IncludedResources.Organizations).To(ConsistOf( - Organization{GUID: "org-guid-1", Name: "org-name-1"}, + resources.Organization{GUID: "org-guid-1", Name: "org-name-1"}, )) }) }) diff --git a/api/cloudcontroller/ccv3/requester_test.go b/api/cloudcontroller/ccv3/requester_test.go index c0e493e1cd8..068a9451adf 100644 --- a/api/cloudcontroller/ccv3/requester_test.go +++ b/api/cloudcontroller/ccv3/requester_test.go @@ -12,7 +12,8 @@ import ( . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - "code.cloudfoundry.org/cli/resources" + + // "code.cloudfoundry.org/cli/resources" . "code.cloudfoundry.org/cli/resources" "code.cloudfoundry.org/cli/types" . "github.com/onsi/ginkgo/v2" @@ -320,11 +321,11 @@ var _ = Describe("shared request helpers", func() { Context("PATCH resource", func() { var ( - responseBody resources.Application + responseBody Application ) BeforeEach(func() { - requestBody := resources.Application{ + requestBody := Application{ GUID: "some-app-guid", Name: "some-app-name", StackName: "some-stack-name", @@ -387,7 +388,7 @@ var _ = Describe("shared request helpers", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(warnings).To(ConsistOf("this is a warning")) - Expect(responseBody).To(Equal(resources.Application{ + Expect(responseBody).To(Equal(Application{ GUID: "some-app-guid", StackName: "some-stack-name", LifecycleBuildpacks: []string{"some-buildpack"}, @@ -550,12 +551,12 @@ var _ = Describe("shared request helpers", func() { Context("with query params and included resources", func() { var ( - resourceList []resources.Role + resourceList []Role query []Query ) BeforeEach(func() { - resourceList = []resources.Role{} + resourceList = []Role{} query = []Query{ { Key: OrganizationGUIDFilter, @@ -569,9 +570,9 @@ var _ = Describe("shared request helpers", func() { requestParams = RequestParams{ RequestName: internal.GetRolesRequest, Query: query, - ResponseBody: resources.Role{}, + ResponseBody: Role{}, AppendToList: func(item interface{}) error { - resourceList = append(resourceList, item.(resources.Role)) + resourceList = append(resourceList, item.(Role)) return nil }, } @@ -621,7 +622,7 @@ var _ = Describe("shared request helpers", func() { It("returns the given resources and all warnings", func() { Expect(executeErr).ToNot(HaveOccurred()) Expect(warnings).To(ConsistOf("warning-1", "warning-2")) - Expect(resourceList).To(Equal([]resources.Role{{ + Expect(resourceList).To(Equal([]Role{{ GUID: "role-guid-1", Type: constant.OrgUserRole, }, { @@ -783,7 +784,7 @@ var _ = Describe("shared request helpers", func() { Expect(executeErr).ToNot(HaveOccurred()) Expect(warnings).To(ConsistOf("warning-1", "warning-2")) - Expect(resourceList).To(Equal([]resources.Role{{ + Expect(resourceList).To(Equal([]Role{{ GUID: "role-guid-1", Type: constant.OrgUserRole, UserGUID: "user-guid-1", @@ -794,10 +795,10 @@ var _ = Describe("shared request helpers", func() { }})) Expect(includedResources).To(Equal(IncludedResources{ - Apps: []resources.Application{ + Apps: []Application{ {Name: "app-name-1", GUID: "app-guid-1"}, }, - Users: []resources.User{ + Users: []User{ {GUID: "user-guid-1", Username: "user-name-1", Origin: "uaa"}, {GUID: "user-guid-2", Username: "user-name-2", Origin: "uaa"}, }, @@ -813,7 +814,7 @@ var _ = Describe("shared request helpers", func() { {Name: "broker-name-1", GUID: "broker-guid-1"}, {Name: "broker-name-2", GUID: "broker-guid-2"}, }, - ServiceInstances: []resources.ServiceInstance{ + ServiceInstances: []ServiceInstance{ {Name: "service-instance-name-1", GUID: "service-instance-guid-1"}, {Name: "service-instance-name-2", GUID: "service-instance-guid-2"}, }, @@ -943,12 +944,12 @@ var _ = Describe("shared request helpers", func() { Context("with 'per_page' and 'page' query params", func() { var ( - resourceList []resources.Stack + resourceList []Stack query []Query ) BeforeEach(func() { - resourceList = []resources.Stack{} + resourceList = []Stack{} query = []Query{ { Key: PerPage, @@ -958,9 +959,9 @@ var _ = Describe("shared request helpers", func() { requestParams = RequestParams{ RequestName: internal.GetStacksRequest, Query: query, - ResponseBody: resources.Stack{}, + ResponseBody: Stack{}, AppendToList: func(item interface{}) error { - resourceList = append(resourceList, item.(resources.Stack)) + resourceList = append(resourceList, item.(Stack)) return nil }, } @@ -995,7 +996,7 @@ var _ = Describe("shared request helpers", func() { It("returns only the resources from the specified page", func() { Expect(executeErr).ToNot(HaveOccurred()) - Expect(resourceList).To(Equal([]resources.Stack{{ + Expect(resourceList).To(Equal([]Stack{{ GUID: "stack-guid-1", }})) }) @@ -1028,7 +1029,7 @@ var _ = Describe("shared request helpers", func() { It("returns only the resources from the specified page", func() { Expect(executeErr).ToNot(HaveOccurred()) - Expect(resourceList).To(Equal([]resources.Stack{{ + Expect(resourceList).To(Equal([]Stack{{ GUID: "stack-guid-2", }})) }) diff --git a/api/cloudcontroller/ccv3/space_test.go b/api/cloudcontroller/ccv3/space_test.go index 11b247018d0..07e73f4bd98 100644 --- a/api/cloudcontroller/ccv3/space_test.go +++ b/api/cloudcontroller/ccv3/space_test.go @@ -7,7 +7,7 @@ import ( "code.cloudfoundry.org/cli/api/cloudcontroller/ccerror" . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" - "code.cloudfoundry.org/cli/resources" + . "code.cloudfoundry.org/cli/resources" "code.cloudfoundry.org/cli/types" . "github.com/onsi/ginkgo/v2" @@ -31,7 +31,7 @@ var _ = Describe("Spaces", func() { ) JustBeforeEach(func() { - spaceToCreate = Space{Name: "some-space", Relationships: resources.Relationships{constant.RelationshipTypeOrganization: resources.Relationship{GUID: "some-org-guid"}}} + spaceToCreate = Space{Name: "some-space", Relationships: Relationships{constant.RelationshipTypeOrganization: Relationship{GUID: "some-org-guid"}}} space, warnings, executeErr = client.CreateSpace(spaceToCreate) }) @@ -199,14 +199,14 @@ var _ = Describe("Spaces", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(spaces).To(ConsistOf( - Space{Name: "space-name-1", GUID: "space-guid-1", Relationships: resources.Relationships{ - constant.RelationshipTypeOrganization: resources.Relationship{GUID: "org-guid-1"}, + Space{Name: "space-name-1", GUID: "space-guid-1", Relationships: Relationships{ + constant.RelationshipTypeOrganization: Relationship{GUID: "org-guid-1"}, }}, - Space{Name: "space-name-2", GUID: "space-guid-2", Relationships: resources.Relationships{ - constant.RelationshipTypeOrganization: resources.Relationship{GUID: "org-guid-2"}, + Space{Name: "space-name-2", GUID: "space-guid-2", Relationships: Relationships{ + constant.RelationshipTypeOrganization: Relationship{GUID: "org-guid-2"}, }}, - Space{Name: "space-name-3", GUID: "space-guid-3", Relationships: resources.Relationships{ - constant.RelationshipTypeOrganization: resources.Relationship{GUID: "org-guid-3"}, + Space{Name: "space-name-3", GUID: "space-guid-3", Relationships: Relationships{ + constant.RelationshipTypeOrganization: Relationship{GUID: "org-guid-3"}, }}, )) Expect(warnings).To(ConsistOf("this is a warning", "this is another warning")) @@ -305,14 +305,14 @@ var _ = Describe("Spaces", func() { Expect(warnings).To(ConsistOf("warning-1", "warning-2")) Expect(spaces).To(ConsistOf( - Space{Name: "space-name-1", GUID: "space-guid-1", Relationships: resources.Relationships{ - constant.RelationshipTypeOrganization: resources.Relationship{GUID: "org-guid-1"}, + Space{Name: "space-name-1", GUID: "space-guid-1", Relationships: Relationships{ + constant.RelationshipTypeOrganization: Relationship{GUID: "org-guid-1"}, }}, - Space{Name: "space-name-2", GUID: "space-guid-2", Relationships: resources.Relationships{ - constant.RelationshipTypeOrganization: resources.Relationship{GUID: "org-guid-2"}, + Space{Name: "space-name-2", GUID: "space-guid-2", Relationships: Relationships{ + constant.RelationshipTypeOrganization: Relationship{GUID: "org-guid-2"}, }}, - Space{Name: "space-name-3", GUID: "space-guid-3", Relationships: resources.Relationships{ - constant.RelationshipTypeOrganization: resources.Relationship{GUID: "org-guid-3"}, + Space{Name: "space-name-3", GUID: "space-guid-3", Relationships: Relationships{ + constant.RelationshipTypeOrganization: Relationship{GUID: "org-guid-3"}, }}, )) diff --git a/api/uaa/prompts_test.go b/api/uaa/prompts_test.go index 117a12586e6..1624c51c4b8 100644 --- a/api/uaa/prompts_test.go +++ b/api/uaa/prompts_test.go @@ -4,7 +4,6 @@ import ( "net/http" "code.cloudfoundry.org/cli/api/uaa" - . "code.cloudfoundry.org/cli/api/uaa" "code.cloudfoundry.org/cli/api/uaa/uaafakes" . "github.com/onsi/ginkgo/v2" @@ -14,13 +13,13 @@ import ( var _ = Describe("Prompts", func() { var ( - client *Client + client *uaa.Client fakeConfig *uaafakes.FakeConfig ) BeforeEach(func() { fakeConfig = NewTestConfig() - client = NewClient(fakeConfig) + client = uaa.NewClient(fakeConfig) client.Info.Links.Login = "https://" + TestAuthorizationResource }) diff --git a/api/uaa/version_test.go b/api/uaa/version_test.go index 780bd814ca5..c87374a4536 100644 --- a/api/uaa/version_test.go +++ b/api/uaa/version_test.go @@ -4,7 +4,6 @@ import ( "net/http" "code.cloudfoundry.org/cli/api/uaa" - . "code.cloudfoundry.org/cli/api/uaa" "code.cloudfoundry.org/cli/api/uaa/uaafakes" . "github.com/onsi/ginkgo/v2" @@ -14,13 +13,13 @@ import ( var _ = Describe("Version", func() { var ( - client *Client + client *uaa.Client fakeConfig *uaafakes.FakeConfig ) BeforeEach(func() { fakeConfig = NewTestConfig() - client = NewClient(fakeConfig) + client = uaa.NewClient(fakeConfig) client.Info.Links.Login = "https://" + TestAuthorizationResource }) diff --git a/command/v7/config_command_test.go b/command/v7/config_command_test.go index dcc61aa6e88..cec2f52d112 100644 --- a/command/v7/config_command_test.go +++ b/command/v7/config_command_test.go @@ -4,7 +4,6 @@ import ( "code.cloudfoundry.org/cli/command/commandfakes" "code.cloudfoundry.org/cli/command/flag" "code.cloudfoundry.org/cli/command/translatableerror" - . "code.cloudfoundry.org/cli/command/v7" v7 "code.cloudfoundry.org/cli/command/v7" "code.cloudfoundry.org/cli/types" "code.cloudfoundry.org/cli/util/ui" @@ -25,7 +24,7 @@ var _ = Describe("ConfigCommand", func() { testUI = ui.NewTestUI(nil, NewBuffer(), NewBuffer()) fakeConfig = new(commandfakes.FakeConfig) - cmd = ConfigCommand{ + cmd = v7.ConfigCommand{ UI: testUI, Config: fakeConfig, } diff --git a/command/v7/logs_command_test.go b/command/v7/logs_command_test.go index 61cf0121764..36072ca8cee 100644 --- a/command/v7/logs_command_test.go +++ b/command/v7/logs_command_test.go @@ -326,7 +326,6 @@ var _ = Describe("logs command", func() { time.Sleep(100 * time.Millisecond) close(logStream) close(errorStream) - return }() return logStream, errorStream, func() {}, v7action.Warnings{}, nil diff --git a/command/v7/revisions_command_test.go b/command/v7/revisions_command_test.go index 6af5b8ff3d9..d426c07de5d 100644 --- a/command/v7/revisions_command_test.go +++ b/command/v7/revisions_command_test.go @@ -8,7 +8,6 @@ import ( "code.cloudfoundry.org/cli/actor/v7action" "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" v7 "code.cloudfoundry.org/cli/command/v7" "code.cloudfoundry.org/cli/command/v7/v7fakes" "code.cloudfoundry.org/cli/resources" @@ -21,7 +20,7 @@ import ( var _ = Describe("revisions Command", func() { var ( - cmd RevisionsCommand + cmd v7.RevisionsCommand testUI *ui.UI fakeConfig *commandfakes.FakeConfig fakeSharedActor *commandfakes.FakeSharedActor diff --git a/command/v7/ssh_code_command_test.go b/command/v7/ssh_code_command_test.go index 46dcf5fe599..ab4f9532514 100644 --- a/command/v7/ssh_code_command_test.go +++ b/command/v7/ssh_code_command_test.go @@ -5,7 +5,7 @@ import ( "code.cloudfoundry.org/cli/actor/actionerror" "code.cloudfoundry.org/cli/command/commandfakes" - . "code.cloudfoundry.org/cli/command/v7" + v7 "code.cloudfoundry.org/cli/command/v7" "code.cloudfoundry.org/cli/command/v7/v7fakes" "code.cloudfoundry.org/cli/util/ui" @@ -16,7 +16,7 @@ import ( var _ = Describe("ssh-code Command", func() { var ( - cmd SSHCodeCommand + cmd v7.SSHCodeCommand testUI *ui.UI fakeConfig *commandfakes.FakeConfig fakeSharedActor *commandfakes.FakeSharedActor diff --git a/util/configv3/json_config_test.go b/util/configv3/json_config_test.go index 236579b4280..3e61e1b0665 100644 --- a/util/configv3/json_config_test.go +++ b/util/configv3/json_config_test.go @@ -4,7 +4,6 @@ import ( "fmt" "time" - "code.cloudfoundry.org/cli/util/configv3" . "code.cloudfoundry.org/cli/util/configv3" . "github.com/onsi/ginkgo/v2" @@ -513,7 +512,7 @@ var _ = Describe("JSONConfig", func() { }) Describe("CurrentUser", func() { - var user configv3.User + var user User JustBeforeEach(func() { user, err = config.CurrentUser() diff --git a/util/configv3/load_config_test.go b/util/configv3/load_config_test.go index b8321eea92f..cd70b9679a6 100644 --- a/util/configv3/load_config_test.go +++ b/util/configv3/load_config_test.go @@ -8,7 +8,8 @@ import ( "code.cloudfoundry.org/cli/command/translatableerror" "code.cloudfoundry.org/cli/integration/helpers" - "code.cloudfoundry.org/cli/util/configv3" + + // "code.cloudfoundry.org/cli/util/configv3" . "code.cloudfoundry.org/cli/util/configv3" . "github.com/onsi/ginkgo/v2" @@ -113,7 +114,7 @@ var _ = Describe("Config", func() { Expect(config.ConfigFile).To(Equal( JSONConfig{ ColorEnabled: DefaultColorEnabled, - ConfigVersion: configv3.CurrentConfigVersion, + ConfigVersion: CurrentConfigVersion, SSHOAuthClient: DefaultSSHOAuthClient, UAAOAuthClient: DefaultUAAOAuthClient, UAAOAuthClientSecret: DefaultUAAOAuthClientSecret, @@ -153,7 +154,7 @@ var _ = Describe("Config", func() { Expect(config.ConfigFile).To(Equal( JSONConfig{ ColorEnabled: DefaultColorEnabled, - ConfigVersion: configv3.CurrentConfigVersion, + ConfigVersion: CurrentConfigVersion, SSHOAuthClient: DefaultSSHOAuthClient, UAAOAuthClient: DefaultUAAOAuthClient, UAAOAuthClientSecret: DefaultUAAOAuthClientSecret, @@ -199,7 +200,7 @@ var _ = Describe("Config", func() { { "UAAOAuthClient": "", "ConfigVersion": %d - }`, configv3.CurrentConfigVersion+1) + }`, CurrentConfigVersion+1) setConfig(homeDir, rawConfig) }) @@ -221,11 +222,11 @@ var _ = Describe("Config", func() { { "AccessToken": "bearer shazbat!", "ConfigVersion": %d - }`, configv3.CurrentConfigVersion-1) + }`, CurrentConfigVersion-1) setConfig(homeDir, rawConfig) config := helpers.GetConfig() Expect(loadErr).ToNot(HaveOccurred()) - Expect(config.ConfigFile.ConfigVersion).To(Equal(configv3.CurrentConfigVersion)) + Expect(config.ConfigFile.ConfigVersion).To(Equal(CurrentConfigVersion)) Expect(config.ConfigFile.AccessToken).To(Equal("")) }) }) @@ -236,11 +237,11 @@ var _ = Describe("Config", func() { { "AccessToken": "bearer shazbat!", "ConfigVersion": %d - }`, configv3.CurrentConfigVersion) + }`, CurrentConfigVersion) setConfig(homeDir, rawConfig) config := helpers.GetConfig() Expect(loadErr).ToNot(HaveOccurred()) - Expect(config.ConfigFile.ConfigVersion).To(Equal(configv3.CurrentConfigVersion)) + Expect(config.ConfigFile.ConfigVersion).To(Equal(CurrentConfigVersion)) Expect(config.ConfigFile.AccessToken).To(Equal("bearer shazbat!")) }) }) @@ -251,11 +252,11 @@ var _ = Describe("Config", func() { { "AccessToken": "bearer shazbat!", "ConfigVersion": %d - }`, configv3.CurrentConfigVersion+1) + }`, CurrentConfigVersion+1) setConfig(homeDir, rawConfig) config := helpers.GetConfig() Expect(loadErr).ToNot(HaveOccurred()) - Expect(config.ConfigFile.ConfigVersion).To(Equal(configv3.CurrentConfigVersion)) + Expect(config.ConfigFile.ConfigVersion).To(Equal(CurrentConfigVersion)) Expect(config.ConfigFile.AccessToken).To(Equal("")) }) }) diff --git a/util/randomword/generator_test.go b/util/randomword/generator_test.go index 944d4abe51d..7f69671f3ae 100644 --- a/util/randomword/generator_test.go +++ b/util/randomword/generator_test.go @@ -8,7 +8,7 @@ import ( ) var _ = Describe("Generator", func() { - var gen Generator = NewGenerator() + gen := NewGenerator() Describe("RandomAdjective", func() { It("generates a random adjective each time it is called", func() { diff --git a/util/ui/prompt.go b/util/ui/prompt.go index b196ae51898..4049750bfaf 100644 --- a/util/ui/prompt.go +++ b/util/ui/prompt.go @@ -94,7 +94,7 @@ func (ui *UI) DisplayTextMenu(choices []string, promptTemplate string, templateV interactivePrompt.SetIn(ui.In) interactivePrompt.SetOut(ui.OutForInteraction) - var value string = "enter to skip" + value := "enter to skip" err := interactivePrompt.Resolve(&value) if isInterrupt(err) { From a8ff3582a5f626fe038830026e549e49d97e1c30 Mon Sep 17 00:00:00 2001 From: Shwetha Gururaj Date: Wed, 24 Sep 2025 10:35:04 -0400 Subject: [PATCH 2/3] PR review fixes --- .github/workflows/golangci-lint.yml | 1 + .golangci.json | 6 +++--- Makefile | 2 +- api/cloudcontroller/ccv3/requester_test.go | 1 - util/configv3/load_config_test.go | 1 - 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 3a05765725a..0c9d517d178 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -34,6 +34,7 @@ jobs: uses: golangci/golangci-lint-action@v8 with: version: v2.4 + args: -v format: name: Run go fmt runs-on: ubuntu-latest diff --git a/.golangci.json b/.golangci.json index 18d18b4b6e7..cc83ebbe9f4 100644 --- a/.golangci.json +++ b/.golangci.json @@ -65,9 +65,9 @@ "third_party$", "builtin$", "examples$", - "cf", - "fixtures", - "plugin" + "cf$", + "fixtures$", + "plugin$" ], "presets": [ "comments", diff --git a/Makefile b/Makefile index 01c7522e8c7..5628e691299 100644 --- a/Makefile +++ b/Makefile @@ -147,7 +147,7 @@ integration-tests-full-ci: install-test-deps integration-cleanup lint: format ## Runs all linters and formatters @echo "Running linters..." - golangci-lint run + golangci-lint run -v @echo "No lint errors!" # TODO: version specific tagging for all these builds diff --git a/api/cloudcontroller/ccv3/requester_test.go b/api/cloudcontroller/ccv3/requester_test.go index 068a9451adf..533df95b43f 100644 --- a/api/cloudcontroller/ccv3/requester_test.go +++ b/api/cloudcontroller/ccv3/requester_test.go @@ -13,7 +13,6 @@ import ( "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" - // "code.cloudfoundry.org/cli/resources" . "code.cloudfoundry.org/cli/resources" "code.cloudfoundry.org/cli/types" . "github.com/onsi/ginkgo/v2" diff --git a/util/configv3/load_config_test.go b/util/configv3/load_config_test.go index cd70b9679a6..59535f84496 100644 --- a/util/configv3/load_config_test.go +++ b/util/configv3/load_config_test.go @@ -9,7 +9,6 @@ import ( "code.cloudfoundry.org/cli/command/translatableerror" "code.cloudfoundry.org/cli/integration/helpers" - // "code.cloudfoundry.org/cli/util/configv3" . "code.cloudfoundry.org/cli/util/configv3" . "github.com/onsi/ginkgo/v2" From 3ac01be22e4db71f5dbc9d71d768092186f3cac8 Mon Sep 17 00:00:00 2001 From: Shwetha Gururaj Date: Fri, 26 Sep 2025 10:11:16 -0400 Subject: [PATCH 3/3] PR review changes --- .golangci.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.golangci.json b/.golangci.json index cc83ebbe9f4..9836e7d9434 100644 --- a/.golangci.json +++ b/.golangci.json @@ -11,9 +11,9 @@ "third_party$", "builtin$", "examples$", - "cf", - "fixtures", - "plugin" + "cf$", + "fixtures$", + "plugin$" ] } }, @@ -124,7 +124,8 @@ } }, "run": { - "concurrency": 4 + "concurrency": 4, + "timeout": "60m" }, "version": "2" }