Skip to content

Commit

Permalink
feat: upgrade golangci-lint to v1.63.4
Browse files Browse the repository at this point in the history
Signed-off-by: rambohe-ch <rambohe.ch@gmail.com>
  • Loading branch information
rambohe-ch committed Jan 13, 2025
1 parent 3d04ba6 commit 1170ad1
Show file tree
Hide file tree
Showing 52 changed files with 261 additions and 245 deletions.
17 changes: 13 additions & 4 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
run:
deadline: 10m
timeout: 15m

linters-settings:
gci:
skip-generated: true
sections:
- standard
- prefix(github.com/kaito-project)
- default

linters:
disable-all: true
enable:
- deadcode
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- nilerr
- prealloc
- structcheck
- typecheck
- unused
- varcheck
- gci
- gofmt
- goimports
- staticcheck
# Run with --fast=false for more extensive checks
fast: true
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ BIN_DIR := $(abspath $(ROOT_DIR)/bin)
TOOLS_DIR := hack/tools
TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/bin)

GOLANGCI_LINT_VER := v1.57.2
GOLANGCI_LINT_VER := v1.63.4
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER))

Expand Down
5 changes: 3 additions & 2 deletions api/v1alpha1/params_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import (
"reflect"
"strings"

"github.com/kaito-project/kaito/pkg/k8sclient"
"github.com/kaito-project/kaito/pkg/utils"
"gopkg.in/yaml.v2"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"knative.dev/pkg/apis"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/kaito-project/kaito/pkg/k8sclient"
"github.com/kaito-project/kaito/pkg/utils"
)

