-
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.
Add command 'i-have' that shows the permissions one has in GoCD
- Loading branch information
1 parent
9625129
commit 79a2a9c
Showing
6 changed files
with
137 additions
and
18 deletions.
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,38 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func registerIHaveCommand() *cobra.Command { | ||
var entity string | ||
|
||
iCanCmd := &cobra.Command{ | ||
Use: "i-have", | ||
Short: "Command to check the permissions that the current user has", | ||
Long: `Command leverages GoCD permissions api [https://api.gocd.org/current/#permissions] to show all permission that current user has in GoCD`, | ||
PreRunE: setCLIClient, | ||
Args: cobra.NoArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
query := map[string]string{"type": entity} | ||
|
||
response, err := client.GetPermissions(query) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return cliRenderer.Render(response) | ||
}, | ||
} | ||
|
||
iCanCmd.SetUsageTemplate(getUsageTemplate()) | ||
|
||
for _, command := range iCanCmd.Commands() { | ||
command.SilenceUsage = true | ||
} | ||
|
||
iCanCmd.PersistentFlags().StringVarP(&entity, "entity", "e", "", | ||
"type of GoCD entity to filter the permissions") | ||
|
||
return iCanCmd | ||
} |
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,44 @@ | ||
## gocd-cli i-have | ||
|
||
Command to check the permissions that the current user has | ||
|
||
### Synopsis | ||
|
||
Command leverages GoCD permissions api [https://api.gocd.org/current/#permissions] to show all permission that current user has in GoCD | ||
|
||
``` | ||
gocd-cli i-have [flags] | ||
``` | ||
|
||
### Options | ||
|
||
``` | ||
-e, --entity string type of GoCD entity to filter the permissions | ||
-h, --help help for i-have | ||
``` | ||
|
||
### Options inherited from parent commands | ||
|
||
``` | ||
--api-log-level string log level for GoCD API calls, this sets log level to [https://pkg.go.dev/github.com/go-resty/resty/v2#Client.SetLogger],log levels supported by [https://github.com/sirupsen/logrus] will work (default "info") | ||
-t, --auth-token string token to authenticate with GoCD server, should not be co-used with basic auth (username/password) | ||
--ca-file-path string path to file containing CA cert used to authenticate GoCD server, if you have one | ||
--from-file string file containing configurations of objects that needs to be created in GoCD, config-repo/pipeline-group/environment and etc. | ||
--json enable this to Render output in JSON format | ||
-l, --log-level string log level for GoCD cli, log levels supported by [https://github.com/sirupsen/logrus] will work (default "info") | ||
--no-color enable this to Render output in YAML format | ||
-p, --password string password to authenticate with GoCD server | ||
-q, --query string query to filter the results, ex: '.material.attributes.type | id eq git'. this uses library gojsonq beneath | ||
more queries can be found here https://github.com/thedevsaddam/gojsonq/wiki/Queries | ||
--server-url string GoCD server URL base path (default "http://localhost:8153/go") | ||
--skip-cache-config if enabled locally save auth configs would not be used to authenticate GoCD server (path: $HOME/.gocd/auth_config.yaml) | ||
--to-file string file to which the output needs to be written | ||
-u, --username string username to authenticate with GoCD server | ||
--yaml enable this to Render output in YAML format | ||
``` | ||
|
||
### SEE ALSO | ||
|
||
* [gocd-cli](gocd-cli.md) - Command line interface for GoCD | ||
|
||
###### Auto generated by spf13/cobra on 2-Jan-2024 |
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