From dd862aa761146e890e1da8a57795d5a0cf3eb035 Mon Sep 17 00:00:00 2001 From: Gabriel Martinez Date: Sun, 10 Mar 2024 18:33:46 +0000 Subject: [PATCH] feat: allow masking output on comments Signed-off-by: Gabriel Martinez --- runatlantis.io/docs/custom-workflows.md | 12 +-- server/core/config/raw/step.go | 80 ++++++++++------- server/core/config/raw/step_test.go | 18 ++++ server/core/config/valid/repo_cfg.go | 32 ++++++- server/core/runtime/env_step_runner.go | 2 +- server/core/runtime/multienv_step_runner.go | 2 +- server/core/runtime/plan_step_runner.go | 9 ++ server/core/runtime/plan_step_runner_test.go | 85 +++++++++++++++++++ server/core/runtime/run_step_runner.go | 7 +- server/core/runtime/run_step_runner_test.go | 7 +- .../events/mocks/mock_custom_step_runner.go | 20 +++-- server/events/project_command_runner.go | 3 +- server/events/project_command_runner_test.go | 8 +- server/events/vcs/github_client.go | 3 +- 14 files changed, 229 insertions(+), 59 deletions(-) diff --git a/runatlantis.io/docs/custom-workflows.md b/runatlantis.io/docs/custom-workflows.md index af655abf26..f0fd0ac500 100644 --- a/runatlantis.io/docs/custom-workflows.md +++ b/runatlantis.io/docs/custom-workflows.md @@ -354,7 +354,10 @@ workflows: value: 'true' - run: command: terragrunt plan -input=false -out=$PLANFILE - output: strip_refreshing + output: strip_refreshing_with_custom_regex + # Filters text matching 'mySecret: "aaa"' -> 'mySecret: ""' + regex_filter: "((?i)secret:\\s\")[^\"]*" + apply: steps: - env: @@ -604,17 +607,16 @@ Full - "--debug" - "-c" output: show + custom_regex: .* ``` | Key | Type | Default | Required | Description | |-----|--------------------------------------------------------------|---------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| run | map\[string -> string\] | none | no | Run a custom command | +| run | map[string -> string] | none | no | Run a custom command | | run.command | string | none | yes | Shell command to run | -| run.shell | string | "sh" | no | Name of the shell to use for command execution | -| run.shellArgs | string or []string | "-c" | no | Command line arguments to be passed to the shell. Cannot be set without `shell` | | run.output | string | "show" | no | How to post-process the output of this command when posted in the PR comment. The options are
*`show` - preserve the full output
* `hide` - hide output from comment (still visible in the real-time streaming output)
* `strip_refreshing` - hide all output up until and including the last line containing "Refreshing...". This matches the behavior of the built-in `plan` command | -#### Native Environment Variables +::: tip Notes * `run` steps in the main `workflow` are executed with the following environment variables: note: these variables are not available to `pre` or `post` workflows diff --git a/server/core/config/raw/step.go b/server/core/config/raw/step.go index 6ada93488c..6491fb7338 100644 --- a/server/core/config/raw/step.go +++ b/server/core/config/raw/step.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "fmt" + "regexp" "sort" "strings" @@ -13,23 +14,24 @@ import ( ) const ( - ExtraArgsKey = "extra_args" - NameArgKey = "name" - CommandArgKey = "command" - ValueArgKey = "value" - OutputArgKey = "output" - RunStepName = "run" - PlanStepName = "plan" - ShowStepName = "show" - PolicyCheckStepName = "policy_check" - ApplyStepName = "apply" - InitStepName = "init" - EnvStepName = "env" - MultiEnvStepName = "multienv" - ImportStepName = "import" - StateRmStepName = "state_rm" - ShellArgKey = "shell" - ShellArgsArgKey = "shellArgs" + ExtraArgsKey = "extra_args" + NameArgKey = "name" + CommandArgKey = "command" + ValueArgKey = "value" + OutputArgKey = "output" + OutputRegexFilterKey = "regex_filter" + RunStepName = "run" + PlanStepName = "plan" + ShowStepName = "show" + PolicyCheckStepName = "policy_check" + ApplyStepName = "apply" + InitStepName = "init" + EnvStepName = "env" + MultiEnvStepName = "multienv" + ImportStepName = "import" + StateRmStepName = "state_rm" + ShellArgKey = "shell" + ShellArgsArgKey = "shellArgs" ) /* @@ -59,6 +61,10 @@ Step represents a single action/command to perform. In YAML, it can be set as - run: command: my custom command output: hide + - run: + command: my custom command + output: custom_regex + regex_filter: .* 3. A map for a built-in command and extra_args: - plan: @@ -249,20 +255,33 @@ func (s Step) Validate() error { if _, ok := argMap[CommandArgKey].(string); !ok { return fmt.Errorf("%q step must have a %q key set", stepName, CommandArgKey) } - delete(argMap, CommandArgKey) - if v, ok := argMap[OutputArgKey].(string); ok { - if stepName == RunStepName && !(v == valid.PostProcessRunOutputShow || - v == valid.PostProcessRunOutputHide || v == valid.PostProcessRunOutputStripRefreshing) { - return fmt.Errorf("run step %q option must be one of %q, %q, or %q", - OutputArgKey, valid.PostProcessRunOutputShow, valid.PostProcessRunOutputHide, - valid.PostProcessRunOutputStripRefreshing) - } else if stepName == MultiEnvStepName && !(v == valid.PostProcessRunOutputShow || - v == valid.PostProcessRunOutputHide) { - return fmt.Errorf("multienv step %q option must be %q or %q", - OutputArgKey, valid.PostProcessRunOutputShow, valid.PostProcessRunOutputHide) + delete(args, CommandArgKey) + if v, ok := args[OutputArgKey].(string); ok { + if !valid.MatchesAnyPostProcessRunOutputOptions(v) { + return fmt.Errorf("run step %q option must be one of %q", OutputArgKey, strings.Join(valid.PostProcessRunOutputOptions(), ",")) + } + // When output requires regex option + if v == valid.PostProcessRunOutputCustomRegex || v == valid.PostProcessRunOutputStripRefreshingWithCustomRegex { + if regex, ok := args[OutputRegexFilterKey]; ok { + if _, err := regexp.Compile(regex.(string)); err != nil { + return fmt.Errorf("run step %q option with expression %q is not a valid regex: %w", OutputRegexFilterKey, regex, err) + } + delete(args, OutputRegexFilterKey) + } else { + return fmt.Errorf("run step %q option requires %q to be set", OutputArgKey, OutputRegexFilterKey) + } } } - delete(argMap, OutputArgKey) + delete(args, OutputArgKey) + if len(args) > 0 { + var argKeys []string + for k := range args { + argKeys = append(argKeys, k) + } + // Sort so tests can be deterministic. + sort.Strings(argKeys) + return fmt.Errorf("run steps only support keys %q, %q and %q, found extra keys %q", RunStepName, CommandArgKey, OutputArgKey, strings.Join(argKeys, ",")) + } default: return fmt.Errorf("%q is not a valid step type", stepName) } @@ -343,6 +362,9 @@ func (s Step) ToValid() valid.Step { if output, ok := stepArgs[OutputArgKey].(string); ok { step.Output = valid.PostProcessRunOutputOption(output) } + if outputRegexFilter, ok := stepArgs[OutputRegexFilterKey].(string); ok { + step.OutputRegexFilter = outputRegexFilter + } if shell, ok := stepArgs[ShellArgKey].(string); ok { step.RunShell = &valid.CommandShell{ Shell: shell, diff --git a/server/core/config/raw/step_test.go b/server/core/config/raw/step_test.go index f8b9ae8b11..deabf09f5a 100644 --- a/server/core/config/raw/step_test.go +++ b/server/core/config/raw/step_test.go @@ -695,6 +695,24 @@ func TestStep_ToValid(t *testing.T) { Output: "hide", }, }, + { + description: "run step with regex", + input: raw.Step{ + CommandMap: RunType{ + "run": { + "command": "my 'run command'", + "output": "regex_filter", + "regex_filter": ".*", + }, + }, + }, + exp: valid.Step{ + StepName: "run", + RunCommand: "my 'run command'", + Output: "regex_filter", + OutputRegexFilter: ".*", + }, + }, } for _, c := range cases { t.Run(c.description, func(t *testing.T) { diff --git a/server/core/config/valid/repo_cfg.go b/server/core/config/valid/repo_cfg.go index e42e60158b..f9f027986a 100644 --- a/server/core/config/valid/repo_cfg.go +++ b/server/core/config/valid/repo_cfg.go @@ -180,11 +180,35 @@ type Autoplan struct { type PostProcessRunOutputOption string const ( - PostProcessRunOutputShow = "show" - PostProcessRunOutputHide = "hide" - PostProcessRunOutputStripRefreshing = "strip_refreshing" + PostProcessRunOutputShow = "show" + PostProcessRunOutputHide = "hide" + PostProcessRunOutputStripRefreshing = "strip_refreshing" + PostProcessRunOutputCustomRegex = "custom_regex" + PostProcessRunOutputStripRefreshingWithCustomRegex = "strip_refreshing_with_custom_regex" ) +// PostProcessRunOutputOptions returns the available post processing options +// This list needs to be manually updated +func PostProcessRunOutputOptions() []string { + return []string{ + PostProcessRunOutputShow, + PostProcessRunOutputHide, + PostProcessRunOutputStripRefreshing, + PostProcessRunOutputCustomRegex, + PostProcessRunOutputStripRefreshingWithCustomRegex, + } +} + +// MatchesAnyPostProcessRunOutputOptions returns true when the input matches any of the available post processing options +func MatchesAnyPostProcessRunOutputOptions(option string) bool { + for _, c := range PostProcessRunOutputOptions() { + if option == c { + return true + } + } + return false +} + type Stage struct { Steps []Step } @@ -207,6 +231,8 @@ type Step struct { RunCommand string // Output is option for post-processing a RunCommand output Output PostProcessRunOutputOption + // OutputRegexFilter is a required option when post-processing uses a regex filter output + OutputRegexFilter string // EnvVarName is the name of the // environment variable that should be set by this step. EnvVarName string diff --git a/server/core/runtime/env_step_runner.go b/server/core/runtime/env_step_runner.go index 5fa865fefd..c64ca66d82 100644 --- a/server/core/runtime/env_step_runner.go +++ b/server/core/runtime/env_step_runner.go @@ -28,7 +28,7 @@ func (r *EnvStepRunner) Run( } // Pass `false` for streamOutput because this isn't interesting to the user reading the build logs // in the web UI. - res, err := r.RunStepRunner.Run(ctx, shell, command, path, envs, false, valid.PostProcessRunOutputShow) + res, err := r.RunStepRunner.Run(ctx, shell, command, path, envs, false, valid.PostProcessRunOutputShow, "") // Trim newline from res to support running `echo env_value` which has // a newline. We don't recommend users run echo -n env_value to remove the // newline because -n doesn't work in the sh shell which is what we use diff --git a/server/core/runtime/multienv_step_runner.go b/server/core/runtime/multienv_step_runner.go index 6e4434111f..5193ee8d5c 100644 --- a/server/core/runtime/multienv_step_runner.go +++ b/server/core/runtime/multienv_step_runner.go @@ -24,7 +24,7 @@ func (r *MultiEnvStepRunner) Run( envs map[string]string, postProcessOutput valid.PostProcessRunOutputOption, ) (string, error) { - res, err := r.RunStepRunner.Run(ctx, shell, command, path, envs, false, postProcessOutput) + res, err := r.RunStepRunner.Run(ctx, shell, command, path, envs, false, postProcessOutput, "") if err != nil { return "", err } diff --git a/server/core/runtime/plan_step_runner.go b/server/core/runtime/plan_step_runner.go index b1cb66c1e4..0e5aa2706c 100644 --- a/server/core/runtime/plan_step_runner.go +++ b/server/core/runtime/plan_step_runner.go @@ -265,6 +265,15 @@ func StripRefreshingFromPlanOutput(output string, tfVersion *version.Version) st return output } +func CustomRegexFromPlanOutput(output string, outputFilterRegex string) string { + if outputFilterRegex == "" { + return output + } + // Regex was validated previously + r := regexp.MustCompile(outputFilterRegex) + return r.ReplaceAllString(output, "${1}$2") +} + // remoteOpsErr01114 is the error terraform plan will return if this project is // using TFE remote operations in TF 0.11.15. var remoteOpsErr01114 = `Error: Saving a generated plan is currently not supported! diff --git a/server/core/runtime/plan_step_runner_test.go b/server/core/runtime/plan_step_runner_test.go index f05336637c..1ea0311416 100644 --- a/server/core/runtime/plan_step_runner_test.go +++ b/server/core/runtime/plan_step_runner_test.go @@ -536,6 +536,31 @@ Plan: 0 to add, 0 to change, 1 to destroy.`, output) } } +// Test custom regex on output method +func TestCustomRegexFromPlanOutputFromPlanOutput(t *testing.T) { + cases := []struct { + in string + out string + regex string + }{ + { + remotePlanOutput, + remotePlanOutput, + "", + }, + { + remotePlanOutputSensitive, + remotePlanOutputSensitiveMasked, + `((?i)secret:\s")[^"]*`, + }, + } + + for _, c := range cases { + output := runtime.CustomRegexFromPlanOutput(c.in, c.regex) + Equals(t, c.out, output) + } +} + type remotePlanMock struct { // LinesToSend will be sent on the channel. LinesToSend string @@ -603,3 +628,63 @@ Terraform will perform the following actions: Plan: 0 to add, 0 to change, 1 to destroy.` + +var remotePlanOutputSensitive = `Terraform will perform the following actions: + + # kubectl_manifest.test[0] will be updated in-place +! resource "kubectl_manifest" "test" { + id = "/apis/argoproj.io/v1alpha1/namespaces/test/applications/test" + name = "test" +! yaml_body = (sensitive value) +! yaml_body_parsed = <<-EOT + apiVersion: argoproj.io/v1alpha1 + kind: Application + metadata: + name: test + namespace: test + spec: + destination: + namespace: test + server: https://kubernetes.default.svc + project: default + source: + helm: + values: |- +- clientID: "test_id" +- clientSecret: "super_secret_old" ++ clientID: "test_id" ++ clientSecret: "super_secret_new" + EOT + } + +Plan: 0 to add, 1 to change, 0 to destroy.` + +var remotePlanOutputSensitiveMasked = `Terraform will perform the following actions: + + # kubectl_manifest.test[0] will be updated in-place +! resource "kubectl_manifest" "test" { + id = "/apis/argoproj.io/v1alpha1/namespaces/test/applications/test" + name = "test" +! yaml_body = (sensitive value) +! yaml_body_parsed = <<-EOT + apiVersion: argoproj.io/v1alpha1 + kind: Application + metadata: + name: test + namespace: test + spec: + destination: + namespace: test + server: https://kubernetes.default.svc + project: default + source: + helm: + values: |- +- clientID: "test_id" +- clientSecret: "" ++ clientID: "test_id" ++ clientSecret: "" + EOT + } + +Plan: 0 to add, 1 to change, 0 to destroy.` diff --git a/server/core/runtime/run_step_runner.go b/server/core/runtime/run_step_runner.go index 76629ba460..6b1fdf645a 100644 --- a/server/core/runtime/run_step_runner.go +++ b/server/core/runtime/run_step_runner.go @@ -30,6 +30,7 @@ func (r *RunStepRunner) Run( envs map[string]string, streamOutput bool, postProcessOutput valid.PostProcessRunOutputOption, + postProcessRegexFilter string, ) (string, error) { tfVersion := r.DefaultTFVersion if ctx.TerraformVersion != nil { @@ -97,7 +98,11 @@ func (r *RunStepRunner) Run( case valid.PostProcessRunOutputHide: return "", nil case valid.PostProcessRunOutputStripRefreshing: - return output, nil + return StripRefreshingFromPlanOutput(output, tfVersion), nil + case valid.PostProcessRunOutputCustomRegex: + return CustomRegexFromPlanOutput(output, postProcessRegexFilter), nil + case valid.PostProcessRunOutputStripRefreshingWithCustomRegex: + return CustomRegexFromPlanOutput(StripRefreshingFromPlanOutput(output, tfVersion), postProcessRegexFilter), nil case valid.PostProcessRunOutputShow: return output, nil default: diff --git a/server/core/runtime/run_step_runner_test.go b/server/core/runtime/run_step_runner_test.go index 4672fa2bb0..a71e8d08d5 100644 --- a/server/core/runtime/run_step_runner_test.go +++ b/server/core/runtime/run_step_runner_test.go @@ -1,4 +1,4 @@ -package runtime_test +package runtime import ( "fmt" @@ -9,7 +9,6 @@ import ( "github.com/hashicorp/go-version" . "github.com/petergtz/pegomock/v4" "github.com/runatlantis/atlantis/server/core/config/valid" - "github.com/runatlantis/atlantis/server/core/runtime" "github.com/runatlantis/atlantis/server/core/terraform/mocks" "github.com/runatlantis/atlantis/server/events/command" "github.com/runatlantis/atlantis/server/events/models" @@ -111,7 +110,7 @@ func TestRunStepRunner_Run(t *testing.T) { projectCmdOutputHandler := jobmocks.NewMockProjectCommandOutputHandler() tmpDir := t.TempDir() - r := runtime.RunStepRunner{ + r := RunStepRunner{ TerraformExecutor: terraform, DefaultTFVersion: defaultVersion, TerraformBinDir: "/bin/dir", @@ -145,7 +144,7 @@ func TestRunStepRunner_Run(t *testing.T) { ProjectName: c.ProjectName, EscapedCommentArgs: []string{"-target=resource1", "-target=resource2"}, } - out, err := r.Run(ctx, nil, c.Command, tmpDir, map[string]string{"test": "var"}, true, valid.PostProcessRunOutputShow) + out, err := r.Run(ctx, nil, c.Command, tmpDir, map[string]string{"test": "var"}, true, valid.PostProcessRunOutputShow, "") if c.ExpErr != "" { ErrContains(t, c.ExpErr, err) return diff --git a/server/events/mocks/mock_custom_step_runner.go b/server/events/mocks/mock_custom_step_runner.go index 7662d22ba0..1ef32740aa 100644 --- a/server/events/mocks/mock_custom_step_runner.go +++ b/server/events/mocks/mock_custom_step_runner.go @@ -26,11 +26,11 @@ func NewMockCustomStepRunner(options ...pegomock.Option) *MockCustomStepRunner { func (mock *MockCustomStepRunner) SetFailHandler(fh pegomock.FailHandler) { mock.fail = fh } func (mock *MockCustomStepRunner) FailHandler() pegomock.FailHandler { return mock.fail } -func (mock *MockCustomStepRunner) Run(ctx command.ProjectContext, shell *valid.CommandShell, cmd string, path string, envs map[string]string, streamOutput bool, postProcessOutput valid.PostProcessRunOutputOption) (string, error) { +func (mock *MockCustomStepRunner) Run(ctx command.ProjectContext, shell *valid.CommandShell, cmd string, path string, envs map[string]string, streamOutput bool, postProcessOutput valid.PostProcessRunOutputOption, postProcessRegexFilter string) (string, error) { if mock == nil { panic("mock must not be nil. Use myMock := NewMockCustomStepRunner().") } - params := []pegomock.Param{ctx, cmd, path, envs, streamOutput, postProcessOutput} + params := []pegomock.Param{ctx, cmd, path, envs, streamOutput, postProcessOutput, postProcessRegexFilter} result := pegomock.GetGenericMockFrom(mock).Invoke("Run", params, []reflect.Type{reflect.TypeOf((*string)(nil)).Elem(), reflect.TypeOf((*error)(nil)).Elem()}) var ret0 string var ret1 error @@ -82,8 +82,8 @@ type VerifierMockCustomStepRunner struct { timeout time.Duration } -func (verifier *VerifierMockCustomStepRunner) Run(ctx command.ProjectContext, shell *valid.CommandShell, cmd string, path string, envs map[string]string, streamOutput bool, postProcessOutput valid.PostProcessRunOutputOption) *MockCustomStepRunner_Run_OngoingVerification { - params := []pegomock.Param{ctx, cmd, path, envs, streamOutput, postProcessOutput} +func (verifier *VerifierMockCustomStepRunner) Run(ctx command.ProjectContext, shell *valid.CommandShell, cmd string, path string, envs map[string]string, streamOutput bool, postProcessOutput valid.PostProcessRunOutputOption, postProcessRegexFilter string) *MockCustomStepRunner_Run_OngoingVerification { + params := []pegomock.Param{ctx, cmd, path, envs, streamOutput, postProcessOutput, postProcessRegexFilter} methodInvocations := pegomock.GetGenericMockFrom(verifier.mock).Verify(verifier.inOrderContext, verifier.invocationCountMatcher, "Run", params, verifier.timeout) return &MockCustomStepRunner_Run_OngoingVerification{mock: verifier.mock, methodInvocations: methodInvocations} } @@ -93,12 +93,12 @@ type MockCustomStepRunner_Run_OngoingVerification struct { methodInvocations []pegomock.MethodInvocation } -func (c *MockCustomStepRunner_Run_OngoingVerification) GetCapturedArguments() (command.ProjectContext, string, string, map[string]string, bool, valid.PostProcessRunOutputOption) { - ctx, cmd, path, envs, streamOutput, postProcessOutput := c.GetAllCapturedArguments() - return ctx[len(ctx)-1], cmd[len(cmd)-1], path[len(path)-1], envs[len(envs)-1], streamOutput[len(streamOutput)-1], postProcessOutput[len(postProcessOutput)-1] +func (c *MockCustomStepRunner_Run_OngoingVerification) GetCapturedArguments() (command.ProjectContext, string, string, map[string]string, bool, valid.PostProcessRunOutputOption, string) { + ctx, cmd, path, envs, streamOutput, postProcessOutput, postProcessRegexFilter := c.GetAllCapturedArguments() + return ctx[len(ctx)-1], cmd[len(cmd)-1], path[len(path)-1], envs[len(envs)-1], streamOutput[len(streamOutput)-1], postProcessOutput[len(postProcessOutput)-1], postProcessRegexFilter[len(postProcessRegexFilter)-1] } -func (c *MockCustomStepRunner_Run_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 []string, _param2 []string, _param3 []map[string]string, _param4 []bool, _param5 []valid.PostProcessRunOutputOption) { +func (c *MockCustomStepRunner_Run_OngoingVerification) GetAllCapturedArguments() (_param0 []command.ProjectContext, _param1 []string, _param2 []string, _param3 []map[string]string, _param4 []bool, _param5 []valid.PostProcessRunOutputOption, _param6 []string) { params := pegomock.GetGenericMockFrom(c.mock).GetInvocationParams(c.methodInvocations) if len(params) > 0 { _param0 = make([]command.ProjectContext, len(c.methodInvocations)) @@ -125,6 +125,10 @@ func (c *MockCustomStepRunner_Run_OngoingVerification) GetAllCapturedArguments() for u, param := range params[5] { _param5[u] = param.(valid.PostProcessRunOutputOption) } + _param6 = make([]string, len(c.methodInvocations)) + for u, param := range params[6] { + _param6[u] = param.(string) + } } return } diff --git a/server/events/project_command_runner.go b/server/events/project_command_runner.go index 26d4dc2cc2..9c201a294d 100644 --- a/server/events/project_command_runner.go +++ b/server/events/project_command_runner.go @@ -73,6 +73,7 @@ type CustomStepRunner interface { envs map[string]string, streamOutput bool, postProcessOutput valid.PostProcessRunOutputOption, + postProcessRegexFilter string, ) (string, error) } @@ -812,7 +813,7 @@ func (p *DefaultProjectCommandRunner) runSteps(steps []valid.Step, ctx command.P case "state_rm": out, err = p.StateRmStepRunner.Run(ctx, step.ExtraArgs, absPath, envs) case "run": - out, err = p.RunStepRunner.Run(ctx, step.RunShell, step.RunCommand, absPath, envs, true, step.Output) + out, err = p.RunStepRunner.Run(ctx, step.RunShell, step.RunCommand, absPath, envs, true, step.Output, step.OutputRegexFilter) case "env": out, err = p.EnvStepRunner.Run(ctx, step.RunShell, step.RunCommand, step.EnvVarValue, absPath, envs) envs[step.EnvVarName] = out diff --git a/server/events/project_command_runner_test.go b/server/events/project_command_runner_test.go index 68548efdd0..cd00f1e492 100644 --- a/server/events/project_command_runner_test.go +++ b/server/events/project_command_runner_test.go @@ -99,7 +99,7 @@ func TestDefaultProjectCommandRunner_Plan(t *testing.T) { When(mockInit.Run(ctx, nil, repoDir, expEnvs)).ThenReturn("init", nil) When(mockPlan.Run(ctx, nil, repoDir, expEnvs)).ThenReturn("plan", nil) When(mockApply.Run(ctx, nil, repoDir, expEnvs)).ThenReturn("apply", nil) - When(mockRun.Run(ctx, nil, "", repoDir, expEnvs, true, "")).ThenReturn("run", nil) + When(mockRun.Run(ctx, nil, "", repoDir, expEnvs, true, "", "")).ThenReturn("run", nil) res := runner.Plan(ctx) Assert(t, res.PlanSuccess != nil, "exp plan success") @@ -115,7 +115,7 @@ func TestDefaultProjectCommandRunner_Plan(t *testing.T) { case "apply": mockApply.VerifyWasCalledOnce().Run(ctx, nil, repoDir, expEnvs) case "run": - mockRun.VerifyWasCalledOnce().Run(ctx, nil, "", repoDir, expEnvs, true, "") + mockRun.VerifyWasCalledOnce().Run(ctx, nil, "", repoDir, expEnvs, true, "", "") } } } @@ -455,7 +455,7 @@ func TestDefaultProjectCommandRunner_Apply(t *testing.T) { When(mockInit.Run(ctx, nil, repoDir, expEnvs)).ThenReturn("init", nil) When(mockPlan.Run(ctx, nil, repoDir, expEnvs)).ThenReturn("plan", nil) When(mockApply.Run(ctx, nil, repoDir, expEnvs)).ThenReturn("apply", nil) - When(mockRun.Run(ctx, nil, "", repoDir, expEnvs, true, "")).ThenReturn("run", nil) + When(mockRun.Run(ctx, nil, "", repoDir, expEnvs, true, "", "")).ThenReturn("run", nil) When(mockEnv.Run(ctx, nil, "", "value", repoDir, make(map[string]string))).ThenReturn("value", nil) res := runner.Apply(ctx) @@ -471,7 +471,7 @@ func TestDefaultProjectCommandRunner_Apply(t *testing.T) { case "apply": mockApply.VerifyWasCalledOnce().Run(ctx, nil, repoDir, expEnvs) case "run": - mockRun.VerifyWasCalledOnce().Run(ctx, nil, "", repoDir, expEnvs, true, "") + mockRun.VerifyWasCalledOnce().Run(ctx, nil, "", repoDir, expEnvs, true, "", "") case "env": mockEnv.VerifyWasCalledOnce().Run(ctx, nil, "", "value", repoDir, expEnvs) } diff --git a/server/events/vcs/github_client.go b/server/events/vcs/github_client.go index d9c3d90541..66a890c261 100644 --- a/server/events/vcs/github_client.go +++ b/server/events/vcs/github_client.go @@ -131,8 +131,7 @@ func NewGithubClient(hostname string, credentials GithubCredentials, config Gith graphqlURL = "https://api.github.com/graphql" } else { apiURL := resolveGithubAPIURL(hostname) - // TODO: Deprecated: Use NewClient(httpClient).WithEnterpriseURLs(baseURL, uploadURL) instead - client, err = github.NewEnterpriseClient(apiURL.String(), apiURL.String(), transport) //nolint:staticcheck + client, err = github.NewEnterpriseClient(apiURL.String(), apiURL.String(), transport) // nolint: staticcheck if err != nil { return nil, err }