Skip to content

fix: credentials: do not prompt the user multiple times at once #249

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

Merged
merged 1 commit into from
Apr 16, 2024
Merged
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
6 changes: 6 additions & 0 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type Runner struct {
runtimeManager engine.RuntimeManager
ports engine.Ports
credCtx string
credMutex sync.Mutex
}

func New(client engine.Model, credCtx string, opts ...Options) (*Runner, error) {
Expand All @@ -71,6 +72,7 @@ func New(client engine.Model, credCtx string, opts ...Options) (*Runner, error)
factory: opt.MonitorFactory,
runtimeManager: opt.RuntimeManager,
credCtx: credCtx,
credMutex: sync.Mutex{},
}

if opt.StartPort != 0 {
Expand Down Expand Up @@ -330,6 +332,10 @@ func recordStateMessage(state *engine.State) error {
}

func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env []string) ([]string, error) {
// Since credential tools (usually) prompt the user, we want to only run one at a time.
r.credMutex.Lock()
defer r.credMutex.Unlock()

c, err := config.ReadCLIConfig("")
if err != nil {
return nil, fmt.Errorf("failed to read CLI config: %w", err)
Expand Down