Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions ocp_resources/cluster_role_binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,33 @@

class ClusterRoleBinding(Resource):
"""
ClusterRoleBinding object.
https://kubernetes.io/docs/reference/kubernetes-api/authorization-resources/cluster-role-binding-v1/
"""

api_group = Resource.ApiGroup.RBAC_AUTHORIZATION_K8S_IO

def __init__(
self,
name=None,
cluster_role=None,
subjects=None,
**kwargs,
):
super().__init__(name=name, **kwargs)
"""
Args:
cluster_role (str): Name of referenced ClusterRole
subjects (list, optional): User subjects that are authorised to access the cluster role
"""
super().__init__(**kwargs)
self.cluster_role = cluster_role
self.subjects = subjects

def to_dict(self):
super().to_dict()
if not self.yaml_file:
if not self.cluster_role:
raise ValueError(
"Passing yaml_file or parameter 'cluster_role' is required."
)
self.res.setdefault("roleRef", {})
self.res["roleRef"] = {
"apiGroup": self.api_group,
Expand Down