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

[cli] proxy authentication from new CLI options #410

Closed
wants to merge 1 commit into from
Closed
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
25 changes: 25 additions & 0 deletions cmd/esc/cli/esc.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@
}

func newESC(opts *Options) *escCommand {
fs := valueOrDefault(opts.fs, newFS())

Check failure on line 67 in cmd/esc/cli/esc.go

View workflow job for this annotation

GitHub Actions / lint / lint

SA5011: possible nil pointer dereference (staticcheck)

esc := &escCommand{
fs: fs,
environ: valueOrDefault(opts.environ, newEnviron()),

Check failure on line 71 in cmd/esc/cli/esc.go

View workflow job for this annotation

GitHub Actions / lint / lint

SA5011: possible nil pointer dereference (staticcheck)
exec: valueOrDefault(opts.exec, newCmdExec()),

Check failure on line 72 in cmd/esc/cli/esc.go

View workflow job for this annotation

GitHub Actions / lint / lint

SA5011: possible nil pointer dereference (staticcheck)
pager: valueOrDefault(opts.pager, newPager()),
stdin: valueOrDefault(opts.Stdin, io.Reader(os.Stdin)),
stdout: valueOrDefault(opts.Stdout, io.Writer(os.Stdout)),
Expand All @@ -85,6 +85,31 @@
esc.newClient = client.New
}

// gracefully set the esc account here such that if one of the calls fails we still
// return the esc command
if opts == nil || opts.PulumiWorkspace == nil {

Check failure on line 90 in cmd/esc/cli/esc.go

View workflow job for this annotation

GitHub Actions / lint / lint

SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
return esc
}

creds, err := opts.PulumiWorkspace.GetStoredCredentials()
if err != nil {
return esc
}

backendURL := creds.Current
if val, ok := creds.Accounts[backendURL]; ok {
defaultOrg, err := esc.workspace.GetBackendConfigDefaultOrg(backendURL, val.Username)
if err != nil {
return esc
}
esc.account = workspace.Account{
Account: val,
BackendURL: creds.Current,
DefaultOrg: defaultOrg,
}
}

esc.workspace.SetCurrentAccount(esc.account, true)

Check failure on line 112 in cmd/esc/cli/esc.go

View workflow job for this annotation

GitHub Actions / lint / lint

Error return value of `esc.workspace.SetCurrentAccount` is not checked (errcheck)
return esc
}

Expand Down
Loading