Skip to content

Commit

Permalink
removed SCORECARD_PUBLISH_RESULTS env var
Browse files Browse the repository at this point in the history
  • Loading branch information
rohankh532 authored and naveensrinivasan committed Feb 23, 2022
1 parent 4e3137e commit b55fb21
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
31 changes: 13 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var (
enabledChecks = ""
scorecardPrivateRepository = ""
scorecardDefaultBranch = ""
scorecardPublishResults = ""
)

type repositoryInformation struct {
Expand All @@ -61,17 +62,16 @@ const (
githubRef = "GITHUB_REF"
githubWorkspace = "GITHUB_WORKSPACE"
//nolint:gosec
githubAuthToken = "GITHUB_AUTH_TOKEN"
inputresultsfile = "INPUT_RESULTS_FILE"
inputresultsformat = "INPUT_RESULTS_FORMAT"
inputpublishresults = "INPUT_PUBLISH_RESULTS"
scorecardBin = "/scorecard"
scorecardResultsFormat = "SCORECARD_RESULTS_FORMAT"
scorecardPublishResults = "SCORECARD_PUBLISH_RESULTS"
scorecardPolicyFile = "./policy.yml"
scorecardResultsFile = "SCORECARD_RESULTS_FILE"
scorecardFork = "SCORECARD_IS_FORK"
sarif = "sarif"
githubAuthToken = "GITHUB_AUTH_TOKEN"
inputresultsfile = "INPUT_RESULTS_FILE"
inputresultsformat = "INPUT_RESULTS_FORMAT"
inputpublishresults = "INPUT_PUBLISH_RESULTS"
scorecardBin = "/scorecard"
scorecardResultsFormat = "SCORECARD_RESULTS_FORMAT"
scorecardPolicyFile = "./policy.yml"
scorecardResultsFile = "SCORECARD_RESULTS_FILE"
scorecardFork = "SCORECARD_IS_FORK"
sarif = "sarif"
)

// main is the entrypoint for the action.
Expand Down Expand Up @@ -178,9 +178,7 @@ func initalizeENVVariables() error {
if result == "" {
return errInputPublishResultsEmpty
}
if err := os.Setenv(scorecardPublishResults, result); err != nil {
return fmt.Errorf("error setting %s: %w", scorecardPublishResults, err)
}
scorecardPublishResults = result
}

return gitHubEventPath()
Expand Down Expand Up @@ -303,9 +301,7 @@ func updateRepositoryInformation(privateRepo bool, defaultBranch string) error {
func updateEnvVariables() error {
isPrivateRepo := scorecardPrivateRepository
if isPrivateRepo != "true" {
if err := os.Setenv(scorecardPublishResults, "false"); err != nil {
return fmt.Errorf("error setting %s: %w", scorecardPublishResults, err)
}
scorecardPublishResults = "false"
}
return nil
}
Expand All @@ -317,7 +313,6 @@ func printEnvVariables(writer io.Writer) {
fmt.Fprintf(writer, "GITHUB_REPOSITORY=%s\n", os.Getenv(githubRepository))
fmt.Fprintf(writer, "SCORECARD_IS_FORK=%s\n", os.Getenv(scorecardFork))
fmt.Fprintf(writer, "Ref=%s\n", os.Getenv(githubRef))
fmt.Fprintf(writer, "SCORECARD_PUBLISH_RESULTS=%s\n", os.Getenv(scorecardPublishResults))
fmt.Fprintf(writer, "Format=%s\n", os.Getenv(scorecardResultsFormat))
}

Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func Test_updateEnvVariables(t *testing.T) {
t.Errorf("updateEnvVariables() error = %v, wantErr %v", err, tt.wantErr)
}
if !tt.wantErr && tt.isPrivateRepo {
if os.Getenv(scorecardPublishResults) != "false" {
if scorecardPublishResults != "false" {
t.Errorf("scorecardPublishResults env var should be false")
}
}
Expand Down

0 comments on commit b55fb21

Please sign in to comment.