Coverage for ocp_resources/cluster_role.py: 0%
12 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-30 10:48 +0200
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-30 10:48 +0200
1# -*- coding: utf-8 -*-
2from ocp_resources.resource import MissingRequiredArgumentError, Resource
5class ClusterRole(Resource):
6 """
7 https://kubernetes.io/docs/reference/kubernetes-api/authorization-resources/cluster-role-v1/
8 """
10 api_group = Resource.ApiGroup.RBAC_AUTHORIZATION_K8S_IO
12 def __init__(self, rules=None, **kwargs):
13 """
14 Args:
15 rules (list): list of dicts of rules. In the dict:
16 permissions_to_resources (list): List of string with resource/s to which you want to add permissions to.
17 Verbs (list): Determine the action/s (permissions) applicable on a specific resource.
18 Available verbs per resource can be seen with the command 'oc api-resources --sort-by name -o wide'
19 """
20 super().__init__(**kwargs)
21 self.rules = rules
23 def to_dict(self) -> None:
24 super().to_dict()
25 if not self.kind_dict and not self.yaml_file:
26 if not self.rules:
27 raise MissingRequiredArgumentError(argument="rules")
28 self.res["rules"] = self.rules