Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsimon committed Jun 16, 2022
1 parent cdad8fc commit 9d2e219
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 5 additions & 4 deletions options/env.go
Expand Up @@ -37,10 +37,11 @@ const (

// TODO(input): INPUT_ constants should be removed in a future release once
// they have replacements in upstream scorecard.
EnvInputRepoToken = "INPUT_REPO_TOKEN" //nolint:gosec
EnvInputResultsFile = "INPUT_RESULTS_FILE"
EnvInputResultsFormat = "INPUT_RESULTS_FORMAT"
EnvInputPublishResults = "INPUT_PUBLISH_RESULTS"
EnvInputRepoToken = "INPUT_REPO_TOKEN" //nolint:gosec
EnvInputInternalRepoToken = "INPUT_INTERNAL_DEFAULT_TOKEN" //nolint:gosec
EnvInputResultsFile = "INPUT_RESULTS_FILE"
EnvInputResultsFormat = "INPUT_RESULTS_FORMAT"
EnvInputPublishResults = "INPUT_PUBLISH_RESULTS"
)

// Errors
Expand Down
10 changes: 7 additions & 3 deletions options/options.go
Expand Up @@ -34,6 +34,7 @@ var (
errGithubEventPathEmpty = errors.New("GitHub event path is empty")
errResultsPathEmpty = errors.New("results path is empty")
errOnlyDefaultBranchSupported = errors.New("only default branch is supported")
errInternalDefaultTokenEmpty = errors.New("internal default token is empty")

trueStr = "true"
)
Expand Down Expand Up @@ -156,9 +157,12 @@ func (o *Options) Initialize() error {
// o.EnableLicense = "1"
// o.EnableDangerousWorkflow = "1"

_, tokenSet := os.LookupEnv(EnvGithubAuthToken)
if !tokenSet {
inputToken := os.Getenv(EnvInputRepoToken)
inputToken := os.Getenv(EnvInputRepoToken)
if inputToken == "" {
inputToken := os.Getenv(EnvInputInternalRepoToken)
if inputToken == "" {
return errInternalDefaultTokenEmpty
}
os.Setenv(EnvGithubAuthToken, inputToken)
}

Expand Down

0 comments on commit 9d2e219

Please sign in to comment.