Skip to content

Commit e406e84

Browse files
Updating the golangci-lint to v2 (#479)
* Updating the golangci-lint to v2 Signed-off-by: Vishesh Tanksale <vtanksale@nvidia.com> * Adding linter config Signed-off-by: Vishesh Tanksale <vtanksale@nvidia.com> --------- Signed-off-by: Vishesh Tanksale <vtanksale@nvidia.com>
1 parent bb52461 commit e406e84

60 files changed

Lines changed: 1710 additions & 1528 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.golangci.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: "2"
2+
run:
3+
tests: true
4+
linters:
5+
enable:
6+
- asciicheck
7+
- contextcheck
8+
- forcetypeassert
9+
- gocritic
10+
- godot
11+
- misspell
12+
- staticcheck
13+
exclusions:
14+
generated: lax
15+
presets:
16+
- comments
17+
- common-false-positives
18+
- legacy
19+
- std-error-handling
20+
paths:
21+
- third_party$
22+
- builtin$
23+
- examples$
24+
formatters:
25+
enable:
26+
- gofmt
27+
- goimports
28+
settings:
29+
goimports:
30+
local-prefixes:
31+
- github.com/NVIDIA/k8s-nim-operator
32+
exclusions:
33+
generated: lax
34+
paths:
35+
- third_party$
36+
- builtin$
37+
- examples$

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ test-e2e:
130130

131131
.PHONY: lint
132132
lint: golangci-lint
133-
$(GOLANGCI_LINT) run ./...
133+
$(GOLANGCI_LINT) config path
134+
$(GOLANGCI_LINT) run -v
134135

135136
.PHONY: lint-fix
136137
lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
@@ -222,7 +223,7 @@ GINKGO_VERSION ?= $(shell $(GO_CMD) list -m -f '{{.Version}}' github.com/onsi/gi
222223
KUSTOMIZE_VERSION ?= $(shell cd $(PROJECT_DIR)/deployments/devel; $(GO_CMD) list -m -f '{{.Version}}' sigs.k8s.io/kustomize/kustomize/v5)
223224
CONTROLLER_TOOLS_VERSION ?= $(shell cd $(PROJECT_DIR)/deployments/devel; $(GO_CMD) list -m -f '{{.Version}}' sigs.k8s.io/controller-tools)
224225
ENVTEST_VERSION ?= $(shell cd $(PROJECT_DIR)/deployments/devel; $(GO_CMD) list -m -f '{{.Version}}' sigs.k8s.io/controller-runtime/tools/setup-envtest)
225-
GOLANGCI_LINT_VERSION ?= $(shell cd $(PROJECT_DIR)/deployments/devel; $(GO_CMD) list -m -f '{{.Version}}' github.com/golangci/golangci-lint)
226+
GOLANGCI_LINT_VERSION ?= $(shell cd $(PROJECT_DIR)/deployments/devel; $(GO_CMD) list -m -f '{{.Version}}' github.com/golangci/golangci-lint/v2)
226227

227228
.PHONY: kustomize
228229
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
@@ -242,7 +243,7 @@ $(ENVTEST): $(LOCALBIN)
242243
.PHONY: golangci-lint
243244
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
244245
$(GOLANGCI_LINT): $(LOCALBIN)
245-
@GOBIN=$(PROJECT_DIR)/bin GO111MODULE=on $(GO_CMD) install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
246+
@GOBIN=$(PROJECT_DIR)/bin GO111MODULE=on $(GO_CMD) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
246247

247248
GINKGO = $(PROJECT_DIR)/bin/ginkgo
248249
.PHONY: ginkgo

api/apps/v1alpha1/common_types.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ import (
2525
)
2626

2727
const (
28-
// DefaultAPIPort is the default api port
28+
// DefaultAPIPort is the default api port.
2929
DefaultAPIPort = 8000
30-
// DefaultNamedPortAPI is the default name for api port
30+
// DefaultNamedPortAPI is the default name for api port.
3131
DefaultNamedPortAPI = "api"
3232
)
3333

34-
// Expose defines attributes to expose the service
34+
// Expose defines attributes to expose the service.
3535
type Expose struct {
3636
Service Service `json:"service,omitempty"`
3737
Ingress Ingress `json:"ingress,omitempty"`
3838
}
3939

40-
// Service defines attributes to create a service
40+
// Service defines attributes to create a service.
4141
type Service struct {
4242
Type corev1.ServiceType `json:"type,omitempty"`
4343
// override the default service name
@@ -50,51 +50,51 @@ type Service struct {
5050
Annotations map[string]string `json:"annotations,omitempty"`
5151
}
5252

53-
// ExposeV1 defines attributes to expose the service
53+
// ExposeV1 defines attributes to expose the service.
5454
type ExposeV1 struct {
5555
Service Service `json:"service,omitempty"`
5656
Ingress IngressV1 `json:"ingress,omitempty"`
5757
}
5858

59-
// Metrics defines attributes to setup metrics collection
59+
// Metrics defines attributes to setup metrics collection.
6060
type Metrics struct {
6161
Enabled *bool `json:"enabled,omitempty"`
6262
// for use with the Prometheus Operator and the primary service object
6363
ServiceMonitor ServiceMonitor `json:"serviceMonitor,omitempty"`
6464
}
6565

66-
// ServiceMonitor defines attributes to create a service monitor
66+
// ServiceMonitor defines attributes to create a service monitor.
6767
type ServiceMonitor struct {
6868
AdditionalLabels map[string]string `json:"additionalLabels,omitempty"`
6969
Annotations map[string]string `json:"annotations,omitempty"`
7070
Interval promv1.Duration `json:"interval,omitempty"`
7171
ScrapeTimeout promv1.Duration `json:"scrapeTimeout,omitempty"`
7272
}
7373

74-
// Autoscaling defines attributes to automatically scale the service based on metrics
74+
// Autoscaling defines attributes to automatically scale the service based on metrics.
7575
type Autoscaling struct {
7676
Enabled *bool `json:"enabled,omitempty"`
7777
HPA HorizontalPodAutoscalerSpec `json:"hpa,omitempty"`
7878
Annotations map[string]string `json:"annotations,omitempty"`
7979
}
8080

81-
// HorizontalPodAutoscalerSpec defines the parameters required to setup HPA
81+
// HorizontalPodAutoscalerSpec defines the parameters required to setup HPA.
8282
type HorizontalPodAutoscalerSpec struct {
8383
MinReplicas *int32 `json:"minReplicas,omitempty"`
8484
MaxReplicas int32 `json:"maxReplicas"`
8585
Metrics []autoscalingv2.MetricSpec `json:"metrics,omitempty"`
8686
Behavior *autoscalingv2.HorizontalPodAutoscalerBehavior `json:"behavior,omitempty" `
8787
}
8888

89-
// Image defines image attributes
89+
// Image defines image attributes.
9090
type Image struct {
9191
Repository string `json:"repository"`
9292
PullPolicy string `json:"pullPolicy,omitempty"`
9393
Tag string `json:"tag"`
9494
PullSecrets []string `json:"pullSecrets,omitempty"`
9595
}
9696

97-
// Ingress defines attributes to enable ingress for the service
97+
// Ingress defines attributes to enable ingress for the service.
9898
type Ingress struct {
9999
// ingress, or virtualService - not both
100100
Enabled *bool `json:"enabled,omitempty"`
@@ -160,15 +160,15 @@ type IngressSpec struct {
160160
Paths []IngressPath `json:"paths,omitempty"`
161161
}
162162

163-
// IngressPath defines attributes for ingress paths
163+
// IngressPath defines attributes for ingress paths.
164164
type IngressPath struct {
165165
// +kubebuilder:default="/"
166166
Path string `json:"path,omitempty"`
167167
// +kubebuilder:default=Prefix
168168
PathType *networkingv1.PathType `json:"pathType,omitempty"`
169169
}
170170

171-
// Probe defines attributes for startup/liveness/readiness probes
171+
// Probe defines attributes for startup/liveness/readiness probes.
172172
type Probe struct {
173173
Enabled *bool `json:"enabled,omitempty"`
174174
Probe *corev1.Probe `json:"probe,omitempty"`
@@ -182,7 +182,7 @@ type CertConfig struct {
182182
MountPath string `json:"mountPath"`
183183
}
184184

185-
// ProxySpec defines the proxy configuration for NIMService
185+
// ProxySpec defines the proxy configuration for NIMService.
186186
type ProxySpec struct {
187187
HttpProxy string `json:"httpProxy,omitempty"`
188188
HttpsProxy string `json:"httpsProxy,omitempty"`

api/apps/v1alpha1/groupversion_info.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ import (
2525
)
2626

2727
var (
28-
// SchemeGroupVersion is group version used to register these objects
28+
// SchemeGroupVersion is group version used to register these objects.
2929
SchemeGroupVersion = schema.GroupVersion{Group: "apps.nvidia.com", Version: "v1alpha1"}
3030

31-
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
3232
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
3333

3434
// AddToScheme adds the types in this group-version to the given scheme.

api/apps/v1alpha1/nemo_common_types.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,43 +16,43 @@ limitations under the License.
1616

1717
package v1alpha1
1818

19-
// ArgoWorkflows defines configuration to connect to Argo Workflows service
19+
// ArgoWorkflows defines configuration to connect to Argo Workflows service.
2020
type ArgoWorkflows struct {
2121
// +kubebuilder:validation:Pattern=`^http`
2222
// +kubebuilder:validation:MinLength=1
2323
Endpoint string `json:"endpoint"`
2424
ServiceAccount string `json:"serviceAccount"`
2525
}
2626

27-
// VectorDB defines the configuration for connecting to the external VectorDB
27+
// VectorDB defines the configuration for connecting to the external VectorDB.
2828
type VectorDB struct {
2929
// +kubebuilder:validation:Pattern=`^http`
3030
// +kubebuilder:validation:MinLength=1
3131
Endpoint string `json:"endpoint"`
3232
}
3333

34-
// Datastore defines the configuration for connecting to the NeMo Datastore service
34+
// Datastore defines the configuration for connecting to the NeMo Datastore service.
3535
type Datastore struct {
3636
// +kubebuilder:validation:Pattern=`^http`
3737
// +kubebuilder:validation:MinLength=1
3838
Endpoint string `json:"endpoint"`
3939
}
4040

41-
// Entitystore defines the configuration for connecting to the NeMo EntityStore service
41+
// Entitystore defines the configuration for connecting to the NeMo EntityStore service.
4242
type Entitystore struct {
4343
// +kubebuilder:validation:Pattern=`^http`
4444
// +kubebuilder:validation:MinLength=1
4545
Endpoint string `json:"endpoint"`
4646
}
4747

48-
// MLFlow defines the configuration for connecting to the MLFlow tracking service
48+
// MLFlow defines the configuration for connecting to the MLFlow tracking service.
4949
type MLFlow struct {
5050
// +kubebuilder:validation:Pattern=`^http`
5151
// +kubebuilder:validation:MinLength=1
5252
Endpoint string `json:"endpoint"`
5353
}
5454

55-
// DatabaseConfig is the external database configuration
55+
// DatabaseConfig is the external database configuration.
5656
type DatabaseConfig struct {
5757
// Host is the hostname of the database.
5858
// Required, must not be empty.
@@ -78,7 +78,7 @@ type DatabaseConfig struct {
7878
Credentials DatabaseCredentials `json:"credentials"`
7979
}
8080

81-
// DatabaseCredentials are the external database credentials
81+
// DatabaseCredentials are the external database credentials.
8282
type DatabaseCredentials struct {
8383
// User is the non-root username for a NEMO Service in the database.
8484
// Required, must not be empty.
@@ -130,7 +130,7 @@ type WandBConfig struct {
130130
Project string `json:"projectName,omitempty"`
131131
}
132132

133-
// OTelSpec defines the settings for OpenTelemetry
133+
// OTelSpec defines the settings for OpenTelemetry.
134134
type OTelSpec struct {
135135
// Enabled indicates if opentelemetry collector and tracing are enabled
136136
Enabled *bool `json:"enabled,omitempty"`
@@ -159,7 +159,7 @@ type OTelSpec struct {
159159
LogLevel string `json:"logLevel,omitempty"`
160160
}
161161

162-
// ExporterConfig stores configuration for different OTel exporters
162+
// ExporterConfig stores configuration for different OTel exporters.
163163
type ExporterConfig struct {
164164
// TracesExporter sets the traces exporter: (otlp, console, none).
165165
// +kubebuilder:validation:Optional
@@ -180,7 +180,7 @@ type ExporterConfig struct {
180180
LogsExporter string `json:"logsExporter,omitempty"`
181181
}
182182

183-
// ConfigMapRef with a valid config map name
183+
// ConfigMapRef with a valid config map name.
184184
type ConfigMapRef struct {
185185
// +kubebuilder:validation:MinLength=1
186186
Name string `json:"name"`

0 commit comments

Comments
 (0)