-
Notifications
You must be signed in to change notification settings - Fork 1
/
path.go
46 lines (36 loc) · 1.03 KB
/
path.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
Copyright (c) 2019 VMware, Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package clusteroverview
import (
"path"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/runtime/schema"
"github.com/vmware/octant/internal/gvk"
)
var (
supportedGVKs = []schema.GroupVersionKind{
gvk.ClusterRoleBinding,
gvk.ClusterRole,
gvk.Node,
}
)
const rbacAPIVersion = "rbac.authorization.k8s.io/v1"
func crdPath(namespace, crdName, name string) (string, error) {
return path.Join("/cluster-overview/custom-resources", crdName, name), nil
}
func gvkPath(namespace, apiVersion, kind, name string) (string, error) {
var p string
switch {
case apiVersion == rbacAPIVersion && kind == "ClusterRole":
p = "/rbac/cluster-roles"
case apiVersion == rbacAPIVersion && kind == "ClusterRoleBinding":
p = "/rbac/cluster-role-bindings"
case apiVersion == "v1" && kind == "Node":
p = "/nodes"
default:
return "", errors.Errorf("unknown object %s %s", apiVersion, kind)
}
return path.Join("/cluster-overview", p, name), nil
}