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:
@@ -102,8 +102,9 @@ func RunCommand(cmd []string, env map[string]string) (string, error) {
|
||||
}
|
||||
|
||||
type QueryProps struct {
|
||||
Namespace string
|
||||
Name string
|
||||
Namespace string
|
||||
Name string
|
||||
APIVersion string
|
||||
}
|
||||
|
||||
func GetQueryProps(c *gin.Context) (*QueryProps, error) {
|
||||
@@ -111,6 +112,7 @@ func GetQueryProps(c *gin.Context) (*QueryProps, error) {
|
||||
|
||||
qp.Namespace = c.Query("namespace")
|
||||
qp.Name = c.Query("name")
|
||||
qp.APIVersion = c.Query("apiVersion")
|
||||
if qp.Name == "" {
|
||||
return nil, errors.New("missing required query string parameter: name")
|
||||
}
|
||||
@@ -118,6 +120,24 @@ func GetQueryProps(c *gin.Context) (*QueryProps, error) {
|
||||
return &qp, nil
|
||||
}
|
||||
|
||||
// QualifiedKind returns a group-qualified kind (e.g. "Widget.new.example.com")
|
||||
// when apiVersion contains a group, allowing kubectl to disambiguate CRDs
|
||||
// that share the same kind across different API groups.
|
||||
func QualifiedKind(kind string, apiVersion string) string {
|
||||
if apiVersion == "" {
|
||||
return kind
|
||||
}
|
||||
group := apiVersion
|
||||
if idx := strings.Index(apiVersion, "/"); idx >= 0 {
|
||||
group = apiVersion[:idx]
|
||||
}
|
||||
// Core API group (e.g. "v1") has no group prefix
|
||||
if !strings.Contains(group, ".") {
|
||||
return kind
|
||||
}
|
||||
return kind + "." + group
|
||||
}
|
||||
|
||||
func EnvAsBool(envKey string, envDef bool) bool {
|
||||
validSettableValues := []string{"false", "true", "0", "1"}
|
||||
envValue := os.Getenv(envKey)
|
||||
|
||||
Reference in New Issue
Block a user