-
Notifications
You must be signed in to change notification settings - Fork 5
cronjob for multiple namespaces #27
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
Conversation
DanNiESh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script worked well! Just one small comment in the cronjob.
| args: | ||
| - | | ||
| # get everyone in current grouping | ||
| group_users=($(oc get groups --as system:admin $GROUP_NAME -o jsonpath='{.users[*]}')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you don't need to run --as system:admin here since the cronjob service account already has get/list/update/patch roles to groups. I've tested it without as system:admin and it worked.
| # get everyone who has edit permissions on a workbench | ||
| curr_users=() | ||
|
|
||
| namespaces=($(oc get ns --as system:admin -o jsonpath='{.items[*].metadata.name}' | tr ' ' '\n' | grep "^${CLASS_NAME}-")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for getting namespace
| echo " " | ||
|
|
||
| if [ ${#users_to_add[@]} -gt 0 ]; then | ||
| oc adm groups add-users --as system:admin "$GROUP_NAME" "${users_to_add[@]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
| fi | ||
|
|
||
| if [ ${#users_to_remove[@]} -gt 0 ]; then | ||
| oc adm groups remove-users --as system:admin "$GROUP_NAME" "${users_to_remove[@]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
No description provided.