argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
17.94k stars 5.46k forks source link

Fluent `argocd context` command #19867

Open eugene70 opened 2 months ago

eugene70 commented 2 months ago

In Argo-CD CLI, cluster context is managed through argocd context and argocd login commands. However, these context management commands are a bit different from other command systems, so they can be confusing for beginners. So I want to provide rich functionality by providing various subcommands for the argocd context command, such as the argocd app command. Example:

argocd context list
argocd context delete <context>
argocd context use <context>
argocd context login <context> [<server>]
argocd context login <context> --core
argocd context logout <context>
argocd context # for compatibility = context list
argocd context —delete <server> # for compatibility = context delete
argocd login <server> —name <context> # for compatibility = context login
argocd logout <context> # for compatibility = context logout
nueavv commented 2 months ago

I think this would be a valuable improvement. We manage multiple clusters, each with its own ArgoCD instance, and many of our developers are familiar with kubectl syntax. Because of that, they often find the ArgoCD syntax difficult to use. Making the syntax more intuitive or closer to kubectl could significantly improve the user experience for many teams.

eugene70 commented 2 months ago

If it's okay, I'd like to implement it.

eugene70 commented 1 month ago

I wrote down the usage before proceeding with the task.

Manage contexts

Usage:
  argocd context [flags]
  argocd context [command]

Examples:
  # List Argo CD contexts.
  argocd context list

  # Login to Argo CD using a username and password and update context  
  argocd context login CONTEXT SERVER

  # Login to Argo CD context using a username and password  
  argocd context login # login to current context
  argocd context login CONTEXT

  # Switch Argo CD context
  argocd context CONTEXT # for compatibility
  argocd context use CONTEXT

  # Get the details of a context
  argocd context get CONTEXT

  # Delete a context
  argocd context delete CONTEXT
  argocd context CONTEXT --delete # for compatibility

Available Commands:
  get         Get context details
  delete      Delete a context
  list        List contexts
  login       Login to Argo CD using a username and password
  logout      Logout current context or specified context
  use         Switch current context
andrii-korotkov-verkada commented 5 days ago

Looks great! I can take a look at your PR once ready (tho I don't have approvers permissions yet).