Skip to content

feat(login-cli): Add arguments for port forwarding settings to persist while using the CLI #22521

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions cmd/argocd/commands/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,29 @@ argocd login cd.argoproj.io --core`,
if localCfg == nil {
localCfg = &localconfig.LocalConfig{}
}
localCfg.UpsertServer(localconfig.Server{
Server: server,
PlainText: globalClientOpts.PlainText,
Insecure: globalClientOpts.Insecure,
GRPCWeb: globalClientOpts.GRPCWeb,
GRPCWebRootPath: globalClientOpts.GRPCWebRootPath,
Core: globalClientOpts.Core,
})

if globalClientOpts.PortForward && globalClientOpts.PortForwardNamespace != "" {
localCfg.UpsertServer(localconfig.Server{
Server: server,
PlainText: globalClientOpts.PlainText,
Insecure: globalClientOpts.Insecure,
GRPCWeb: globalClientOpts.GRPCWeb,
GRPCWebRootPath: globalClientOpts.GRPCWebRootPath,
Core: globalClientOpts.Core,
PortForward: globalClientOpts.PortForward,
PortForwardNamespace: globalClientOpts.PortForwardNamespace,
})
} else {
localCfg.UpsertServer(localconfig.Server{
Server: server,
PlainText: globalClientOpts.PlainText,
Insecure: globalClientOpts.Insecure,
GRPCWeb: globalClientOpts.GRPCWeb,
GRPCWebRootPath: globalClientOpts.GRPCWebRootPath,
Core: globalClientOpts.Core,
})
}

localCfg.UpsertUser(localconfig.User{
Name: ctxName,
AuthToken: tokenString,
Expand Down
4 changes: 4 additions & 0 deletions util/localconfig/localconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ type Server struct {
PlainText bool `json:"plain-text,omitempty"`
// Core indicates to talk to Kubernetes API without using Argo CD API server
Core bool `json:"core,omitempty"`
// PortForward enables automatic port forwarding when the ArgoCD CLI communicates with the API server
PortForward bool `json:"port-forward,omitempty"`
// PortForwardNamespace specifies the namespace where port forwarding should be applied (default: argocd)
PortForwardNamespace string `json:"port-forward-namespace,omitempty"`
}

// User contains user authentication information
Expand Down
Loading