Skip to content

Commit

Permalink
actions -> verbs
Browse files Browse the repository at this point in the history
  • Loading branch information
php-coder committed Nov 16, 2016
1 parent b708947 commit 89dbf78
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/cmd/admin/policy/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ type NewClusterRoleOptions struct {

Name string
Resources []string
Actions []string
Verbs []string
}

// NewCmdCreateClusterRole implements the OpenShift cli create-cluster-role command.
func NewCmdCreateClusterRole(name, fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command {
options := &NewClusterRoleOptions{}

cmd := &cobra.Command{
Use: name + " <role-name>", // TODO
Use: name + " <role-name>",
Short: "Create a new cluster role",
Long: `Create a new cluster role for specified resources and actions`, // TODO
Long: `Create a new cluster role for specified resources and verbs`,
Example: fmt.Sprintf(createClusterRoleExample, fullName),
Run: func(cmd *cobra.Command, args []string) {
if err := options.Complete(f, args); err != nil {
Expand All @@ -48,7 +48,7 @@ func NewCmdCreateClusterRole(name, fullName string, f *clientcmd.Factory, out io
}

cmd.Flags().StringSliceVarP(&options.Resources, "resources", "", options.Resources, "list of resources (separated by comma)")
cmd.Flags().StringSliceVarP(&options.Actions, "actions", "", options.Actions, "list of actions (separated by comma)")
cmd.Flags().StringSliceVarP(&options.Verbs, "verbs", "", options.Verbs, "list of verbs (separated by comma)")

return cmd
}
Expand Down Expand Up @@ -77,14 +77,14 @@ func (o *NewClusterRoleOptions) Validate() error {
if len(o.Resources) == 0 {
return errors.New("Resources is required")
}
if len(o.Actions) == 0 {
return errors.New("Actions is required")
if len(o.Verbs) == 0 {
return errors.New("Verbs is required")
}
return nil
}

func (o *NewClusterRoleOptions) CreateRole() error {
rule, err := authapi.NewRule(o.Actions...).Resources(o.Resources...).Groups("").Rule()
rule, err := authapi.NewRule(o.Verbs...).Resources(o.Resources...).Groups("").Rule()
if err != nil {
return err
}
Expand Down

0 comments on commit 89dbf78

Please sign in to comment.