feat(quality): fix duplicates and modernize
This commit is contained in:
@@ -3,13 +3,13 @@ package generator
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"katenary.io/internal/generator/labels"
|
"katenary.io/internal/generator/labels"
|
||||||
|
|
||||||
yaml3 "gopkg.in/yaml.v3"
|
yaml3 "gopkg.in/yaml.v3"
|
||||||
appsv1 "k8s.io/api/apps/v1"
|
|
||||||
v1 "k8s.io/api/apps/v1"
|
v1 "k8s.io/api/apps/v1"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
rbacv1 "k8s.io/api/rbac/v1"
|
rbacv1 "k8s.io/api/rbac/v1"
|
||||||
@@ -671,7 +671,7 @@ services:
|
|||||||
rbacOutput := internalCompileTest(t, "-s", "templates/web/depends-on.rbac.yaml")
|
rbacOutput := internalCompileTest(t, "-s", "templates/web/depends-on.rbac.yaml")
|
||||||
|
|
||||||
docs := strings.Split(rbacOutput, "---\n")
|
docs := strings.Split(rbacOutput, "---\n")
|
||||||
|
|
||||||
// Filter out empty documents and strip helm template comments
|
// Filter out empty documents and strip helm template comments
|
||||||
var filteredDocs []string
|
var filteredDocs []string
|
||||||
for _, doc := range docs {
|
for _, doc := range docs {
|
||||||
@@ -687,7 +687,7 @@ services:
|
|||||||
filteredDocs = append(filteredDocs, strings.Join(contentLines, "\n"))
|
filteredDocs = append(filteredDocs, strings.Join(contentLines, "\n"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(filteredDocs) != 3 {
|
if len(filteredDocs) != 3 {
|
||||||
t.Fatalf("Expected 3 YAML documents in RBAC file, got %d (filtered from %d)", len(filteredDocs), len(docs))
|
t.Fatalf("Expected 3 YAML documents in RBAC file, got %d (filtered from %d)", len(filteredDocs), len(docs))
|
||||||
}
|
}
|
||||||
@@ -780,7 +780,7 @@ services:
|
|||||||
|
|
||||||
output := internalCompileTest(t, "-s", "templates/web/deployment.yaml")
|
output := internalCompileTest(t, "-s", "templates/web/deployment.yaml")
|
||||||
|
|
||||||
var dt appsv1.Deployment
|
var dt v1.Deployment
|
||||||
if err := yaml.Unmarshal([]byte(output), &dt); err != nil {
|
if err := yaml.Unmarshal([]byte(output), &dt); err != nil {
|
||||||
t.Errorf("Failed to unmarshal Deployment: %v", err)
|
t.Errorf("Failed to unmarshal Deployment: %v", err)
|
||||||
}
|
}
|
||||||
@@ -832,10 +832,5 @@ services:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func contains(slice []string, item string) bool {
|
func contains(slice []string, item string) bool {
|
||||||
for _, s := range slice {
|
return slices.Contains(slice, item)
|
||||||
if s == item {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user