20
20
#
21
21
22
22
function help() {
23
- echo " authorize-namespace.sh - Authorize a namespace to be managable from another namespare through the NamespaceScope operator"
23
+ echo " authorize-namespace.sh - Authorize a namespace to be manageable from another namespace through the NamespaceScope operator"
24
24
echo " SYNTAX:"
25
- echo " authorize-namespace.sh [namespace | default current namespace] [-to namespacename | default ibm-common-services] [-delete]"
25
+ echo " authorize-namespace.sh [namespace | default current namespace] [-to namespace | default ibm-common-services] [-delete]"
26
26
echo " WHERE:"
27
- echo " namespace : is the name of the namspece you wish to authorize. This namespace MUST exist, "
28
- echo " by default the current namespace is assumed"
29
- echo " tonamespace : is the name of the namespace that you want to authorize to manage artifacts in this namespace."
30
- echo " This namespace MUST exist. The default is ibm-common-services" .
31
- echo " The NamepaceScope CR MUST be define in this namespace with the name namespacescope."
32
- echo " -delete : Removes the ability for the tonamespace to manage artifacts in the namespace."
27
+ echo " namespace: It is the name of the namespace you wish to authorize. This namespace MUST exist. "
28
+ echo " By default, the current namespace is assumed"
29
+ echo " -to namespace: It is the name of the namespace of the NamespaceScope operator that you want to authorize."
30
+ echo " This namespace MUST exist. The default is ibm-common-services."
31
+ echo " -delete: It removes the ability for the NamespaceScope operator in tonamespace to manage artifacts in the namespace."
33
32
echo " "
34
33
echo " You must be logged into the Openshift cluster from the oc command line"
35
34
echo " "
@@ -107,23 +106,23 @@ if [ $? -ne 0 ]; then
107
106
fi
108
107
109
108
if [ " $TARGETNS " == " $TONS " ]; then
110
- echo " Namespace and tonamespace canot be the same namespace."
109
+ echo " Namespace and to namespace cannot be the same namespace."
111
110
help
112
111
exit 1
113
112
fi
114
113
115
114
if [ $DELETE -eq 1 ]; then
116
- echo " Deleteing authorization of namespace $TARGETNS to $TONS " >&2
115
+ echo " Deleting authorization that the NamespaceScope operator in $TONS to manages namespace $TARGETNS " >&2
117
116
else
118
- echo " Authorizing namespace $TARGETNS to $TONS " >&2
117
+ echo " Authorizing the NamespaceScope operator in $TONS to manage namespace $TARGETNS " >&2
119
118
fi
120
119
121
120
#
122
121
# Delete permissions and update the list if needed
123
122
#
124
123
if [ $DELETE -ne 0 ]; then
125
- oc delete role -l projectedfrom= $TONS -n $TARGETNS
126
- oc delete rolebinding -l projectedfrom= $TONS -n $TARGETNS
124
+ oc delete role nss-managed-role-from- $TONS -n $TARGETNS --ignore-not-found
125
+ oc delete rolebinding nss-managed-role-from- $TONS -n $TARGETNS --ignore-not-found
127
126
exit 0
128
127
fi
129
128
@@ -135,9 +134,7 @@ cat <<EOF | oc apply -n $TARGETNS -f -
135
134
apiVersion: rbac.authorization.k8s.io/v1
136
135
kind: Role
137
136
metadata:
138
- name: namespace-scope-client
139
- labels:
140
- projectedfrom: $TONS
137
+ name: nss-managed-role-from-$TONS
141
138
rules:
142
139
- apiGroups:
143
140
- "*"
@@ -154,15 +151,13 @@ cat <<EOF | oc apply -n $TARGETNS -f -
154
151
kind: RoleBinding
155
152
apiVersion: rbac.authorization.k8s.io/v1
156
153
metadata:
157
- name: namespace-scope-binding
158
- labels:
159
- projectedfrom: $TONS
154
+ name: nss-managed-role-from-$TONS
160
155
subjects:
161
156
- kind: ServiceAccount
162
157
name: ibm-namespace-scope-operator
163
158
namespace: $TONS
164
159
roleRef:
165
160
kind: Role
166
- name: namespace-scope-client
161
+ name: nss-managed-role-from- $TONS
167
162
apiGroup: rbac.authorization.k8s.io
168
163
EOF
0 commit comments