New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
task: validate import alias via importas #2804
Changes from 1 commit
6b0545c
12651f0
beb7321
a60fabd
d0f0b25
d7a5abd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,45 @@ linters-settings: | |
min-occurrences: 2 | ||
gocyclo: | ||
min-complexity: 15 | ||
govet: | ||
check-shadowing: true | ||
maligned: | ||
suggest-new: true | ||
importas: | ||
no-extra-aliases: true | ||
alias: | ||
- pkg: go.mongodb.org/atlas-sdk/v[\d]+/admin | ||
alias: atlasv2 | ||
- pkg: go.mongodb.org/atlas/mongodbatlas | ||
alias: atlas | ||
- pkg: go.mongodb.org/atlas/auth | ||
alias: atlasauth | ||
- pkg: github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/api/v1 | ||
alias: akov2 | ||
- pkg: github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/api/v1/common | ||
alias: akov2common | ||
- pkg: github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/api/v1/provider | ||
alias: akov2provider | ||
- pkg: github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/api/v1/status | ||
alias: akov2status | ||
- pkg: github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/api/v1/project | ||
alias: akov2project | ||
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1 | ||
alias: apisv1 | ||
- pkg: k8s.io/api/apps/v1 | ||
alias: appsv1 | ||
- pkg: k8s.io/api/core/v1 | ||
alias: corev1 | ||
- pkg: k8s.io/api/rbac/v1 | ||
alias: rbacv1 | ||
- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1 | ||
alias: apiextensionsv1 | ||
- pkg: k8s.io/apiserver/pkg/storage/names | ||
alias: k8snames | ||
- pkg: github.com/AlecAivazis/survey/v2/core | ||
alias: survey | ||
- pkg: github.com/creack/pty | ||
alias: pseudotty | ||
- pkg: cloud.google.com/go/kms/apiv1 | ||
alias: kmsv1 | ||
- pkg: github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/config | ||
alias: cliconfig | ||
misspell: | ||
locale: US | ||
ignore-words: | ||
|
@@ -59,8 +94,6 @@ linters-settings: | |
sections: | ||
- standard | ||
- default | ||
section-separators: | ||
- newLine | ||
Comment on lines
-62
to
-63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. invalid config |
||
linters: | ||
disable-all: true | ||
enable: | ||
|
@@ -83,6 +116,7 @@ linters: | |
- gosimple # (megacheck) Linter for Go source code that specializes in simplifying code [fast: false, auto-fix: false] | ||
- govet # (vet, vetshadow) Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: false, auto-fix: false] | ||
- ineffassign # Detects when assignments to existing variables are not used [fast: true, auto-fix: false] | ||
- importas # Enforces consistent import aliases [fast: false, auto-fix: false] | ||
- makezero # Finds slice declarations with non-zero initial length [fast: false, auto-fix: false] | ||
- misspell # Finds commonly misspelled English words in comments [fast: true, auto-fix: true] | ||
- nakedret # Finds naked returns in functions greater than a specified function length [fast: true, auto-fix: false] | ||
|
@@ -138,7 +172,6 @@ linters: | |
# - gomodguard # Allow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations. [fast: true, auto-fix: false] | ||
# - grouper # An analyzer to analyze expression groups. [fast: true, auto-fix: false] | ||
# - ifshort # [deprecated] Checks that your code uses short syntax for if-statements whenever possible [fast: true, auto-fix: false] | ||
# - importas # Enforces consistent import aliases [fast: false, auto-fix: false] | ||
# - interfacebloat # A linter that checks the number of methods inside an interface. [fast: true, auto-fix: false] | ||
# - interfacer # [deprecated]: Linter that suggests narrower interface types [fast: false, auto-fix: false] | ||
# - ireturn # Accept Interfaces, Return Concrete Types [fast: false, auto-fix: false] | ||
|
@@ -174,8 +207,6 @@ run: | |
- e2e | ||
- unit | ||
- integration | ||
skip-dirs: | ||
- internal/mocks | ||
Comment on lines
-177
to
-178
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. invalid config |
||
modules-download-mode: readonly | ||
|
||
issues: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ import ( | |
akov2common "github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/api/v1/common" | ||
akov2status "github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/api/v1/status" | ||
"go.mongodb.org/atlas-sdk/v20231115008/admin" | ||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
apisv1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: this is not idiomatic in kube upstream, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
) | ||
|
||
const ( | ||
|
@@ -41,11 +41,11 @@ func BuildAtlasDataFederation(dataFederationStore store.DataFederationStore, dat | |
return nil, nil | ||
} | ||
atlasDataFederation := &akov2.AtlasDataFederation{ | ||
TypeMeta: v1.TypeMeta{ | ||
TypeMeta: apisv1.TypeMeta{ | ||
APIVersion: "atlas.mongodb.com/v1", | ||
Kind: "AtlasDataFederation", | ||
}, | ||
ObjectMeta: v1.ObjectMeta{ | ||
ObjectMeta: apisv1.ObjectMeta{ | ||
Name: resources.NormalizeAtlasName(fmt.Sprintf("%s-%s", projectName, dataFederation.GetName()), dictionary), | ||
Namespace: targetNamespace, | ||
Labels: map[string]string{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ import ( | |
akov2common "github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/api/v1/common" | ||
akov2status "github.com/mongodb/mongodb-atlas-kubernetes/v2/pkg/api/v1/status" | ||
"go.mongodb.org/atlas-sdk/v20231115008/admin" | ||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
apisv1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
) | ||
|
||
const ( | ||
|
@@ -113,11 +113,11 @@ func Test_BuildAtlasDataFederation(t *testing.T) { | |
dataFederationStore.EXPECT().DataFederation(projectID, dataFederationName).Return(dataFederation, nil) | ||
|
||
expected := &akov2.AtlasDataFederation{ | ||
TypeMeta: v1.TypeMeta{ | ||
TypeMeta: apisv1.TypeMeta{ | ||
Kind: "AtlasDataFederation", | ||
APIVersion: "atlas.mongodb.com/v1", | ||
}, | ||
ObjectMeta: v1.ObjectMeta{ | ||
ObjectMeta: apisv1.ObjectMeta{ | ||
Name: resources.NormalizeAtlasName(fmt.Sprintf("%s-%s", projectName, dataFederation.GetName()), dictionary), | ||
Namespace: targetNamespace, | ||
Labels: map[string]string{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invalid configs