diff --git a/ocp_resources/cluster_role_binding.py b/ocp_resources/cluster_role_binding.py index 82ffeb9a0f..c0ee72ad9d 100644 --- a/ocp_resources/cluster_role_binding.py +++ b/ocp_resources/cluster_role_binding.py @@ -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,