Skip to content

Commit

Permalink
better namespace errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantxu committed Jul 10, 2023
1 parent 7a08c47 commit e7e0483
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/util/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ func NamespaceToOrgID(ns string) (int64, error) {
if parts[0] == "default" {
return 1, nil
}
return 0, fmt.Errorf("invalid namespace")
if parts[0] == "" {
return 0, nil // no orgId, cluster scope
}
return 0, fmt.Errorf("invalid namespace (expected default)")
case 2:
if !(parts[0] == "org" || parts[0] == "tenant") {
return 0, fmt.Errorf("invalid namespace (org|tenant)")
Expand All @@ -31,5 +34,5 @@ func NamespaceToOrgID(ns string) (int64, error) {
}
return n, nil
}
return 0, fmt.Errorf("invalid namespace")
return 0, fmt.Errorf("invalid namespace (%d parts)", len(parts))
}

0 comments on commit e7e0483

Please sign in to comment.