Skip to content

Commit

Permalink
[CONTINT-4412] Upgrade k8s dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
L3n41c committed Oct 7, 2024
1 parent 272d0da commit 792f6d0
Show file tree
Hide file tree
Showing 15 changed files with 343 additions and 1,576 deletions.
27 changes: 13 additions & 14 deletions .golangci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
[linters-settings]

[linters-settings.govet]
check-shadowing = true
enable = [
"shadow"
]

[linters-settings.gocyclo]
min-complexity = 12.0
Expand All @@ -20,19 +22,22 @@
[linters-settings.misspell]
locale = "US"

[linters-settings.errcheck]
exclude-functions = [
"fmt.Fprint",
"fmt.Fprintf"
]

[linters]
enable-all = true
disable = [
"exhaustruct",
"nosnakecase",
"logrlint",
"loggercheck",
"nonamedreturns",
"maligned",
"revive",
"lll",
"gas",
"gosec",
"dupl",
"scopelint",
"gocyclo",
"gochecknoinits",
"gochecknoglobals",
Expand All @@ -41,16 +46,14 @@
"cyclop",
"gomnd",
"wrapcheck",
"exhaustivestruct",
"forcetypeassert",
"goerr113",
"err113",
"testpackage",
"wastedassign",
"thelper",
"paralleltest",
"nestif",
"exhaustive",
"interfacer",
"gci",
"wsl",
"godox",
Expand All @@ -63,20 +66,16 @@
"nilnil",
"ireturn",
"maintidx",
"ifshort",
"gocritic",
"errchkjson",
"gofumpt",
"golint",
"gomoddirectives",
"prealloc",
"structcheck",
"deadcode",
"varcheck",
"rowserrcheck",
"sqlclosecheck",
"depguard",
"perfsprint",
"mnd",
]

[issues]
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ docker-buildx-ci:
##@ Tools
CONTROLLER_GEN = bin/$(PLATFORM)/controller-gen
$(CONTROLLER_GEN): Makefile ## Download controller-gen locally if necessary.
$(call go-get-tool,$@,sigs.k8s.io/controller-tools/cmd/controller-gen@v0.6.1)
$(call go-get-tool,$@,sigs.k8s.io/controller-tools/cmd/controller-gen@v0.16.3)

