Skip to content

Commit

Permalink
Merge pull request #1643 from Devils-Knight/issue
Browse files Browse the repository at this point in the history
[ISSUE] Update Names of `WorkflowParameters` struct properties to UpperCase
  • Loading branch information
varunsh-coder authored Dec 12, 2022
2 parents 582a89d + ee52f8f commit ad10892
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions remediation/workflow/addworkflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
const CodeQLWorkflowFileName = "codeql.yml"

type WorkflowParameters struct {
languagesToAdd []string
defaultBranch string
LanguagesToAdd []string
DefaultBranch string
}

func getTemplate(file string) (string, error) {
Expand All @@ -38,9 +38,9 @@ func AddWorkflow(name string, workflowParameters WorkflowParameters) (string, er
return "", err
}

sort.Strings(workflowParameters.languagesToAdd)
codeqlWorkflow = strings.ReplaceAll(codeqlWorkflow, "$default-branch", fmt.Sprintf(`"%s"`, workflowParameters.defaultBranch))
codeqlWorkflow = strings.ReplaceAll(codeqlWorkflow, "$detected-codeql-languages", strings.Join(workflowParameters.languagesToAdd, ", "))
sort.Strings(workflowParameters.LanguagesToAdd)
codeqlWorkflow = strings.ReplaceAll(codeqlWorkflow, "$default-branch", fmt.Sprintf(`"%s"`, workflowParameters.DefaultBranch))
codeqlWorkflow = strings.ReplaceAll(codeqlWorkflow, "$detected-codeql-languages", strings.Join(workflowParameters.LanguagesToAdd, ", "))
codeqlWorkflow = strings.ReplaceAll(codeqlWorkflow, "$cron-weekly", fmt.Sprintf(`"%s"`, "0 0 * * 1")) // Note: Runs every monday at 12:00 AM

return codeqlWorkflow, nil
Expand Down
8 changes: 4 additions & 4 deletions remediation/workflow/addworkflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ func Test_AddWorkflow(t *testing.T) {
{
workflowName: "codeql",
workflowParameters: WorkflowParameters{
languagesToAdd: []string{"cpp", "go", "java"},
defaultBranch: "main",
LanguagesToAdd: []string{"cpp", "go", "java"},
DefaultBranch: "main",
},
expectedError: false,
expectedOutputFile: "../../testfiles/expected-codeql.yml",
},
{
workflowName: "xyz",
workflowParameters: WorkflowParameters{
languagesToAdd: []string{"cpp"},
defaultBranch: "main",
LanguagesToAdd: []string{"cpp"},
DefaultBranch: "main",
},
expectedError: true,
expectedOutputFile: "",
Expand Down

0 comments on commit ad10892

Please sign in to comment.