-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rockset/cli/format" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func newListRolesCommand() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "role", | ||
Aliases: []string{"r", "roles"}, | ||
Args: cobra.NoArgs, | ||
Short: "list roles", | ||
Annotations: group("role"), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
ctx := cmd.Context() | ||
rs, err := rockClient(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
aliases, err := rs.ListRoles(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return formatList(cmd, format.ToInterfaceArray(aliases)) | ||
}, | ||
} | ||
|
||
return cmd | ||
} | ||
|
||
func newGetRoleCommand() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "role NAME", | ||
Aliases: []string{"r"}, | ||
Args: cobra.ExactArgs(1), | ||
Short: "get role information", | ||
Annotations: group("role"), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
ctx := cmd.Context() | ||
rs, err := rockClient(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
alias, err := rs.GetRole(ctx, args[0]) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return formatOne(cmd, alias) | ||
}, | ||
} | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package format | ||
|
||
import "github.com/rockset/rockset-go-client/openapi" | ||
|
||
var RoleDefaultSelector = DefaultSelector{ | ||
Normal: "Name:.role_name,Created By:.created_by", | ||
Wide: "Name:.role_name,Created By:.created_by,Description:.description", | ||
} | ||
|
||
// just to list available fields | ||
var _ = openapi.Role{ | ||
CreatedAt: nil, | ||
CreatedBy: nil, | ||
Description: nil, | ||
OwnerEmail: nil, | ||
Privileges: nil, | ||
RoleName: nil, | ||
} |