mirror of
https://github.com/outbackdingo/talos-cloud-controller-manager.git
synced 2026-01-27 18:20:23 +00:00
fix: empty terms
We crush if terms is empty. Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
This commit is contained in:
2
.github/workflows/build-test.yaml
vendored
2
.github/workflows/build-test.yaml
vendored
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user