diff --git a/.github/workflows/golang-workflow.yaml b/.github/workflows/golang-workflow.yaml index 0938c3f4..2bed4716 100644 --- a/.github/workflows/golang-workflow.yaml +++ b/.github/workflows/golang-workflow.yaml @@ -8,4 +8,4 @@ on: jobs: golang-ci: - uses: kerthcet/github-workflow-as-kube/.github/workflows/workflow-golang-ci.yaml@v0.1.18 + uses: kerthcet/github-workflow-as-kube/.github/workflows/workflow-golang-ci.yaml@v0.1.21 diff --git a/.github/workflows/kube-workflow-init.yaml b/.github/workflows/kube-workflow-init.yaml index 7d58b53a..6545605a 100644 --- a/.github/workflows/kube-workflow-init.yaml +++ b/.github/workflows/kube-workflow-init.yaml @@ -5,6 +5,6 @@ on: jobs: init: - uses: kerthcet/github-workflow-as-kube/.github/workflows/workflow-as-kubernetes-init.yaml@v0.1.18 + uses: kerthcet/github-workflow-as-kube/.github/workflows/workflow-as-kubernetes-init.yaml@v0.1.21 secrets: AGENT_TOKEN: ${{ secrets.AGENT_TOKEN }} diff --git a/.github/workflows/kube-workflow.yaml b/.github/workflows/kube-workflow.yaml index 53bc223c..afcb2094 100644 --- a/.github/workflows/kube-workflow.yaml +++ b/.github/workflows/kube-workflow.yaml @@ -19,6 +19,6 @@ on: jobs: event-handler: - uses: kerthcet/github-workflow-as-kube/.github/workflows/workflow-as-kubernetes.yaml@v0.1.18 + uses: kerthcet/github-workflow-as-kube/.github/workflows/workflow-as-kubernetes.yaml@v0.1.21 secrets: AGENT_TOKEN: ${{ secrets.AGENT_TOKEN }} diff --git a/.golangci.yaml b/.golangci.yaml index d274e491..c794abbe 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,42 +1,47 @@ +version: "2" run: - timeout: 5m allow-parallel-runners: true - -issues: - # don't skip warning about doc comments - # don't exclude the default set of lint - exclude-use-default: false - # restore some of the defaults - # (fill in the rest as needed) - exclude-rules: - - path: "api/*" - linters: - - lll - - path: "pkg/*" - linters: - - dupl - - lll - - path: "test/*" - linters: - - dupl - - lll linters: - disable-all: true + default: none enable: + - copyloopvar - dupl - errcheck - - copyloopvar - goconst - - gofmt - - goimports - - gosimple - govet - ineffassign - misspell - nakedret - prealloc - staticcheck - - typecheck - unconvert - unparam - unused + exclusions: + generated: lax + rules: + - linters: + - lll + path: api/* + - linters: + - dupl + - lll + path: pkg/* + - linters: + - dupl + - lll + path: test/* + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + - goimports + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/Makefile b/Makefile index 3b3066bc..d653c968 100644 --- a/Makefile +++ b/Makefile @@ -139,7 +139,7 @@ test-deploy-with-helm: kind-image-build E2E_KIND_NODE_VERSION=$(E2E_KIND_NODE_VERSION) KIND_CLUSTER_NAME=$(KIND_CLUSTER_NAME) KIND=$(KIND) KUBECTL=$(KUBECTL) USE_EXISTING_CLUSTER=$(USE_EXISTING_CLUSTER) IMAGE_TAG=$(IMG) TAG=$(GIT_TAG) ./hack/test-deploy-with-helm.sh GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint -GOLANGCI_LINT_VERSION ?= v1.64.8 +GOLANGCI_LINT_VERSION ?= v2.2.1 golangci-lint: @[ -f $(GOLANGCI_LINT) ] || { \ set -e ;\ @@ -162,6 +162,10 @@ lint: golangci-lint pythonci-lint lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes $(GOLANGCI_LINT) run --fix +.PHONY: lint-config +lint-config: golangci-lint ## Verify golangci-lint linter configuration + $(GOLANGCI_LINT) config verify + ##@ Build .PHONY: build @@ -341,4 +345,4 @@ helm-package: helm .PHONY: launch-website launch-website: cd site && \ - hugo server \ No newline at end of file + hugo server diff --git a/pkg/controller/inference/service_controller.go b/pkg/controller/inference/service_controller.go index efd6b842..886add7b 100644 --- a/pkg/controller/inference/service_controller.go +++ b/pkg/controller/inference/service_controller.go @@ -106,7 +106,7 @@ func (r *ServiceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct service.Spec.WorkloadTemplate.WorkerTemplate.Spec.SchedulerName = configs.SchedulerName } - if err := r.Client.Update(ctx, service); err != nil { + if err := r.Update(ctx, service); err != nil { return ctrl.Result{}, fmt.Errorf("failed to update service: %w", err) } } diff --git a/pkg/controller_helper/backendruntime/backendruntime.go b/pkg/controller_helper/backendruntime/backendruntime.go index 054a9c60..3abc091c 100644 --- a/pkg/controller_helper/backendruntime/backendruntime.go +++ b/pkg/controller_helper/backendruntime/backendruntime.go @@ -130,7 +130,7 @@ func renderFlags(flags []string, modelInfo map[string]string) ([]string, error) if !exists || replacement == "" { return nil, fmt.Errorf("missing flag or the flag has format error: %s", flag) } - value = strings.Replace(value, match[0], replacement, -1) + value = strings.ReplaceAll(value, match[0], replacement) } res = append(res, value) diff --git a/pkg/controller_helper/modelsource/modelsource_test.go b/pkg/controller_helper/modelsource/modelsource_test.go index 1a02b6fd..9a2e54b1 100644 --- a/pkg/controller_helper/modelsource/modelsource_test.go +++ b/pkg/controller_helper/modelsource/modelsource_test.go @@ -210,7 +210,7 @@ func TestInjectModelEnvVars(t *testing.T) { for _, env := range container.Env { envVarMap[*env.Name] = true if env.ValueFrom != nil && env.ValueFrom.SecretKeyRef != nil { - if *env.ValueFrom.SecretKeyRef.LocalObjectReferenceApplyConfiguration.Name == tt.expectSecretRef { + if *env.ValueFrom.SecretKeyRef.Name == tt.expectSecretRef { secretRefFound = true } } diff --git a/pkg/util/convert.go b/pkg/util/convert.go index a075f206..58149862 100644 --- a/pkg/util/convert.go +++ b/pkg/util/convert.go @@ -79,7 +79,7 @@ var ( mismatchDetection: parseBool(os.Getenv("KUBE_PATCH_CONVERSION_DETECTOR")), comparison: conversion.EqualitiesOrDie( func(a, b time.Time) bool { - return a.UTC() == b.UTC() + return a.UTC().Equal(b.UTC()) }, ), } diff --git a/test/util/validation/validate_service.go b/test/util/validation/validate_service.go index 58a750ef..899e89d5 100644 --- a/test/util/validation/validate_service.go +++ b/test/util/validation/validate_service.go @@ -292,9 +292,10 @@ func ValidateSkipModelLoader(model *coreapi.OpenModel, index int, template corev envStrings = append(envStrings, modelSource.HUGGING_FACE_TOKEN_KEY, modelSource.HUGGING_FACE_HUB_TOKEN) } else if model.Spec.Source.URI != nil { protocol, _, _ := pkgUtil.ParseURI(string(*model.Spec.Source.URI)) - if protocol == modelSource.S3 || protocol == modelSource.GCS { + switch protocol { + case modelSource.S3, modelSource.GCS: envStrings = append(envStrings, modelSource.AWS_ACCESS_KEY_ID, modelSource.AWS_ACCESS_KEY_SECRET) - } else if protocol == modelSource.OSS { + case modelSource.OSS: envStrings = append(envStrings, modelSource.OSS_ACCESS_KEY_ID, modelSource.OSS_ACCESS_KEY_SECRET) } }