Skip to content

Commit a236164

Browse files
committed
Add PSP review kinds to /oapi group map
This allows oc to correctly create the legacy ungroupified variants of these objects. Bug 1572562 Signed-off-by: Monis Khan <[email protected]>
1 parent ef405a3 commit a236164

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

pkg/api/legacygroupification/groupification.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ func OAPIToGroupified(uncast runtime.Object, gvk *schema.GroupVersionKind) {
106106
case *route.Route, *routev1.Route, *route.RouteList, *routev1.RouteList:
107107
gvk.Group = route.GroupName
108108

109-
case *security.SecurityContextConstraints, *securityv1.SecurityContextConstraints, *security.SecurityContextConstraintsList, *securityv1.SecurityContextConstraintsList:
109+
case *security.SecurityContextConstraints, *securityv1.SecurityContextConstraints, *security.SecurityContextConstraintsList, *securityv1.SecurityContextConstraintsList,
110+
*security.PodSecurityPolicySubjectReview, *securityv1.PodSecurityPolicySubjectReview,
111+
*security.PodSecurityPolicySelfSubjectReview, *securityv1.PodSecurityPolicySelfSubjectReview,
112+
*security.PodSecurityPolicyReview, *securityv1.PodSecurityPolicyReview:
110113
gvk.Group = security.GroupName
111114

112115
case *template.Template, *templatev1.Template, *template.TemplateList, *templatev1.TemplateList:
@@ -151,7 +154,10 @@ var oapiKindsToGroup = map[string]string{
151154
"ClusterResourceQuota": "quota.openshift.io", "ClusterResourceQuotaList": "quota.openshift.io",
152155
"Route": "route.openshift.io", "RouteList": "route.openshift.io",
153156
"SecurityContextConstraints": "security.openshift.io", "SecurityContextConstraintsList": "security.openshift.io",
154-
"Template": "template.openshift.io", "TemplateList": "template.openshift.io",
157+
"PodSecurityPolicySubjectReview": "security.openshift.io",
158+
"PodSecurityPolicySelfSubjectReview": "security.openshift.io",
159+
"PodSecurityPolicyReview": "security.openshift.io",
160+
"Template": "template.openshift.io", "TemplateList": "template.openshift.io",
155161
"Group": "user.openshift.io", "GroupList": "user.openshift.io",
156162
"Identity": "user.openshift.io", "IdentityList": "user.openshift.io",
157163
"UserIdentityMapping": "user.openshift.io",

test/cmd/policy.sh

+2
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ os::cmd::expect_failure_and_text 'oc policy scc-review -f ${OS_ROOT}/test/testda
204204
os::cmd::expect_success_and_text 'oc policy scc-subject-review -f ${OS_ROOT}/test/testdata/job.yaml -o=jsonpath={.status.AllowedBy.name}' 'anyuid'
205205
os::cmd::expect_success_and_text 'oc policy scc-subject-review -f ${OS_ROOT}/test/testdata/redis-slave.yaml -o=jsonpath={.status.AllowedBy.name}' 'anyuid'
206206
os::cmd::expect_success_and_text 'oc policy scc-subject-review -f ${OS_ROOT}/test/testdata/nginx_pod.yaml -o=jsonpath={.status.AllowedBy.name}' 'privileged'
207+
# Make sure that the legacy ungroupified objects continue to work by directly doing a create
208+
os::cmd::expect_success_and_text 'oc create -f ${OS_ROOT}/test/testdata/legacy_ungroupified_psp_review.yaml -o=jsonpath={.status.allowedBy.name}' 'restricted'
207209
os::cmd::expect_success "oc login -u bob -p bobpassword"
208210
os::cmd::expect_success_and_text 'oc whoami' 'bob'
209211
os::cmd::expect_success 'oc new-project policy-second'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
kind: PodSecurityPolicySubjectReview
2+
apiVersion: v1 # Must have the empty string group
3+
spec:
4+
template:
5+
spec:
6+
containers:
7+
- name: hello-openshift
8+
image: hello-openshift
9+
ports:
10+
- containerPort: 8080
11+
protocol: TCP
12+
resources: {}
13+
volumeMounts:
14+
- name: tmp
15+
mountPath: "/tmp"
16+
terminationMessagePath: "/dev/termination-log"
17+
terminationMessagePolicy: FallbackToLogsOnError
18+
imagePullPolicy: IfNotPresent
19+
securityContext:
20+
capabilities: {}
21+
privileged: false
22+
volumes:
23+
- name: tmp
24+
emptyDir: {}
25+
restartPolicy: Always
26+
dnsPolicy: ClusterFirst
27+
serviceAccountName: default
28+
user: user1
29+
groups:
30+
- system:authenticated

0 commit comments

Comments
 (0)