Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): adding logout examples #15834

Closed
wants to merge 9 commits into from
7 changes: 7 additions & 0 deletions cmd/argocd/commands/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ compdef _argocd argocd
Optionally, also add the following, in case you are getting errors involving compdef & compinit such as command not found: compdef:
autoload -Uz compinit
compinit
`,
Example: `# For bash
$ source <(argocd completion bash)
# For zsh
$ argocd completion zsh > _argocd
$ source _argocd
`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) != 1 {
Expand Down
8 changes: 8 additions & 0 deletions cmd/argocd/commands/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ func NewContextCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
Use: "context [CONTEXT]",
Aliases: []string{"ctx"},
Short: "Switch between contexts",
Example: `# List Argo CD Contexts
argocd context
# Switch Argo CD context
argocd context cd.argoproj.io
# Delete Argo CD context
argocd context cd.argoproj.io --delete`,
Run: func(c *cobra.Command, args []string) {

localCfg, err := localconfig.ReadLocalConfig(clientOpts.ConfigPath)
Expand Down
20 changes: 19 additions & 1 deletion cmd/argocd/commands/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,32 @@ import (
argocdclient "github.com/argoproj/argo-cd/v2/pkg/apiclient"
"github.com/argoproj/argo-cd/v2/util/errors"
"github.com/argoproj/argo-cd/v2/util/localconfig"
"github.com/argoproj/argo-cd/v2/util/templates"
)

var (
logoutExample = templates.Examples(`
# Basic Logout
argocd logout

# Logout from a Specific Server
argocd logout --server https://argocd-server.example.com

# Logout via Skipping Certificate Validation
argocd logout --insecure

# Logout from a Specific Context
argocd logout my-argocd-context
`)
)

// NewLogoutCommand returns a new instance of `argocd logout` command
func NewLogoutCommand(globalClientOpts *argocdclient.ClientOptions) *cobra.Command {
var command = &cobra.Command{
Use: "logout CONTEXT",
Short: "Log out from Argo CD",
Long: "Log out from Argo CD",
Example: logoutExample,
Long: "Log out from Argo CD",
Run: func(c *cobra.Command, args []string) {
if len(args) == 0 {
c.HelpFunc()(c, args)
Expand Down
7 changes: 4 additions & 3 deletions cmd/argocd/commands/relogin.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ func NewReloginCommand(globalClientOpts *argocdclient.ClientOptions) *cobra.Comm
ssoPort int
)
var command = &cobra.Command{
Use: "relogin",
Short: "Refresh an expired authenticate token",
Long: "Refresh an expired authenticate token",
Use: "relogin",
Short: "Refresh an expired authenticate token",
Long: "Refresh an expired authenticate token",
Example: "argocd relogin --password YOUR_PASSWORD",
Run: func(c *cobra.Command, args []string) {
ctx := c.Context()

Expand Down
12 changes: 12 additions & 0 deletions docs/user-guide/commands/argocd_completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ compinit
argocd completion SHELL [flags]
```

### Examples

```
# For bash
$ source <(argocd completion bash)
# For zsh
$ argocd completion zsh > _argocd
$ source _argocd
```

### Options

```
Expand Down
13 changes: 13 additions & 0 deletions docs/user-guide/commands/argocd_context.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ Switch between contexts
argocd context [CONTEXT] [flags]
```

### Examples

```
# List Argo CD Contexts
argocd context
# Switch Argo CD context
argocd context cd.argoproj.io
# Delete Argo CD context
argocd context cd.argoproj.io --delete
```

### Options

```
Expand Down
17 changes: 17 additions & 0 deletions docs/user-guide/commands/argocd_logout.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ Log out from Argo CD
argocd logout CONTEXT [flags]
```

### Examples

```
# To log out of argocd
$ argocd logout
# This can be helpful for security reasons or when you want to switch between different Argo CD contexts or accounts.

# Logout from a Specific Server
argocd logout --server https://argocd-server.example.com

# Logout via Skipping Certificate Validation
argocd logout --insecure

# Logout from a Specific Context
argocd logout my-argocd-context
```

