forked from kiali/kiali
/
rbac_config.go
34 lines (29 loc) · 897 Bytes
/
rbac_config.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
package models
import (
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/kiali/kiali/kubernetes"
)
type RbacConfigs []RbacConfig
type RbacConfig struct {
meta_v1.TypeMeta
Metadata meta_v1.ObjectMeta `json:"metadata"`
Spec struct {
Mode interface{} `json:"mode"`
Inclusion interface{} `json:"inclusion"`
Exclusion interface{} `json:"exclusion"`
} `json:"spec"`
}
func (rcs *RbacConfigs) Parse(rbacConfigs []kubernetes.IstioObject) {
for _, rc := range rbacConfigs {
rbacConfig := RbacConfig{}
rbacConfig.Parse(rc)
*rcs = append(*rcs, rbacConfig)
}
}
func (rc *RbacConfig) Parse(rbacConfig kubernetes.IstioObject) {
rc.TypeMeta = rbacConfig.GetTypeMeta()
rc.Metadata = rbacConfig.GetObjectMeta()
rc.Spec.Mode = rbacConfig.GetSpec()["mode"]
rc.Spec.Inclusion = rbacConfig.GetSpec()["inclusion"]
rc.Spec.Exclusion = rbacConfig.GetSpec()["exclusion"]
}