-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
PSP reviews: client #12478
PSP reviews: client #12478
Conversation
f887fff
to
912e7e9
Compare
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.
CC @openshift/cli-review
pkg/cmd/cli/describe/printer.go
Outdated
|
||
func printPspSubjectReview(pspSubjectReview *securityapi.PodSecurityPolicySubjectReview, w io.Writer, options kctl.PrintOptions) error { | ||
if pspSubjectReview.Status.AllowedBy != nil { | ||
if _, err := fmt.Fprintf(w, "%s\n", pspSubjectReview.Status.AllowedBy.Name); err != nil { |
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.
you can use fmt.Fprinln()
pkg/cmd/cli/describe/printer.go
Outdated
|
||
func printPspSelfSubjectReview(pspSelfSubjectReview *securityapi.PodSecurityPolicySelfSubjectReview, w io.Writer, options kctl.PrintOptions) error { | ||
if pspSelfSubjectReview.Status.AllowedBy != nil { | ||
if _, err := fmt.Fprintf(w, "%s\n", pspSelfSubjectReview.Status.AllowedBy.Name); err != nil { |
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 here.
pkg/cmd/cli/describe/printer.go
Outdated
@@ -1131,3 +1139,36 @@ func printRoleBindingRestrictionList(list *authorizationapi.RoleBindingRestricti | |||
} | |||
return nil | |||
} | |||
|
|||
//pspReviewColumns = []string{"SERVICE ACCOUNT", "ALLOWED BY"} |
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.
is this comment related to the function?
pkg/cmd/admin/policy/psp_review.go
Outdated
return cmd | ||
} | ||
|
||
func returnPodTemplateSpec(obj runtime.Object) (*kapi.PodTemplateSpec, error) { |
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.
@smarterclayton don't we have this as helper in kube or origin (for things like oc set image)
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.
We do - it's on the factory.
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.
It's in
Line 52 in 283a990
func GetPodSpec(obj runtime.Object) (*kapi.PodSpec, *field.Path, error) { |
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.
@soltysh that func
returns a PodSpec
while here we need a PodTemplateSpec
(with the right meta
) In factory as pointed out by @smarterclayton I found this
My only concern is that upstream AttachablePodForObject
invoked here
does not handle batch.CronJob
and apps.StatefulSet
which I would say it's a bug...
I'm going to submit an upstream PR if you agree.
pkg/cmd/admin/policy/psp_review.go
Outdated
func NewCmdReview(name, fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command { | ||
o := &reviewOptions{} | ||
cmd := &cobra.Command{ | ||
Use: fmt.Sprintf("%s", 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.
no need for Sprintf
pkg/cmd/admin/policy/psp_review.go
Outdated
return fmt.Errorf("unable to find a resource: %v", err) | ||
} | ||
if len(infos) != 1 { | ||
return fmt.Errorf("expected a resource for path: %s", o.Filename) |
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.
expected a single resource?
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 raised the point int here and we agreed that only one resource should be handled
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.
Hmmm... that's not quite how I'm reading this. I'd say we want to be able to pass a list of resources and handle that. Generally, this entire code should go into Run
. Not quite sure what to do with PrintObject
, yet, but I'll get to that.
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.
What if a user pass a directory with multiple files, we want to handle those.
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.
So we're going to handle -R
handling recursion as well?
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.
That's what I understood from the discussion we've had the other day.
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.
OK, I understood exactly the opposite. Only one resource and no -R
:)
Anyway, reworking it to have multiple resources.
pkg/cmd/admin/policy/psp_review.go
Outdated
if err != nil { | ||
return fmt.Errorf("unable to obtain client: %v", err) | ||
} | ||
o.client = oclient |
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.
o.client, _, err := f.Clients()
if err != nil {}
pkg/cmd/admin/policy/psp_review.go
Outdated
The Pod is inferred from the PodTemplateSpec in the provided resource. | ||
If no ServiceAccount is provided the ServiceAccount specified in podTemplateSpec.spec.serviceAccountName is used, | ||
unless the podTemplateSpec.spec.serviceAccountName is empty, in which case "default" is used. | ||
If ServiceAccounts are provided the podTemplateSpec.spec.serviceAccountName is ignored.`) |
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.
can you add newline here?
pkg/cmd/admin/policy/psp_review.go
Outdated
|
||
// Related to PodSecurityPolicyReview | ||
var ( | ||
reviewLong = templates.LongDesc(`Checks which ServiceAccount can create a Pod. |
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.
Checks which Service Account can create a Pod
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.
Move to separate file, please. And like mentioned before, try to keep the flow similar to how other commands are.
pkg/cmd/admin/policy/psp_review.go
Outdated
}, | ||
} | ||
|
||
cmd.Flags().StringVarP(&o.User, "user", "u", o.User, "User") |
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.
maybe add more description to "User"?
@mfojtik thanks!. Going to wait for Clayton feedback and I'll modify accordingly |
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.
Left you some comments.
pkg/cmd/admin/policy/psp_review.go
Outdated
|
||
// PodSecurityPolicySubjectReview and PodSecurityPolicySelfSubjectReview | ||
var ( | ||
subjectReviewLong = templates.LongDesc(`Check whether a User, ServiceAccount, Group can create a Pod. |
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.
a User, ServiceAcount, or a Group...
pkg/cmd/admin/policy/psp_review.go
Outdated
// PodSecurityPolicySubjectReview and PodSecurityPolicySelfSubjectReview | ||
var ( | ||
subjectReviewLong = templates.LongDesc(`Check whether a User, ServiceAccount, Group can create a Pod. | ||
If "User" is specified but not "Group", the it is interpreted as "What if User were not member of any groups". |
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.
theit is interpreted as "What if User is not a member of any group"
and I wouldn't quote User nor Group.
pkg/cmd/admin/policy/psp_review.go
Outdated
var ( | ||
subjectReviewLong = templates.LongDesc(`Check whether a User, ServiceAccount, Group can create a Pod. | ||
If "User" is specified but not "Group", the it is interpreted as "What if User were not member of any groups". | ||
If "User" and "Groups" are empty, then the check is performed using *only* the ServiceAccountName in the PodTemplateSpec`) |
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.
If User and Group is empty, the check is ...
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.
Btw. iirc from the discussion we've had in the trello, not specifying user nor group would result in SelfSubjectReview, which means against current user, has something changed here?
pkg/cmd/admin/policy/psp_review.go
Outdated
return nil | ||
} | ||
|
||
func NewCmdSubjectReview(name, fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command { |
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.
<me ranting>
It's nice and readable to have the NewCmd* function right after *Options structure.
</me ranting>
pkg/cmd/admin/policy/psp_review.go
Outdated
kcmdutil.CheckErr(kcmdutil.UsageError(cmd, err.Error())) | ||
} | ||
err := o.Run(out) | ||
kcmdutil.CheckErr(err) |
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 body of this method should go towards:
kcmdutil.CheckErr(opts.Complete(f, cmd, args, out))
kcmdutil.CheckErr(opts.Validate())
kcmdutil.CheckErr(opts.Run())
Not sure if you need Validate
, yet ;)
pkg/cmd/admin/policy/psp_review.go
Outdated
|
||
response, err := o.client.PodSecurityPolicyReviews(o.Namespace).Create(review) | ||
if err != nil { | ||
return fmt.Errorf("unable to compute PSP rviews: %v", err) |
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.
typo: reviews, beside use full name Pod Security Policy Review
pkg/cmd/admin/policy/psp_review.go
Outdated
if err != nil { | ||
return fmt.Errorf("unable to find a resource: %v", err) | ||
} | ||
if len(infos) != 1 { |
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 limitation, we don't want to have.
pkg/cmd/admin/policy/psp_review.go
Outdated
func NewCmdSubjectReview(name, fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command { | ||
o := &subjectReviewOptions{} | ||
cmd := &cobra.Command{ | ||
Use: fmt.Sprintf("%s", 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 here about not using Sprintf.
pkg/cmd/admin/policy/psp_review.go
Outdated
Long: reviewLong, | ||
Example: fmt.Sprintf(reviewExamples, fullName), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if err := o.Complete(f, args, cmd); err != nil { |
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.
Now I can say validate is not needed, but the shape here should be:
kcmdutil.CheckErr(opts.Complete(f, cmd, args, out))
kcmdutil.CheckErr(opts.Run())
pkg/cmd/admin/policy/psp_review.go
Outdated
return cmd | ||
} | ||
|
||
func returnPodTemplateSpec(obj runtime.Object) (*kapi.PodTemplateSpec, error) { |
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.
It's in
Line 52 in 283a990
func GetPodSpec(obj runtime.Object) (*kapi.PodSpec, *field.Path, error) { |
39d93f8
to
a72ddcd
Compare
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.
My comments apply to both commands, if mentioned only in one file :)
pkg/cmd/cli/describe/printer.go
Outdated
@@ -1131,3 +1139,34 @@ func printRoleBindingRestrictionList(list *authorizationapi.RoleBindingRestricti | |||
} | |||
return nil | |||
} | |||
|
|||
func printPspReview(pspreview *securityapi.PodSecurityPolicyReview, w io.Writer, options kctl.PrintOptions) error { | |||
for _, allowedSA := range pspreview.Status.AllowedServiceAccounts { |
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.
If we're not allowed, we need to say so. This applies to all three printPsp*
methods.
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.
btw. name methods, printPSPReview*
, PSP here is an acronym, so it should be spelled like one.
pkg/cmd/admin/policy/review.go
Outdated
securityapi "github.com/openshift/origin/pkg/security/api" | ||
) | ||
|
||
// Related to PodSecurityPolicyReview |
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.
Comment not needed, since you split that to separate files.
securityapi "github.com/openshift/origin/pkg/security/api" | ||
) | ||
|
||
// PodSecurityPolicySubjectReview and PodSecurityPolicySelfSubjectReview |
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, not needed.
pkg/cmd/admin/policy/review.go
Outdated
var ( | ||
reviewLong = templates.LongDesc(`Checks which Service Account can create a Pod. | ||
The Pod is inferred from the PodTemplateSpec in the provided resource. | ||
If no Service Account is provided the Service Account specified in podTemplateSpec.spec.serviceAccountName is used, |
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.
If not Service Account is provided the one specified in ...
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.
unless the podTemplateSpec.spec.serviceAccoutName it is empty, ...
pkg/cmd/admin/policy/review.go
Outdated
Infos() | ||
if err != nil { | ||
return err | ||
} |
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.
That block should be moved to Run
, not needed here.
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.
Or change it to return you just the builder object.
pkg/cmd/admin/policy/review.go
Outdated
if err != nil { | ||
return err | ||
} | ||
o.printer = kubectl.NewVersionedPrinter(p, kapi.Scheme, version) |
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'm not sure we need this block. If you care about raw output you can always hit the endpoint by yourself. This is a convenience command, that gives you nice output. Similarly to how oc import-image
works. In that case just go with the describer and you'll be good.
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.
Btw. you're missing the actual implementation of a PSP* describers in https://github.com/openshift/origin/blob/master/pkg/cmd/cli/describe/describer.go
@soltysh thanks for the review! PTAL |
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.
Some minor nits in the form but most importantly I'm missing tests for this in test-cmd.sh. Make sure to have a few positive tests and negative, where you're trying to check an object that does not have PodTemplate.
pkg/cmd/admin/policy/review.go
Outdated
ServiceAccountNames []string | ||
|
||
//AllServiceAccounts bool TODO: defines a way in the API to defines all service accounts | ||
approximatePodTemplateForObject func(runtime.Object) (*kapi.PodTemplateSpec, error) |
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 like to have the options nicely sorted external values, set by users (ServiceAccountNames, FilenameOptions in your case) and internal values. Reads better :-)
FilenameOptions resource.FilenameOptions | ||
User string | ||
Groups []string | ||
ServiceAccount string |
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 wrt to options.
pkg/cmd/admin/policy/review.go
Outdated
}, | ||
} | ||
|
||
usage := "Filename, directory, or URL to a file identifying the resource to get from a server." |
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.
No need for value, just put into below function.
} | ||
|
||
switch { | ||
case len(userOrSA) > 0 || len(o.Groups) > 0: |
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 doubt you'll be doing both at the same time, either you do specify user and/or group or you don't and invoke self check. I'd split that into two methods one for each check. The code for the two can be shared start from line 148 until 154. The only difference will be setting .spec.User
and/or .spec.Groups
fields and the actual client calls. Printing should be shared as well.
pkg/cmd/admin/policy/review.go
Outdated
kcmdutil.AddFilenameOptionFlags(cmd, &o.FilenameOptions, usage) | ||
|
||
cmd.Flags().StringSliceVarP(&o.ServiceAccountNames, "serviceaccounts", "s", o.ServiceAccountNames, "List of ServiceAccount names, comma separated") | ||
// TODO: defines a way in the API to defines all service accounts: removing omitempty for PodSecurityPolicyReviewSpec.ServiceAccountNames? |
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.
You're missing kcmdutil.AddPrinterFlags(cmd)
.
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.
Right
This doesn't seem to work as I expect:
It looks from |
When I run this from cluster admin, I got this instead:
My job.yaml for tests is:
|
af4ca23
to
a1898d9
Compare
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.
Some more comments.
) | ||
|
||
var ( | ||
subjectReviewLong = templates.LongDesc(`Check whether a User, Service Account or a Group can create a Pod. |
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.
Maybe a word or two that it returns a list of SCC that will allow creating those. I've struggled for a second what's the return value 😉
pkg/cmd/admin/policy/review.go
Outdated
FilenameOptions resource.FilenameOptions | ||
ServiceAccountNames []string | ||
|
||
//AllServiceAccounts bool TODO: defines a way in the API to defines all service accounts |
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.
IIRC, this is should be no more.
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.
going to write a PR to remove in APIs as well.
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.
API agreed, here should be removed within this PR.
pkg/cmd/admin/policy/review.go
Outdated
|
||
cmd.Flags().StringSliceVarP(&o.ServiceAccountNames, "serviceaccounts", "s", o.ServiceAccountNames, "List of ServiceAccount names, comma separated") | ||
// TODO: defines a way in the API to defines all service accounts: removing omitempty for PodSecurityPolicyReviewSpec.ServiceAccountNames? | ||
//cmd.Flags().BoolVar(&o.AllServiceAccounts, "allserviceaccounts", false, "If true, all accessible service accounts will be considered") |
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 - 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.
same
pkg/cmd/admin/policy/review.go
Outdated
} | ||
|
||
func (o *reviewOptions) Complete(f *clientcmd.Factory, args []string, cmd *cobra.Command, out io.Writer) error { | ||
if len(args) == 0 && len(o.FilenameOptions.Filenames) == 0 { |
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.
You need something like that in subject_review.go
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.
:\ ok, thanks
pkg/cmd/cli/describe/printer.go
Outdated
|
||
func printPSPReview(pspreview *securityapi.PodSecurityPolicyReview, w io.Writer, options kctl.PrintOptions) error { | ||
for _, allowedSA := range pspreview.Status.AllowedServiceAccounts { | ||
allowedByName := "Not allowed" |
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.
Maybe <none>
rather than 'Not allowed', so it's easier to spot.
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.
ok
pkg/cmd/cli/describe/printer.go
Outdated
return err | ||
} | ||
} else { | ||
if _, err := fmt.Fprintln(w, "Not allowed"); err != nil { |
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 <none>
here and below. @fabianofranz wdyt?
test/cmd/policy.sh
Outdated
os::cmd::expect_success_and_text 'oc policy subject-review -z default -g system:authenticated -f ${OS_ROOT}/test/testdata/job.yaml' 'restricted' | ||
os::cmd::expect_success 'oc create -f ${OS_ROOT}/test/testdata/scc_lax.yaml' | ||
os::cmd::expect_success "oc login -u bob -p bob" | ||
os::cmd::expect_success_and_text 'oc policy review -f ./test/testdata/job.yaml --no-headers=true' 'default lax' |
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.
Use ${OS_ROOT}/test/testdata/job.yaml
test/cmd/policy.sh
Outdated
os::cmd::expect_success "oc login -u bob -p bob" | ||
os::cmd::expect_success_and_text 'oc policy review -f ./test/testdata/job.yaml --no-headers=true' 'default lax' | ||
os::cmd::expect_success "oc login -u system:admin -n '${project}'" | ||
os::cmd::expect_success 'oc delete project bob' |
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.
It would be nice if you could use different resources for each test, iow. job, deployment, just pod, etc.
a1898d9
to
81bdcca
Compare
[test] |
This LGTM, thank you Dario! Now we need @openshift/cli-review approval for the cli part and @pweil- sign off, if we want to merge this for 1.5 |
81bdcca
to
b350cd5
Compare
@soltysh added code to verify |
bump @openshift/cli-review |
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.
Also, please check godoc on all public methods.
pkg/cmd/admin/policy/review.go
Outdated
`) | ||
) | ||
|
||
const ReviewRecommendedName = "review" |
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.
these names may be confusing. Should we prefix with psp
or scc
(or register with both)?
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 agree it would be good to prefix them with either, although I am not sure which prefix would best help describe this
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.
psp may be confusing until it's turned on in OpenShift. I'd go with scc if we go with any prefix
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.
Modified both to scc-review
and scc-subject-review
.
Data strcture changed as well
test/cmd/policy.sh
Outdated
@@ -97,6 +97,31 @@ os::cmd::expect_success_and_not_text 'oc policy can-i --list --groups system:una | |||
os::cmd::expect_success_and_not_text 'oc policy can-i --list --user harold --groups system:authenticated' 'get update.*imagestreams/layers' | |||
os::cmd::expect_success_and_text 'oc policy can-i --list --user harold --groups system:authenticated' 'create get.*buildconfigs/webhooks' | |||
|
|||
os::cmd::expect_failure_and_text 'oc policy subject-review -f ${OS_ROOT}/test/testdata/pspreview_unsupported_statefulset.yaml' 'error: StatefulSet "rd" with spec.volumeClaimTemplates currently not supported.' |
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.
add tests for invalid input that is checked by Complete
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.
done
A few comments from @pweil- , but other than that this LGTM from a cli perspective |
pkg/cmd/admin/policy/review.go
Outdated
ContinueOnError(). | ||
Flatten(). | ||
Do(). | ||
Infos() |
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.
Although I would not be opposed if not done this way, having this block return a resource.Result
, and then using the result's .Visitor(func...)
to iterate through each info would match how this is done in other commands.
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.
Done
@pweil- @juanvallejo thanks for the feedback, I'm modifying. |
b350cd5
to
2e32743
Compare
No squash and no code generated. As soon you're OK I'll follow up. |
@pweil- oh well, I'm getting old 😝 |
[test] |
@pweil- mering or leaving out for now? |
double checking priority of this with PM since it is low risk (new commands). My recommendation though is that we get this in a fork ami so it can be tested and merge to master AFTER the 3.5 cut. |
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.
Comments from https://bugzilla.redhat.com/show_bug.cgi?id=1421570 and https://bugzilla.redhat.com/show_bug.cgi?id=1421616 needs addressing. One I've pointed above. The other is about printing resource file name or resource name (depending on what's doable) before printing the actual result of the check. This applies to both commands.
pkg/cmd/admin/policy/review.go
Outdated
}, | ||
} | ||
|
||
cmd.Flags().StringSliceVarP(&o.ServiceAccountNames, "serviceaccounts", "s", o.ServiceAccountNames, "List of ServiceAccount names, comma separated") |
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.
Shorthand should be -z
to be consistent with other commands where serviceaccounts are specified.
I'm taking back my LGTM, until comments from BZ are fixed. |
6ffc033
to
eabb7e4
Compare
@soltysh PTAL |
Flake #11452. [test] |
Actually that was #12995 and it happened again. I'm not gonna re-kick it. |
This looks LGTM. |
I'm re-running tests to get a clean pass. Previously it was flake #12995. [test] |
@smarterclayton this will be merged when last issues is address, @sdminonne is currently working on a fix. Additionally, this will be cherry-picked into 1.5 release. So I'm removing your merge tag for now. |
eabb7e4
to
20bcb5d
Compare
@soltysh: PTAL |
This LGTM. I'm spinning fork_ami and let qa test it. |
Flake #9490. re-[test] |
Evaluated for origin test up to 20bcb5d |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_future/400/) (Base Commit: 2d20080) |
Evaluated for origin merge up to 20bcb5d |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_future/415/) (Base Commit: 0ea6f5d) (Image: devenv-rhel7_5954) |
@soltysh Thanks to have a look. For
all-service-accounts
flags I'm going to propose a fix for the API (working on it).