### Options

```
Expand Down
6 changes: 6 additions & 0 deletions docs/user-guide/commands/argocd_relogin.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ Refresh an expired authenticate token
argocd relogin [flags]
```

### Examples

```
argocd relogin --password YOUR_PASSWORD
```

### Options

```
Expand Down
52 changes: 46 additions & 6 deletions manifests/ha/base/redis-ha/chart/upstream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,13 @@ spec:
args:
- /readonly/haproxy_init.sh
securityContext:
null
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
volumeMounts:
- name: config-volume
mountPath: /readonly
Expand All @@ -1106,7 +1112,13 @@ spec:
image: haproxy:2.6.14-alpine
imagePullPolicy: IfNotPresent
securityContext:
null
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
livenessProbe:
httpGet:
path: /healthz
Expand Down Expand Up @@ -1204,7 +1216,14 @@ spec:
args:
- /readonly-config/init.sh
securityContext:
null
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
env:
- name: SENTINEL_ID_0
value: 3c0d9c0320bb34888c2df5757c718ce6ca992ce6
Expand All @@ -1229,7 +1248,14 @@ spec:
args:
- /data/conf/redis.conf
securityContext:
null
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
livenessProbe:
initialDelaySeconds: 30
periodSeconds: 15
Expand Down Expand Up @@ -1279,7 +1305,14 @@ spec:
args:
- /data/conf/sentinel.conf
securityContext:
null
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
livenessProbe:
initialDelaySeconds: 30
periodSeconds: 15
Expand Down Expand Up @@ -1323,7 +1356,14 @@ spec:
args:
- /readonly-config/fix-split-brain.sh
securityContext:
null
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
env:
- name: SENTINEL_ID_0
value: 3c0d9c0320bb34888c2df5757c718ce6ca992ce6
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/fixture/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ func EnsureCleanState(t *testing.T, opts ...TestOption) {
// set-up tmp repo, must have unique name
FailOnErr(Run("", "cp", "-Rf", opt.testdata, repoDirectory()))
FailOnErr(Run(repoDirectory(), "chmod", "777", "."))
FailOnErr(Run(repoDirectory(), "git", "init"))
FailOnErr(Run(repoDirectory(), "git", "init", "-b", "master"))
FailOnErr(Run(repoDirectory(), "git", "add", "."))
FailOnErr(Run(repoDirectory(), "git", "commit", "-q", "-m", "initial commit"))

Expand Down Expand Up @@ -876,7 +876,7 @@ func CreateSubmoduleRepos(repoType string) {
// set-up submodule repo
FailOnErr(Run("", "cp", "-Rf", "testdata/git-submodule/", submoduleDirectory()))
FailOnErr(Run(submoduleDirectory(), "chmod", "777", "."))
FailOnErr(Run(submoduleDirectory(), "git", "init"))
FailOnErr(Run(submoduleDirectory(), "git", "init", "-b", "master"))
FailOnErr(Run(submoduleDirectory(), "git", "add", "."))
FailOnErr(Run(submoduleDirectory(), "git", "commit", "-q", "-m", "initial commit"))

Expand All @@ -888,7 +888,7 @@ func CreateSubmoduleRepos(repoType string) {
// set-up submodule parent repo
FailOnErr(Run("", "mkdir", submoduleParentDirectory()))
FailOnErr(Run(submoduleParentDirectory(), "chmod", "777", "."))
FailOnErr(Run(submoduleParentDirectory(), "git", "init"))
FailOnErr(Run(submoduleParentDirectory(), "git", "init", "-b", "master"))
FailOnErr(Run(submoduleParentDirectory(), "git", "add", "."))
if IsRemote() {
FailOnErr(Run(submoduleParentDirectory(), "git", "submodule", "add", "-b", "master", os.Getenv("ARGOCD_E2E_GIT_SERVICE_SUBMODULE"), "submodule/test"))
Expand Down