Skip to content

Commit

Permalink
fix label select db session
Browse files Browse the repository at this point in the history
  • Loading branch information
zc2638 committed Feb 29, 2024
1 parent de2da94 commit a591d4d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ 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

- name: Install Dependencies
run: go get -v -t -d ./...

- name: Lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: latest
version: v1.54.2

- name: Install Dependencies
run: go get -v -t -d ./...

- name: Test
run: make tests
Expand All @@ -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
Expand Down
14 changes: 8 additions & 6 deletions core/service/common/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"fmt"
"strings"

Check failure on line 21 in core/service/common/label.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/zc2638/ink) -s blank --custom-order (gci)
"gorm.io/gorm"

"github.com/99nil/gopkg/sets"

Check failure on line 24 in core/service/common/label.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/zc2638/ink) -s blank --custom-order (gci)

storageV1 "github.com/zc2638/ink/pkg/api/storage/v1"
Expand All @@ -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]()
Expand All @@ -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
}
Expand Down

0 comments on commit a591d4d

Please sign in to comment.