-
Notifications
You must be signed in to change notification settings - Fork 67
Update Backup and ClusterRole constructors and to_dict function #1349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1b6405b
Update Backup and ClusterRole constuctors and to_dict function
oharan2 e76ae9f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 63bea4a
Update backup docs
oharan2 362de94
Merge branch 'update_init' of github.com:oharan2/openshift-python-wra…
oharan2 0ea92fc
Update docs
oharan2 28bb357
Update documentations
oharan2 5173141
Remove if not self.yaml_file
oharan2 0759d88
Remove upper super.to_dict()
oharan2 cb1c761
Remove and not self.yaml_file
oharan2 d82a7ff
Update documentaions
oharan2 6e4c503
Use res.update with excluded resources
oharan2 a0e4f5f
Update docs
oharan2 08efe5a
Merge branch 'main' of https://github.com/RedHatQE/openshift-python-w…
oharan2 4fb8375
Remove update() usage to add excluded_resources to spec. update() ove…
oharan2 51b655c
Verified
oharan2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,51 +1,29 @@ | ||
| # -*- coding: utf-8 -*- | ||
| from ocp_resources.constants import TIMEOUT_4MINUTES | ||
| from ocp_resources.resource import Resource | ||
|
|
||
|
|
||
| class ClusterRole(Resource): | ||
| """ | ||
| ClusterRole object | ||
| ClusterRole in kubernetes 'authorization-resources' official API: | ||
| https://kubernetes.io/docs/reference/kubernetes-api/authorization-resources/cluster-role-v1/ | ||
| """ | ||
|
|
||
| api_group = Resource.ApiGroup.RBAC_AUTHORIZATION_K8S_IO | ||
|
|
||
| def __init__( | ||
| self, | ||
| name=None, | ||
| client=None, | ||
| rules=None, | ||
| teardown=True, | ||
| yaml_file=None, | ||
| delete_timeout=TIMEOUT_4MINUTES, | ||
| **kwargs, | ||
| ): | ||
| def __init__(self, rules=None, **kwargs): | ||
oharan2 marked this conversation as resolved.
Show resolved
Hide resolved
myakove marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """ | ||
| Args: | ||
| name (str): Role name. | ||
| client (DynamicClient): DynamicClient to use. | ||
| rules (list): list of dicts of rules. In the dict: | ||
| permissions_to_resources (list): List of string with resource/s to which you want to add permissions to. | ||
| Verbs (list): Determine the action/s (permissions) applicable on a specific resource. | ||
| Available verbs per resource can be seen with the command 'oc api-resources --sort-by name -o wide' | ||
| teardown (bool, default: True): Indicates if this resource would need to be deleted. | ||
| yaml_file (yaml, default: None): yaml file for the resource. | ||
| delete_timeout (int, default: 4 minutes): timeout associated with delete action. | ||
| """ | ||
| super().__init__( | ||
| client=client, | ||
| name=name, | ||
| teardown=teardown, | ||
| yaml_file=yaml_file, | ||
| delete_timeout=delete_timeout, | ||
| **kwargs, | ||
| ) | ||
| super().__init__(**kwargs) | ||
| self.rules = rules | ||
|
|
||
| def to_dict(self): | ||
| if not self.rules and not self.yaml_file: | ||
| raise ValueError("must send rules or yaml_file") | ||
| if not self.res: | ||
| super().to_dict() | ||
| super().to_dict() | ||
oharan2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if not self.yaml_file: | ||
| if not self.rules: | ||
| raise ValueError("must send rules or yaml_file") | ||
| self.res["rules"] = self.rules | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.