Skip to content

Commit

Permalink
Allow arbitrary verbs for the rakkess resource subcommand
Browse files Browse the repository at this point in the history
PodSecurityPolicies usually have a ClusterRole with verb "use". As the verbs in clusterroles is arbitrary anyway, it is now allowed to evaluate for arbitrary words.
  • Loading branch information
Cornelius Weig committed Jun 28, 2019
1 parent 1df34c4 commit b4dd597
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/rakkess/client/result/subject.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type SubjectAccess struct {
ResourceName string
// roles holds all rule data concerning this resource and is extracted from Roles and ClusterRoles.
roles map[RoleRef]sets.String
// roles holds all subject access data for this resource and is extracted from RoleBindings and ClusterRoleBindings.
// subjectAccess holds all subject access data for this resource and is extracted from RoleBindings and ClusterRoleBindings.
subjectAccess map[SubjectRef]sets.String
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/rakkess/rakkess.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func Resource(ctx context.Context, opts *options.RakkessOptions) error {
// prints the result as a matrix with verbs in the horizontal and subject names
// in the vertical direction.
func Subject(opts *options.RakkessOptions, resource, resourceName string) error {
if err := validation.Options(opts); err != nil {
if err := validation.OutputFormat(opts.OutputFormat); err != nil {
return err
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/rakkess/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ func Options(opts *options.RakkessOptions) error {
if err := verbs(opts.Verbs); err != nil {
return err
}
return outputFormat(opts.OutputFormat)
return OutputFormat(opts.OutputFormat)
}

func outputFormat(format string) error {
func OutputFormat(format string) error {
for _, o := range constants.ValidOutputFormats {
if o == format {
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/rakkess/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestOutputFormat(t *testing.T) {

for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
actual := outputFormat(test.format)
actual := OutputFormat(test.format)
if test.expected != "" {
assert.EqualError(t, actual, test.expected)
} else {
Expand Down

0 comments on commit b4dd597

Please sign in to comment.