Documentation
¶
Index ¶
- Constants
- func AddUserWithRoleToCluster(client *rancher.Client, globalRole, role string, cluster *management.Cluster, ...) (*management.User, *rancher.Client, error)
- func CreateClusterRoleTemplateBinding(client *rancher.Client, clusterID string, user *management.User, ...) (*v3.ClusterRoleTemplateBinding, error)
- func CreateProjectRoleTemplateBinding(client *rancher.Client, user *management.User, project *v3.Project, ...) (*v3.ProjectRoleTemplateBinding, error)
- func CreateRoleTemplate(client *rancher.Client, context string, rules []rbacv1.PolicyRule, ...) (*v3.RoleTemplate, error)
- func GetBindings(rancherClient *rancher.Client, userID string) (map[string]interface{}, error)
- func GetClusterRoleRules(client *rancher.Client, clusterID string, clusterRoleName string) ([]rbacv1.PolicyRule, error)
- func GetGlobalRoleBindingByName(client *rancher.Client, globalRoleBindingName string) (*v3.GlobalRoleBinding, error)
- func GetGlobalRoleBindingByUserAndRole(client *rancher.Client, userID, globalRoleName string) (*v3.GlobalRoleBinding, error)
- func GetGlobalRoleByName(client *rancher.Client, globalRoleName string) (*v3.GlobalRole, error)
- func GetRoleBindings(rancherClient *rancher.Client, clusterID string, userID string) ([]rbacv1.RoleBinding, error)
- func GetRoleTemplateByName(client *rancher.Client, roleTemplateName string) (*v3.RoleTemplate, error)
- func SetupUser(client *rancher.Client, globalRoles ...string) (user *management.User, userClient *rancher.Client, err error)
- func VerifyClusterRoleTemplateBindingForUser(client *rancher.Client, username string, expectedCount int) ([]v3.ClusterRoleTemplateBinding, error)
- func VerifyGlobalRoleBindingsForUser(t *testing.T, user *management.User, adminClient *rancher.Client)
- func VerifyProjectRoleTemplateBindingForUser(client *rancher.Client, username string, expectedCount int) ([]v3.ProjectRoleTemplateBinding, error)
- func VerifyRoleBindingsForUser(t *testing.T, user *management.User, adminClient *rancher.Client, ...)
- func VerifyRoleRules(expected, actual map[string][]string) error
- func VerifyUserCanAddClusterRoles(t *testing.T, client, memberClient *rancher.Client, ...)
- func VerifyUserCanAddProjectRoles(t *testing.T, client *rancher.Client, project *v3.Project, ...)
- func VerifyUserCanCreateNamespace(t *testing.T, client, standardClient *rancher.Client, project *v3.Project, ...)
- func VerifyUserCanCreateProjects(t *testing.T, client, standardClient *rancher.Client, clusterID string, ...)
- func VerifyUserCanDeleteNamespace(t *testing.T, client, standardClient *rancher.Client, project *v3.Project, ...)
- func VerifyUserCanDeleteProject(t *testing.T, client *rancher.Client, project *v3.Project, role Role)
- func VerifyUserCanGetProject(t *testing.T, client, standardClient *rancher.Client, ...)
- func VerifyUserCanListCluster(t *testing.T, client, standardClient *rancher.Client, clusterID string, ...)
- func VerifyUserCanListNamespace(t *testing.T, client, standardClient *rancher.Client, project *v3.Project, ...)
- func VerifyUserCanListProject(t *testing.T, client, standardClient *rancher.Client, ...)
- func VerifyUserCanRemoveClusterRoles(t *testing.T, client *rancher.Client, user *management.User)
- func WaitForCrtbStatus(client *rancher.Client, crtbNamespace, crtbName string) error
- func WaitForPrtbExistence(client *rancher.Client, project *v3.Project, ...) (*v3.ProjectRoleTemplateBinding, error)
- type Config
- type Role
Constants ¶
const ( Admin Role = "admin" BaseUser Role = "user-base" StandardUser Role = "user" ClusterOwner Role = "cluster-owner" ClusterMember Role = "cluster-member" ProjectOwner Role = "project-owner" ProjectMember Role = "project-member" CreateNS Role = "create-ns" ReadOnly Role = "read-only" CustomManageProjectMember Role = "projectroletemplatebindings-manage" CrtbView Role = "clusterroletemplatebindings-view" ProjectsCreate Role = "projects-create" ProjectsView Role = "projects-view" ManageWorkloads Role = "workloads-manage" ActiveStatus = "active" ForbiddenError = "403 Forbidden" DefaultNamespace = "fleet-default" LocalCluster = "local" UserKind = "User" ImageName = "nginx" ManageUsersVerb = "manage-users" ManagementAPIGroup = "management.cattle.io" UsersResource = "users" UserAttributeResource = "userattribute" GroupsResource = "groups" GroupMembersResource = "groupmembers" )
const (
ConfigurationFileKey = "rbacInput"
)
Variables ¶
This section is empty.
Functions ¶
func AddUserWithRoleToCluster ¶
func AddUserWithRoleToCluster(client *rancher.Client, globalRole, role string, cluster *management.Cluster, project *v3.Project) (*management.User, *rancher.Client, error)
AddUserWithRoleToCluster creates a user based on the global role and then adds the user to cluster with provided permissions.
func CreateClusterRoleTemplateBinding ¶
func CreateClusterRoleTemplateBinding(client *rancher.Client, clusterID string, user *management.User, roleTemplateID string) (*v3.ClusterRoleTemplateBinding, error)
CreateClusterRoleTemplateBinding creates a cluster role template binding for the user with the provided role template using wrangler context
func CreateProjectRoleTemplateBinding ¶
func CreateProjectRoleTemplateBinding(client *rancher.Client, user *management.User, project *v3.Project, roleTemplateID string) (*v3.ProjectRoleTemplateBinding, error)
CreateProjectRoleTemplateBinding creates a project role template binding for the user with the provided role template using wrangler context
func CreateRoleTemplate ¶
func CreateRoleTemplate(client *rancher.Client, context string, rules []rbacv1.PolicyRule, inheritedRoles []*v3.RoleTemplate, external bool, externalRules []rbacv1.PolicyRule) (*v3.RoleTemplate, error)
CreateRoleTemplate creates a cluster or project role template with the provided rules using wrangler context
func GetBindings ¶
GetBindings is a helper function to fetch bindings for a user
func GetClusterRoleRules ¶
func GetClusterRoleRules(client *rancher.Client, clusterID string, clusterRoleName string) ([]rbacv1.PolicyRule, error)
GetClusterRoleRules is a helper function to fetch rules for a cluster role
func GetGlobalRoleBindingByName ¶
func GetGlobalRoleBindingByName(client *rancher.Client, globalRoleBindingName string) (*v3.GlobalRoleBinding, error)
GetGlobalRoleBindingByName is a helper function to fetch global role binding by name
func GetGlobalRoleBindingByUserAndRole ¶
func GetGlobalRoleBindingByUserAndRole(client *rancher.Client, userID, globalRoleName string) (*v3.GlobalRoleBinding, error)
GetGlobalRoleBindingByUserAndRole is a helper function to fetch global role binding for a user associated with a specific global role
func GetGlobalRoleByName ¶
GetGlobalRoleByName is a helper function to fetch global role by name
func GetRoleBindings ¶
func GetRoleBindings(rancherClient *rancher.Client, clusterID string, userID string) ([]rbacv1.RoleBinding, error)
GetRoleBindings is a helper function to fetch rolebindings for a user
func GetRoleTemplateByName ¶
func GetRoleTemplateByName(client *rancher.Client, roleTemplateName string) (*v3.RoleTemplate, error)
GetRoleTemplateByName is a helper function to fetch role template by name using wrangler context
func SetupUser ¶
func SetupUser(client *rancher.Client, globalRoles ...string) (user *management.User, userClient *rancher.Client, err error)
SetupUser is a helper to create a user with the specified global role and a client for the user.
func VerifyClusterRoleTemplateBindingForUser ¶
func VerifyClusterRoleTemplateBindingForUser(client *rancher.Client, username string, expectedCount int) ([]v3.ClusterRoleTemplateBinding, error)
VerifyClusterRoleTemplateBindingForUser is a helper function to verify the number of cluster role template bindings for a user
func VerifyGlobalRoleBindingsForUser ¶
func VerifyGlobalRoleBindingsForUser(t *testing.T, user *management.User, adminClient *rancher.Client)
VerifyGlobalRoleBindingsForUser validates that a global role bindings is created for a user when the user is created
func VerifyProjectRoleTemplateBindingForUser ¶
func VerifyProjectRoleTemplateBindingForUser(client *rancher.Client, username string, expectedCount int) ([]v3.ProjectRoleTemplateBinding, error)
VerifyProjectRoleTemplateBindingForUser is a helper function to verify the number of project role template bindings for a user
func VerifyRoleBindingsForUser ¶
func VerifyRoleBindingsForUser(t *testing.T, user *management.User, adminClient *rancher.Client, clusterID string, role Role, expectedCount int)
VerifyRoleBindingsForUser validates that the corresponding role bindings are created for the user
func VerifyRoleRules ¶
VerifyRoleRules checks if the expected role rules match the actual rules.
func VerifyUserCanAddClusterRoles ¶
func VerifyUserCanAddClusterRoles(t *testing.T, client, memberClient *rancher.Client, cluster *management.Cluster, role Role)
VerifyUserCanAddClusterRoles validates a user with the required cluster permissions are able/not able to add other users in the cluster
func VerifyUserCanAddProjectRoles ¶
func VerifyUserCanAddProjectRoles(t *testing.T, client *rancher.Client, project *v3.Project, additionalUser *management.User, projectRole, clusterID string, role Role)
VerifyUserCanAddProjectRoles validates a user with the required cluster permissions are able/not able to add other users in a project on the downstream cluster
func VerifyUserCanCreateNamespace ¶
func VerifyUserCanCreateNamespace(t *testing.T, client, standardClient *rancher.Client, project *v3.Project, clusterID string, role Role)
VerifyUserCanCreateNamespace validates a user with the required cluster permissions are able/not able to create namespaces in the project they do not own
func VerifyUserCanCreateProjects ¶
func VerifyUserCanCreateProjects(t *testing.T, client, standardClient *rancher.Client, clusterID string, role Role)
VerifyUserCanCreateProjects validates a user with the required cluster permissions are able/not able to create projects in the downstream cluster
func VerifyUserCanDeleteNamespace ¶
func VerifyUserCanDeleteNamespace(t *testing.T, client, standardClient *rancher.Client, project *v3.Project, clusterID string, role Role)
VerifyUserCanDeleteNamespace validates a user with the required cluster permissions are able/not able to delete namespaces in the project they do not own
func VerifyUserCanDeleteProject ¶
func VerifyUserCanDeleteProject(t *testing.T, client *rancher.Client, project *v3.Project, role Role)
VerifyUserCanDeleteProject validates a user with the required cluster/project permissions are able/not able to delete projects in the downstream cluster
func VerifyUserCanGetProject ¶
func VerifyUserCanGetProject(t *testing.T, client, standardClient *rancher.Client, clusterID, adminProjectName string, role Role)
VerifyUserCanGetProject validates a user with the required cluster permissions are able/not able to get the specific project in the downstream cluster
func VerifyUserCanListCluster ¶
func VerifyUserCanListCluster(t *testing.T, client, standardClient *rancher.Client, clusterID string, role Role)
VerifyUserCanListCluster validates a user with the required global permissions are able to/not able to list the clusters in rancher server
func VerifyUserCanListNamespace ¶
func VerifyUserCanListNamespace(t *testing.T, client, standardClient *rancher.Client, project *v3.Project, clusterID string, role Role)
VerifyUserCanListNamespace validates a user with the required cluster permissions are able/not able to list namespaces in the project they do not own
func VerifyUserCanListProject ¶
func VerifyUserCanListProject(t *testing.T, client, standardClient *rancher.Client, clusterID, adminProjectName string, role Role)
VerifyUserCanListProject validates a user with the required cluster permissions are able/not able to list projects in the downstream cluster
func VerifyUserCanRemoveClusterRoles ¶
VerifyUserCanRemoveClusterRoles validates a user with the required cluster/project permissions are able/not able to remove cluster roles in the downstream cluster
func WaitForCrtbStatus ¶
WaitForCrtbStatus waits for the CRTB to reach the Completed status or checks for its existence if status field is not supported (older Rancher versions)
func WaitForPrtbExistence ¶
func WaitForPrtbExistence(client *rancher.Client, project *v3.Project, prtbObj *v3.ProjectRoleTemplateBinding, user *management.User) (*v3.ProjectRoleTemplateBinding, error)
WaitForPrtbExistence waits for the PRTB to exist with the correct user and project