diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d87b0e8..6fc5c07 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -13,7 +13,7 @@ jobs: - name: Install Go uses: actions/setup-go@v4 with: - go-version: 1.21 + go-version: 1.21.0 - name: Checkout Code uses: actions/checkout@v3 @@ -24,7 +24,7 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v3 with: - version: latest + version: v1.54.2 - name: Test run: make tests @@ -35,7 +35,7 @@ jobs: - name: Install Go uses: actions/setup-go@v4 with: - go-version: 1.21 + go-version: 1.21.0 - name: Checkout Code uses: actions/checkout@v3 diff --git a/core/service/common/label.go b/core/service/common/label.go index f1788be..ed97b69 100644 --- a/core/service/common/label.go +++ b/core/service/common/label.go @@ -19,6 +19,8 @@ import ( "fmt" "strings" + "gorm.io/gorm" + "github.com/99nil/gopkg/sets" storageV1 "github.com/zc2638/ink/pkg/api/storage/v1" @@ -31,7 +33,9 @@ func SelectNamesByLabels(ctx context.Context, kind, namespace string, labels map } db := database.FromContext(ctx) - db = db.Model(&storageV1.Label{}).Where(&storageV1.Label{Namespace: namespace, Kind: kind}) + db = db.Model(&storageV1.Label{}). + Where(&storageV1.Label{Namespace: namespace, Kind: kind}). + Session(&gorm.Session{}) var start bool nameSet := sets.New[string]() @@ -46,11 +50,9 @@ func SelectNamesByLabels(ctx context.Context, kind, namespace string, labels map nameSet.Add(selectNames...) continue } - for _, sn := range selectNames { - if !nameSet.Has(sn) { - nameSet.Remove(sn) - } - } + + selectNameSet := sets.New(selectNames...) + nameSet = nameSet.Intersection(selectNameSet) if nameSet.Len() == 0 { return nil, nil }