KUSTOMIZE = bin/$(PLATFORM)/kustomize
$(KUSTOMIZE): Makefile ## Download kustomize locally if necessary.
Expand Down Expand Up @@ -183,7 +183,7 @@ install-tools: bin/$(PLATFORM)/golangci-lint bin/$(PLATFORM)/operator-sdk bin/$(

.PHONY: generate-openapi
generate-openapi: bin/$(PLATFORM)/openapi-gen
bin/$(PLATFORM)/openapi-gen --logtostderr=true -o "" -i ./apis/datadoghq/v1alpha1 -O zz_generated.openapi -p ./apis/datadoghq/v1alpha1 -h ./hack/boilerplate.go.txt -r "-"
bin/$(PLATFORM)/openapi-gen --logtostderr --output-dir apis/datadoghq/v1alpha1 --output-file zz_generated.openapi.go --output-pkg apis/datadoghq/v1alpha1 --go-header-file ./hack/boilerplate.go.txt

.PHONY: patch-crds
patch-crds: bin/$(PLATFORM)/yq
Expand Down Expand Up @@ -214,7 +214,7 @@ bin/$(PLATFORM)/jq: Makefile
hack/install-jq.sh "bin/$(PLATFORM)" 1.7.1

bin/$(PLATFORM)/golangci-lint: Makefile
hack/install-golangci-lint.sh -b "bin/$(PLATFORM)" v1.56.0
hack/install-golangci-lint.sh -b "bin/$(PLATFORM)" v1.61.0

bin/$(PLATFORM)/operator-sdk: Makefile
hack/install-operator-sdk.sh v1.23.0
Expand Down
24 changes: 8 additions & 16 deletions apis/datadoghq/v1alpha1/watermarkpodautoscaler_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,10 @@ func IsDefaultWatermarkPodAutoscaler(wpa *WatermarkPodAutoscaler) bool {
// return nil if valid, else an error
func CheckWPAValidity(wpa *WatermarkPodAutoscaler) error {
if wpa.Spec.ScaleTargetRef.Kind == "" || wpa.Spec.ScaleTargetRef.Name == "" {
msg := fmt.Sprintf("the Spec.ScaleTargetRef should be populated, currently Kind:%s and/or Name:%s are not set properly", wpa.Spec.ScaleTargetRef.Kind, wpa.Spec.ScaleTargetRef.Name)
return fmt.Errorf(msg)
return fmt.Errorf("the Spec.ScaleTargetRef should be populated, currently Kind:%s and/or Name:%s are not set properly", wpa.Spec.ScaleTargetRef.Kind, wpa.Spec.ScaleTargetRef.Name)
}
if wpa.Spec.MinReplicas == nil || wpa.Spec.MaxReplicas < *wpa.Spec.MinReplicas {
msg := "watermark pod autoscaler requires the minimum number of replicas to be configured and inferior to the maximum"
return fmt.Errorf(msg)
return fmt.Errorf("watermark pod autoscaler requires the minimum number of replicas to be configured and inferior to the maximum")
}
if wpa.Spec.Tolerance.MilliValue() > 1000 || wpa.Spec.Tolerance.MilliValue() < 0 {
return fmt.Errorf("tolerance should be set as a quantity between 0 and 1, currently set to : %v, which is %.0f%%", wpa.Spec.Tolerance.String(), float64(wpa.Spec.Tolerance.MilliValue())/10)
Expand Down Expand Up @@ -120,35 +118,29 @@ func checkWPAMetricsValidity(wpa *WatermarkPodAutoscaler) (err error) {
return fmt.Errorf("metric.External is nil while metric.Type is '%s'", metric.Type)
}
if metric.External.LowWatermark == nil && metric.External.HighWatermark == nil {
msg := fmt.Sprintf("Watermarks are not set correctly, removing the WPA %s/%s from the Reconciler", wpa.Namespace, wpa.Name)
return fmt.Errorf(msg)
return fmt.Errorf("watermarks are not set correctly, removing the WPA %s/%s from the Reconciler", wpa.Namespace, wpa.Name)
}
if metric.External.MetricSelector == nil {
msg := fmt.Sprintf("Missing Labels for the External metric %s", metric.External.MetricName)
return fmt.Errorf(msg)
return fmt.Errorf("missing Labels for the External metric %s", metric.External.MetricName)
}
if metric.External.LowWatermark != nil && metric.External.HighWatermark != nil {
if metric.External.HighWatermark.MilliValue() < metric.External.LowWatermark.MilliValue() {
msg := fmt.Sprintf("Low WaterMark of External metric %s{%s} has to be strictly inferior to the High Watermark", metric.External.MetricName, metric.External.MetricSelector.MatchLabels)
return fmt.Errorf(msg)
return fmt.Errorf("low WaterMark of External metric %s{%s} has to be strictly inferior to the High Watermark", metric.External.MetricName, metric.External.MetricSelector.MatchLabels)
}
}
case ResourceMetricSourceType:
if metric.Resource == nil {
return fmt.Errorf("metric.Resource is nil while metric.Type is '%s'", metric.Type)
}
if metric.Resource.LowWatermark == nil && metric.Resource.HighWatermark == nil {
msg := fmt.Sprintf("Watermarks are not set correctly, removing the WPA %s/%s from the Reconciler", wpa.Namespace, wpa.Name)
return fmt.Errorf(msg)
return fmt.Errorf("watermarks are not set correctly, removing the WPA %s/%s from the Reconciler", wpa.Namespace, wpa.Name)
}
if metric.Resource.MetricSelector == nil {
msg := fmt.Sprintf("Missing Labels for the Resource metric %s", metric.Resource.Name)
return fmt.Errorf(msg)
return fmt.Errorf("missing Labels for the Resource metric %s", metric.Resource.Name)
}
if metric.Resource.LowWatermark != nil && metric.Resource.HighWatermark != nil {
if metric.Resource.HighWatermark.MilliValue() < metric.Resource.LowWatermark.MilliValue() {
msg := fmt.Sprintf("Low WaterMark of Resource metric %s{%s} has to be strictly inferior to the High Watermark", metric.Resource.Name, metric.Resource.MetricSelector.MatchLabels)
return fmt.Errorf(msg)
return fmt.Errorf("low WaterMark of Resource metric %s{%s} has to be strictly inferior to the High Watermark", metric.Resource.Name, metric.Resource.MetricSelector.MatchLabels)
}
}
default:
Expand Down
1 change: 0 additions & 1 deletion apis/datadoghq/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 792f6d0

Please sign in to comment.