type Config struct {
Expand Down
5 changes: 3 additions & 2 deletions api/v1alpha1/ragengine_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import (
"regexp"
"strings"

"github.com/kaito-project/kaito/pkg/utils"
"github.com/kaito-project/kaito/pkg/utils/consts"
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog/v2"
"knative.dev/pkg/apis"

"github.com/kaito-project/kaito/pkg/utils"
"github.com/kaito-project/kaito/pkg/utils/consts"
)

func (w *RAGEngine) SupportedVerbs() []admissionregistrationv1.OperationType {
Expand Down
13 changes: 6 additions & 7 deletions api/v1alpha1/workspace_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ import (
"strconv"
"strings"

"github.com/kaito-project/kaito/pkg/k8sclient"
"github.com/kaito-project/kaito/pkg/utils/consts"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/kaito-project/kaito/pkg/utils"
"github.com/kaito-project/kaito/pkg/utils/plugin"

admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -27,6 +20,12 @@ import (
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/klog/v2"
"knative.dev/pkg/apis"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/kaito-project/kaito/pkg/k8sclient"
"github.com/kaito-project/kaito/pkg/utils"
"github.com/kaito-project/kaito/pkg/utils/consts"
"github.com/kaito-project/kaito/pkg/utils/plugin"
)

const (
Expand Down
12 changes: 6 additions & 6 deletions api/v1alpha1/workspace_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import (
"strings"
"testing"

"github.com/kaito-project/kaito/pkg/k8sclient"
"github.com/kaito-project/kaito/pkg/utils/consts"
"github.com/kaito-project/kaito/pkg/utils/plugin"
"k8s.io/apimachinery/pkg/runtime"

"github.com/kaito-project/kaito/pkg/model"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client/fake"

"github.com/kaito-project/kaito/pkg/k8sclient"
"github.com/kaito-project/kaito/pkg/model"
"github.com/kaito-project/kaito/pkg/utils/consts"
"github.com/kaito-project/kaito/pkg/utils/plugin"
)

const DefaultReleaseNamespace = "kaito-workspace"
Expand Down
27 changes: 12 additions & 15 deletions cmd/ragengine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,30 @@ import (
"syscall"
"time"

//+kubebuilder:scaffold:imports
azurev1alpha2 "github.com/Azure/karpenter-provider-azure/pkg/apis/v1alpha2"
"github.com/aws/karpenter-core/pkg/apis/v1alpha5"
awsv1beta1 "github.com/aws/karpenter-provider-aws/pkg/apis/v1beta1"
"github.com/kaito-project/kaito/pkg/k8sclient"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

"github.com/kaito-project/kaito/pkg/ragengine/controllers"
"github.com/kaito-project/kaito/pkg/ragengine/webhooks"
"k8s.io/api/apps/v1beta1"
"k8s.io/klog/v2"
"knative.dev/pkg/injection/sharedmain"
"knative.dev/pkg/webhook"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"
"sigs.k8s.io/controller-runtime/pkg/log"

"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/klog/v2"
"knative.dev/pkg/injection/sharedmain"
"knative.dev/pkg/webhook"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
kaitov1alpha1 "github.com/kaito-project/kaito/api/v1alpha1"
//+kubebuilder:scaffold:imports
"github.com/kaito-project/kaito/pkg/k8sclient"
"github.com/kaito-project/kaito/pkg/ragengine/controllers"
"github.com/kaito-project/kaito/pkg/ragengine/webhooks"
)

const (
Expand Down
37 changes: 17 additions & 20 deletions cmd/workspace/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,33 @@ import (
"syscall"
"time"

//+kubebuilder:scaffold:imports
azurev1alpha2 "github.com/Azure/karpenter-provider-azure/pkg/apis/v1alpha2"
awsv1beta1 "github.com/aws/karpenter-provider-aws/pkg/apis/v1beta1"
"github.com/kaito-project/kaito/pkg/featuregates"
"github.com/kaito-project/kaito/pkg/k8sclient"
"github.com/kaito-project/kaito/pkg/utils/consts"
"github.com/kaito-project/kaito/pkg/utils/nodeclaim"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/karpenter/pkg/apis/v1beta1"

"github.com/aws/karpenter-core/pkg/apis/v1alpha5"
"github.com/kaito-project/kaito/pkg/workspace/controllers"
"github.com/kaito-project/kaito/pkg/workspace/webhooks"
"k8s.io/klog/v2"
"knative.dev/pkg/injection/sharedmain"
"knative.dev/pkg/webhook"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"
"sigs.k8s.io/controller-runtime/pkg/log"

awsv1beta1 "github.com/aws/karpenter-provider-aws/pkg/apis/v1beta1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/klog/v2"
"knative.dev/pkg/injection/sharedmain"
"knative.dev/pkg/webhook"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/karpenter/pkg/apis/v1beta1"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
kaitov1alpha1 "github.com/kaito-project/kaito/api/v1alpha1"
//+kubebuilder:scaffold:imports
"github.com/kaito-project/kaito/pkg/featuregates"
"github.com/kaito-project/kaito/pkg/k8sclient"
"github.com/kaito-project/kaito/pkg/utils/consts"
"github.com/kaito-project/kaito/pkg/utils/nodeclaim"
"github.com/kaito-project/kaito/pkg/workspace/controllers"
"github.com/kaito-project/kaito/pkg/workspace/webhooks"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion pkg/featuregates/featuregates.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"errors"
"fmt"

"github.com/kaito-project/kaito/pkg/utils/consts"
cliflag "k8s.io/component-base/cli/flag"

"github.com/kaito-project/kaito/pkg/utils/consts"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion pkg/model/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"path"
"time"

"github.com/kaito-project/kaito/pkg/utils"
corev1 "k8s.io/api/core/v1"

"github.com/kaito-project/kaito/pkg/utils"
)

type Model interface {
Expand Down
12 changes: 6 additions & 6 deletions pkg/ragengine/controllers/preset-rag.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import (
"context"
"fmt"

"github.com/kaito-project/kaito/pkg/utils"
"github.com/kaito-project/kaito/pkg/utils/consts"

kaitov1alpha1 "github.com/kaito-project/kaito/api/v1alpha1"
"github.com/kaito-project/kaito/pkg/ragengine/manifests"
"github.com/kaito-project/kaito/pkg/utils/resources"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/util/intstr"
"sigs.k8s.io/controller-runtime/pkg/client"

kaitov1alpha1 "github.com/kaito-project/kaito/api/v1alpha1"
"github.com/kaito-project/kaito/pkg/ragengine/manifests"
"github.com/kaito-project/kaito/pkg/utils"
"github.com/kaito-project/kaito/pkg/utils/consts"
"github.com/kaito-project/kaito/pkg/utils/resources"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions pkg/ragengine/controllers/preset-rag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"strings"
"testing"

"github.com/kaito-project/kaito/pkg/utils/consts"
"github.com/kaito-project/kaito/pkg/utils/test"
"github.com/stretchr/testify/mock"
appsv1 "k8s.io/api/apps/v1"

"github.com/kaito-project/kaito/pkg/utils/consts"
"github.com/kaito-project/kaito/pkg/utils/test"
)

func TestCreatePresetRAG(t *testing.T) {
Expand Down
25 changes: 12 additions & 13 deletions pkg/ragengine/controllers/ragengine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,9 @@ import (

"github.com/aws/karpenter-core/pkg/apis/v1alpha5"
"github.com/go-logr/logr"
kaitov1alpha1 "github.com/kaito-project/kaito/api/v1alpha1"
"github.com/kaito-project/kaito/pkg/featuregates"
"github.com/kaito-project/kaito/pkg/ragengine/manifests"
"github.com/kaito-project/kaito/pkg/utils"
"github.com/kaito-project/kaito/pkg/utils/consts"
"github.com/kaito-project/kaito/pkg/utils/machine"
"github.com/kaito-project/kaito/pkg/utils/nodeclaim"
"github.com/kaito-project/kaito/pkg/utils/resources"
"github.com/samber/lo"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -45,6 +35,15 @@ import (
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/karpenter/pkg/apis/v1beta1"

kaitov1alpha1 "github.com/kaito-project/kaito/api/v1alpha1"
"github.com/kaito-project/kaito/pkg/featuregates"
"github.com/kaito-project/kaito/pkg/ragengine/manifests"
"github.com/kaito-project/kaito/pkg/utils"
"github.com/kaito-project/kaito/pkg/utils/consts"
"github.com/kaito-project/kaito/pkg/utils/machine"
"github.com/kaito-project/kaito/pkg/utils/nodeclaim"
"github.com/kaito-project/kaito/pkg/utils/resources"
)

const (
Expand Down Expand Up @@ -72,7 +71,7 @@ func NewRAGEngineReconciler(client client.Client, scheme *runtime.Scheme, log lo
func (c *RAGEngineReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) {
ragEngineObj := &kaitov1alpha1.RAGEngine{}
if err := c.Client.Get(ctx, req.NamespacedName, ragEngineObj); err != nil {
if !errors.IsNotFound(err) {
if !apierrors.IsNotFound(err) {

Check warning on line 74 in pkg/ragengine/controllers/ragengine_controller.go

View check run for this annotation

Codecov / codecov/patch

pkg/ragengine/controllers/ragengine_controller.go#L74

Added line #L74 was not covered by tests
klog.ErrorS(err, "failed to get RAG Engine", "RAG Engine", req.Name)
}
return reconcile.Result{}, client.IgnoreNotFound(err)
Expand Down Expand Up @@ -309,7 +308,7 @@ func (c *RAGEngineReconciler) syncControllerRevision(ctx context.Context, ragEng
Name: newRevision.Name,
Namespace: newRevision.Namespace,
}, controllerRevision); err != nil {
if errors.IsNotFound(err) {
if apierrors.IsNotFound(err) {

if err := c.Create(ctx, newRevision); err != nil {
return fmt.Errorf("failed to create new ControllerRevision: %w", err)
Expand Down Expand Up @@ -660,7 +659,7 @@ func (c *RAGEngineReconciler) watchMachines() handler.EventHandler {
}
_, conditionFound := lo.Find(machineObj.GetConditions(), func(condition apis.Condition) bool {
return condition.Type == apis.ConditionReady &&
condition.Status == v1.ConditionTrue
condition.Status == corev1.ConditionTrue

Check warning on line 662 in pkg/ragengine/controllers/ragengine_controller.go

View check run for this annotation

Codecov / codecov/patch

pkg/ragengine/controllers/ragengine_controller.go#L662

Added line #L662 was not covered by tests
})
if conditionFound && machineObj.DeletionTimestamp.IsZero() {
// No need to reconcile ragengine if the machine is in READY state unless machine is deleted.
Expand Down
9 changes: 5 additions & 4 deletions pkg/ragengine/controllers/ragengine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ import (
azurev1alpha2 "github.com/Azure/karpenter-provider-azure/pkg/apis/v1alpha2"
"github.com/aws/karpenter-core/pkg/apis/v1alpha5"
awsv1beta1 "github.com/aws/karpenter-provider-aws/pkg/apis/v1beta1"
"github.com/kaito-project/kaito/api/v1alpha1"
"github.com/kaito-project/kaito/pkg/featuregates"
"github.com/kaito-project/kaito/pkg/utils/consts"
"github.com/kaito-project/kaito/pkg/utils/test"
"github.com/stretchr/testify/mock"
"gotest.tools/assert"
appsv1 "k8s.io/api/apps/v1"
Expand All @@ -29,6 +25,11 @@ import (
"knative.dev/pkg/apis"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/karpenter/pkg/apis/v1beta1"

"github.com/kaito-project/kaito/api/v1alpha1"
"github.com/kaito-project/kaito/pkg/featuregates"
"github.com/kaito-project/kaito/pkg/utils/consts"
"github.com/kaito-project/kaito/pkg/utils/test"
)

func TestApplyRAGEngineResource(t *testing.T) {
Expand Down
9 changes: 5 additions & 4 deletions pkg/ragengine/controllers/ragengine_gc_finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ package controllers
import (
"context"

"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

kaitov1alpha1 "github.com/kaito-project/kaito/api/v1alpha1"
"github.com/kaito-project/kaito/pkg/featuregates"
"github.com/kaito-project/kaito/pkg/utils/consts"
"github.com/kaito-project/kaito/pkg/utils/machine"
"github.com/kaito-project/kaito/pkg/utils/nodeclaim"
"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
)

// garbageCollectRAGEngine remove finalizer associated with ragengine object.
Expand Down
Loading

0 comments on commit 1170ad1

Please sign in to comment.