From a4d42aaf51784cc0ab37a63d6069f63dc49507d6 Mon Sep 17 00:00:00 2001 From: derailed Date: Thu, 20 Jun 2019 14:38:51 -0600 Subject: [PATCH] refac policy --- internal/config/config_test.go | 16 ---------------- internal/config/k9s.go | 1 - internal/views/policy.go | 16 +++++----------- 3 files changed, 5 insertions(+), 28 deletions(-) diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 1cfcdb6e..9be402f4 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -293,14 +293,6 @@ var expectedConfig = `k9s: - kube-system view: active: ctx - plugins: - sniff: - shortCut: ShiftS - scopes: - - po - - dp - args: - "n": $NAMESPACE ` var resetConfig = `k9s: @@ -317,12 +309,4 @@ var resetConfig = `k9s: - default view: active: po - plugins: - sniff: - shortCut: ShiftS - scopes: - - po - - dp - args: - "n": $NAMESPACE ` diff --git a/internal/config/k9s.go b/internal/config/k9s.go index 8f7e9a1e..9ac4809b 100644 --- a/internal/config/k9s.go +++ b/internal/config/k9s.go @@ -17,7 +17,6 @@ type K9s struct { CurrentCluster string `yaml:"currentCluster"` Clusters map[string]*Cluster `yaml:"clusters,omitempty"` Aliases map[string]string `yaml:"aliases,omitempty"` - Plugins map[string]Plugin `yaml:"plugins"` } // NewK9s create a new K9s configuration. diff --git a/internal/views/policy.go b/internal/views/policy.go index bb3f9343..af226745 100644 --- a/internal/views/policy.go +++ b/internal/views/policy.go @@ -230,11 +230,11 @@ func (v *policyView) parseRules(ns, binding string, rules []rbacv1.PolicyRule) r for _, na := range r.ResourceNames { n := fqn(k, na) m[fqn(ns, n)] = &resource.RowEvent{ - Fields: v.prepRow(ns, n, grp, binding, r.Verbs), + Fields: append(v.prepRow(ns, n, grp, binding), r.Verbs...), } } m[fqn(ns, k)] = &resource.RowEvent{ - Fields: v.prepRow(ns, k, grp, binding, r.Verbs), + Fields: append(v.prepRow(ns, k, grp, binding), r.Verbs...), } } } @@ -243,7 +243,7 @@ func (v *policyView) parseRules(ns, binding string, rules []rbacv1.PolicyRule) r nres = "/" + nres } m[fqn(ns, nres)] = &resource.RowEvent{ - Fields: v.prepRow(ns, nres, resource.NAValue, binding, r.Verbs), + Fields: append(v.prepRow(ns, nres, resource.NAValue, binding), r.Verbs...), } } } @@ -251,19 +251,13 @@ func (v *policyView) parseRules(ns, binding string, rules []rbacv1.PolicyRule) r return m } -func (v *policyView) prepRow(ns, res, grp, binding string, verbs []string) resource.Row { +func (v *policyView) prepRow(ns, res, grp, binding string) resource.Row { if grp != resource.NAValue { grp = toGroup(grp) } - return v.makeRow(ns, res, grp, binding, asVerbs(verbs...)) -} - -func (*policyView) makeRow(ns, res, group, binding string, verbs []string) resource.Row { r := make(resource.Row, 0, len(policyHeader)) - r = append(r, ns, res, group, binding) - - return append(r, verbs...) + return append(r, ns, res, grp, binding) } func mapSubject(subject string) string {