Skip to content

Commit

Permalink
Update show_permissions_cmd.go
Browse files Browse the repository at this point in the history
  • Loading branch information
agmimidi authored Apr 2, 2024
1 parent 098f320 commit 3dfe3e9
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions cmd/show_permissions_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import (
func NewCommandGenerateShowPermissions() *cobra.Command {

clusterContext := ""
generateKind := "ClusterRole"
forGroups := []string{"*"}
withVerb := []string{"*"}
scope := "cluster"
denyVerb := []string{}
denyResource := []string{}
namespace := ""
roleName := ""

// Support overrides
cmd := &cobra.Command{
Expand Down Expand Up @@ -85,14 +86,20 @@ rbac-tool show --scope=namespaced --without-verbs=create,update,patch,delete,del
}

if scope == "namespaced" {
generateKind = "Role"
}
obj, err := generateRole(generateKind, computedPolicyRules)
if err != nil {
return err
}
obj, err := generateRole(computedPolicyRules, namespace, roleName)
if err != nil {
return err
}

fmt.Fprintln(os.Stdout, obj)
} else {
obj, err := generateClusterRole(computedPolicyRules, roleName)
if err != nil {
return err
}

fmt.Fprintln(os.Stdout, obj)
fmt.Fprintln(os.Stdout, obj)
}

return nil
},
Expand Down

0 comments on commit 3dfe3e9

Please sign in to comment.