Skip to content
Merged
Changes from 1 commit
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
18 changes: 14 additions & 4 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -340,9 +341,18 @@ func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env
}

for _, credToolName := range callCtx.Tool.Credentials {
cred, exists, err := store.Get(credToolName)
if err != nil {
return nil, fmt.Errorf("failed to get credentials for tool %s: %w", credToolName, err)
var (
cred *credentials.Credential
exists bool
err error
)

// Only try to look up the cred if the tool is on GitHub.
if strings.HasPrefix(credToolName, "github.com") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I suggest using a constant instead of a literal since we're using it in multiple places.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Decided to just define a function.

cred, exists, err = store.Get(credToolName)
if err != nil {
return nil, fmt.Errorf("failed to get credentials for tool %s: %w", credToolName, err)
}
}

// If the credential doesn't already exist in the store, run the credential tool in order to get the value,
Expand Down Expand Up @@ -375,7 +385,7 @@ func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env
}

// Only store the credential if the tool is on GitHub.
if callCtx.Program.ToolSet[credToolID].Source.Repo != nil {
if strings.HasPrefix(credToolName, "github.com") && callCtx.Program.ToolSet[credToolID].Source.Repo != nil {
if err := store.Add(*cred); err != nil {
return nil, fmt.Errorf("failed to add credential for tool %s: %w", credToolName, err)
}
Expand Down