mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-03-24 11:48:04 +00:00
fix: use apiVersion to disambiguate CRDs with same kind (#504)
When multiple CRDs share the same kind but different API groups (e.g. Traefik's Middleware under traefik.io and traefik.containo.us), the dashboard failed to look up the correct resource. Thread apiVersion through the resource fetch chain and use group-qualified kind (e.g. Widget.new.example.com) for kubectl lookups. Closes #504 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -108,6 +108,30 @@ func TestChartAndVersion(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestQualifiedKind(t *testing.T) {
|
||||
tests := []struct {
|
||||
kind string
|
||||
apiVersion string
|
||||
want string
|
||||
}{
|
||||
{"Widget", "new.example.com/v1alpha1", "Widget.new.example.com"},
|
||||
{"Widget", "old.example.com/v1alpha1", "Widget.old.example.com"},
|
||||
{"Deployment", "apps/v1", "Deployment"},
|
||||
{"ConfigMap", "v1", "ConfigMap"},
|
||||
{"ConfigMap", "", "ConfigMap"},
|
||||
{"Middleware", "traefik.io/v1alpha1", "Middleware.traefik.io"},
|
||||
{"Middleware", "traefik.containo.us/v1alpha1", "Middleware.traefik.containo.us"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.kind+"/"+tt.apiVersion, func(t *testing.T) {
|
||||
got := QualifiedKind(tt.kind, tt.apiVersion)
|
||||
if got != tt.want {
|
||||
t.Errorf("QualifiedKind(%q, %q) = %q, want %q", tt.kind, tt.apiVersion, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnvAsBool(t *testing.T) {
|
||||
// value: "true" | "1", default: false -> expect true
|
||||
t.Setenv("TEST", "true")
|
||||
|
||||
Reference in New Issue
Block a user