Skip to content

Commit

Permalink
fix: empty terms
Browse files Browse the repository at this point in the history
We crush if terms is empty.

Signed-off-by: Serge Logvinov <[email protected]>
  • Loading branch information
sergelogvinov committed May 13, 2024
1 parent 749a01d commit 9dde8aa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
go-version-file: 'go.mod'

- name: Lint
uses: golangci/golangci-lint-action@v5
uses: golangci/golangci-lint-action@v6
with:
version: v1.58.0
args: --timeout=5m --config=.golangci.yml
Expand Down
8 changes: 4 additions & 4 deletions pkg/transformer/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ var prohibitedPlatformMetadataKeys = []string{"hostname", "platform"}
//
//nolint:gocyclo,cyclop
func TransformNode(terms []NodeTerm, platformMetadata *runtime.PlatformMetadataSpec) (*NodeSpec, error) {
if len(terms) == 0 {
return nil, nil
}

node := &NodeSpec{
Annotations: make(map[string]string),
Labels: make(map[string]string),
}

if len(terms) == 0 {
return node, nil
}

metadata := metadataFromStruct(platformMetadata)

for _, term := range terms {
Expand Down
4 changes: 4 additions & 0 deletions pkg/transformer/transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func TestMatch(t *testing.T) {
Platform: "test-platform",
Hostname: "test-hostname",
},
expected: &transformer.NodeSpec{
Annotations: map[string]string{},
Labels: map[string]string{},
},
},
{
name: "Transform labels",
Expand Down

0 comments on commit 9dde8aa

Please sign in to comment.