Skip to content

Commit

Permalink
feat(cli): Add examples to --help output for remaining "argocd repocr…
Browse files Browse the repository at this point in the history
…eds" cmds (argoproj#15846)

Signed-off-by: Michele Caci <michele.caci@gmail.com>
  • Loading branch information
mcaci authored and tesla59 committed Dec 16, 2023
1 parent 0d80743 commit 7fa78ac
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cmd/argocd/commands/repocreds.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,24 @@ import (
"github.com/argoproj/argo-cd/v2/util/errors"
"github.com/argoproj/argo-cd/v2/util/git"
"github.com/argoproj/argo-cd/v2/util/io"
"github.com/argoproj/argo-cd/v2/util/templates"
)

// NewRepoCredsCommand returns a new instance of an `argocd repocreds` command
func NewRepoCredsCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "repocreds",
Short: "Manage repository connection parameters",
Example: templates.Examples(`
# Add credentials with user/pass authentication to use for all repositories under the specified URL
argocd repocreds add URL --username USERNAME --password PASSWORD
# List all the configured repository credentials
argocd repocreds list
# Remove credentials for the repositories with speficied URL
argocd repocreds rm URL
`),
Run: func(c *cobra.Command, args []string) {
c.HelpFunc()(c, args)
os.Exit(1)
Expand Down Expand Up @@ -184,6 +195,10 @@ func NewRepoCredsRemoveCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
var command = &cobra.Command{
Use: "rm CREDSURL",
Short: "Remove repository credentials",
Example: templates.Examples(`
# Remove credentials for the repositories with URL https://git.example.com/repos
argocd repocreds rm https://git.example.com/repos/
`),
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()

Expand Down Expand Up @@ -231,6 +246,13 @@ func NewRepoCredsListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Comm
var command = &cobra.Command{
Use: "list",
Short: "List configured repository credentials",
Example: templates.Examples(`
# List all the configured repository credentials
argocd repocreds list
# List all the configured repository credentials in json format
argocd repocreds list -o json
`),
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()

Expand Down
13 changes: 13 additions & 0 deletions docs/user-guide/commands/argocd_repocreds.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ Manage repository connection parameters
argocd repocreds [flags]
```

### Examples

```
# Add credentials with user/pass authentication to use for all repositories under the specified URL
argocd repocreds add URL --username USERNAME --password PASSWORD
# List all the configured repository credentials
argocd repocreds list
# Remove credentials for the repositories with speficied URL
argocd repocreds rm URL
```

### Options

```
Expand Down
10 changes: 10 additions & 0 deletions docs/user-guide/commands/argocd_repocreds_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ List configured repository credentials
argocd repocreds list [flags]
```

### Examples

```
# List all the configured repository credentials
argocd repocreds list
# List all the configured repository credentials in json format
argocd repocreds list -o json
```

### Options

```
Expand Down
7 changes: 7 additions & 0 deletions docs/user-guide/commands/argocd_repocreds_rm.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ Remove repository credentials
argocd repocreds rm CREDSURL [flags]
```

### Examples

```
# Remove credentials for the repositories with URL https://git.example.com/repos
argocd repocreds rm https://git.example.com/repos/
```

### Options

```
Expand Down

0 comments on commit 7fa78ac

Please sign in to comment.