Skip to content

Commit

Permalink
split up terraform and deploy queue interfaces to resolve interface b…
Browse files Browse the repository at this point in the history
…loat linter error
  • Loading branch information
tlin4194 committed Dec 2, 2024
1 parent 1cbfba8 commit 565a13a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -86,6 +89,7 @@ const (
func NewWorker(
ctx workflow.Context,
q queue,
tfqueue terraformQueue,
a workerActivities,
tfWorkflow terraform.Workflow,
postDeployExecutors []plugins.PostDeployExecutor,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions server/neptune/workflows/internal/deploy/terraform/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions server/neptune/workflows/internal/deploy/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 565a13a

Please sign in to comment.