From 320e853b8dd5a1b91e1934b12bad6bd49b9708bf Mon Sep 17 00:00:00 2001 From: Seb Ospina Date: Thu, 16 May 2019 19:07:28 +0200 Subject: [PATCH] Added List mode for Role, ClusterRole and Bindings Kubernetes supports RoleList, RoleBindingList, ClusterRoleList and ClusterRoleBindingList, in order for a Role to be bound, it must already exist. For the List reference, see: https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/rbac/types.go Signed-off-by: Seb Ospina --- pkg/tiller/kind_sorter.go | 8 ++++++++ pkg/tiller/kind_sorter_test.go | 20 ++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/pkg/tiller/kind_sorter.go b/pkg/tiller/kind_sorter.go index f980277d2..2c11aa855 100644 --- a/pkg/tiller/kind_sorter.go +++ b/pkg/tiller/kind_sorter.go @@ -40,9 +40,13 @@ var InstallOrder SortOrder = []string{ "ServiceAccount", "CustomResourceDefinition", "ClusterRole", + "ClusterRoleList", "ClusterRoleBinding", + "ClusterRoleBindingList", "Role", + "RoleList", "RoleBinding", + "RoleBindingList", "Service", "DaemonSet", "Pod", @@ -71,9 +75,13 @@ var UninstallOrder SortOrder = []string{ "ReplicationController", "Pod", "DaemonSet", + "RoleBindingList", "RoleBinding", + "RoleList", "Role", + "ClusterRoleBindingList", "ClusterRoleBinding", + "ClusterRoleList", "ClusterRole", "CustomResourceDefinition", "ServiceAccount", diff --git a/pkg/tiller/kind_sorter_test.go b/pkg/tiller/kind_sorter_test.go index 56822f995..626e80ee6 100644 --- a/pkg/tiller/kind_sorter_test.go +++ b/pkg/tiller/kind_sorter_test.go @@ -29,10 +29,18 @@ func TestKindSorter(t *testing.T) { Name: "i", Head: &util.SimpleHead{Kind: "ClusterRole"}, }, + { + Name: "I", + Head: &util.SimpleHead{Kind: "ClusterRoleList"}, + }, { Name: "j", Head: &util.SimpleHead{Kind: "ClusterRoleBinding"}, }, + { + Name: "J", + Head: &util.SimpleHead{Kind: "ClusterRoleBindingList"}, + }, { Name: "e", Head: &util.SimpleHead{Kind: "ConfigMap"}, @@ -105,10 +113,18 @@ func TestKindSorter(t *testing.T) { Name: "k", Head: &util.SimpleHead{Kind: "Role"}, }, + { + Name: "K", + Head: &util.SimpleHead{Kind: "RoleList"}, + }, { Name: "l", Head: &util.SimpleHead{Kind: "RoleBinding"}, }, + { + Name: "L", + Head: &util.SimpleHead{Kind: "RoleBindingList"}, + }, { Name: "d", Head: &util.SimpleHead{Kind: "Secret"}, @@ -144,8 +160,8 @@ func TestKindSorter(t *testing.T) { order SortOrder expected string }{ - {"install", InstallOrder, "abc3zde1fgh2ijklmnopqrstuvw!"}, - {"uninstall", UninstallOrder, "wvmutsrqponlkji2hgf1edz3cba!"}, + {"install", InstallOrder, "abc3zde1fgh2iIjJkKlLmnopqrstuvw!"}, + {"uninstall", UninstallOrder, "wvmutsrqponLlKkJjIi2hgf1edz3cba!"}, } { var buf bytes.Buffer t.Run(test.description, func(t *testing.T) {