From 565a13aea919ef2590b8a6db3b7f6e1ab97ff93c Mon Sep 17 00:00:00 2001 From: Tiffany Chiang Date: Mon, 2 Dec 2024 14:41:02 -0500 Subject: [PATCH] split up terraform and deploy queue interfaces to resolve interface bloat linter error --- .../workflows/internal/deploy/revision/queue/worker.go | 6 +++++- .../workflows/internal/deploy/revision/queue/worker_test.go | 2 +- .../neptune/workflows/internal/deploy/terraform/runner.go | 4 ++-- server/neptune/workflows/internal/deploy/terraform/state.go | 2 +- server/neptune/workflows/internal/deploy/workflow.go | 1 + 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/server/neptune/workflows/internal/deploy/revision/queue/worker.go b/server/neptune/workflows/internal/deploy/revision/queue/worker.go index f2acd0287..41d15bc33 100644 --- a/server/neptune/workflows/internal/deploy/revision/queue/worker.go +++ b/server/neptune/workflows/internal/deploy/revision/queue/worker.go @@ -26,6 +26,9 @@ type queue interface { CanPop() bool Pop() (terraform.DeploymentInfo, error) SetLockForMergedItems(ctx workflow.Context, state lock.LockState) +} + +type terraformQueue interface { GetOrderedMergedItems() []terraform.DeploymentInfo GetQueuedRevisionsSummary() string GetLockState() lock.LockState @@ -86,6 +89,7 @@ const ( func NewWorker( ctx workflow.Context, q queue, + tfqueue terraformQueue, a workerActivities, tfWorkflow terraform.Workflow, postDeployExecutors []plugins.PostDeployExecutor, @@ -100,7 +104,7 @@ func NewWorker( }, } - tfWorkflowRunner := terraform.NewWorkflowRunner(q, tfWorkflow, githubCheckRunCache, notifiers, additionalNotifiers...) + tfWorkflowRunner := terraform.NewWorkflowRunner(tfqueue, tfWorkflow, githubCheckRunCache, notifiers, additionalNotifiers...) deployer := &Deployer{ Activities: a, TerraformWorkflowRunner: tfWorkflowRunner, diff --git a/server/neptune/workflows/internal/deploy/revision/queue/worker_test.go b/server/neptune/workflows/internal/deploy/revision/queue/worker_test.go index 8f0362e85..e1a17a3c9 100644 --- a/server/neptune/workflows/internal/deploy/revision/queue/worker_test.go +++ b/server/neptune/workflows/internal/deploy/revision/queue/worker_test.go @@ -413,7 +413,7 @@ func TestNewWorker(t *testing.T) { ScheduleToCloseTimeout: 5 * time.Second, }) q := queue.NewQueue(noopCallback, metrics.NewNullableScope()) - _, err := queue.NewWorker(ctx, q, &testDeployActivity{}, emptyWorkflow, []plugins.PostDeployExecutor{}, "nish/repo", "root", &testCheckRunClient{}) + _, err := queue.NewWorker(ctx, q, q, &testDeployActivity{}, emptyWorkflow, []plugins.PostDeployExecutor{}, "nish/repo", "root", &testCheckRunClient{}) return res{ Lock: q.GetLockState(), }, err diff --git a/server/neptune/workflows/internal/deploy/terraform/runner.go b/server/neptune/workflows/internal/deploy/terraform/runner.go index e07619f93..24ba40bf6 100644 --- a/server/neptune/workflows/internal/deploy/terraform/runner.go +++ b/server/neptune/workflows/internal/deploy/terraform/runner.go @@ -34,13 +34,13 @@ type stateReceiver interface { Receive(ctx workflow.Context, c workflow.ReceiveChannel, deploymentInfo DeploymentInfo) } -type deployQueue interface { +type terraformQueue interface { GetOrderedMergedItems() []DeploymentInfo GetQueuedRevisionsSummary() string GetLockState() lock.LockState } -func NewWorkflowRunner(queue deployQueue, w Workflow, githubCheckRunCache CheckRunClient, internalNotifiers []WorkflowNotifier, additionalNotifiers ...plugins.TerraformWorkflowNotifier) *WorkflowRunner { +func NewWorkflowRunner(queue terraformQueue, w Workflow, githubCheckRunCache CheckRunClient, internalNotifiers []WorkflowNotifier, additionalNotifiers ...plugins.TerraformWorkflowNotifier) *WorkflowRunner { return &WorkflowRunner{ Workflow: w, StateReceiver: &StateReceiver{ diff --git a/server/neptune/workflows/internal/deploy/terraform/state.go b/server/neptune/workflows/internal/deploy/terraform/state.go index 8d806199a..366902c5a 100644 --- a/server/neptune/workflows/internal/deploy/terraform/state.go +++ b/server/neptune/workflows/internal/deploy/terraform/state.go @@ -25,7 +25,7 @@ type StateReceiver struct { // We have separate classes of notifiers since we can be more flexible with our internal ones in terms of the data model // What we support externally should be well thought out so for now this is kept to a minimum. - Queue deployQueue + Queue terraformQueue CheckRunCache CheckRunClient InternalNotifiers []WorkflowNotifier AdditionalNotifiers []plugins.TerraformWorkflowNotifier diff --git a/server/neptune/workflows/internal/deploy/workflow.go b/server/neptune/workflows/internal/deploy/workflow.go index 986317743..6bcc4a5e5 100644 --- a/server/neptune/workflows/internal/deploy/workflow.go +++ b/server/neptune/workflows/internal/deploy/workflow.go @@ -116,6 +116,7 @@ func newRunner(ctx workflow.Context, request Request, children ChildWorkflows, p worker, err := queue.NewWorker( ctx, revisionQueue, + revisionQueue, a, children.Terraform, plugins.PostDeployExecutors, request.Repo.FullName, request.Root.Name,