From d9bcb959ddbc9b2a8f98f559639040816756070c Mon Sep 17 00:00:00 2001 From: Shawna Monero <66325812+smonero@users.noreply.github.com> Date: Thu, 21 Mar 2024 09:28:41 -0700 Subject: [PATCH] [DEVCON-6859] Add adhoc execution params struct that will be used for ExecuteWorkflow(terraform..) (#735) --- cmd/adhoc.go | 10 +++++ .../adhoc_execution_params.go | 15 +++++++ server/neptune/adhoc/config/config.go | 8 ++-- server/neptune/adhoc/server.go | 42 ++++++++++--------- 4 files changed, 52 insertions(+), 23 deletions(-) create mode 100644 server/neptune/adhoc/adhocexecutionhelpers/adhoc_execution_params.go diff --git a/cmd/adhoc.go b/cmd/adhoc.go index 21b93c0fb..26645d401 100644 --- a/cmd/adhoc.go +++ b/cmd/adhoc.go @@ -7,8 +7,11 @@ import ( "github.com/runatlantis/atlantis/server/legacy" "github.com/runatlantis/atlantis/server/logging" adhoc "github.com/runatlantis/atlantis/server/neptune/adhoc" + adhocHelpers "github.com/runatlantis/atlantis/server/neptune/adhoc/adhocexecutionhelpers" adhocconfig "github.com/runatlantis/atlantis/server/neptune/adhoc/config" neptune "github.com/runatlantis/atlantis/server/neptune/temporalworker/config" + "github.com/runatlantis/atlantis/server/neptune/workflows/activities/github" + "github.com/runatlantis/atlantis/server/neptune/workflows/activities/terraform" ) type Adhoc struct{} @@ -62,6 +65,13 @@ func (a *Adhoc) NewServer(userConfig legacy.UserConfig, config legacy.Config) (S CtxLogger: ctxLogger, StatsNamespace: userConfig.StatsNamespace, Metrics: globalCfg.Metrics, + AdhocExecutionParams: adhocHelpers.AdhocTerraformWorkflowExecutionParams{ + AtlantisRoot: globalCfg.AdhocMode.Root, + AtlantisRepo: globalCfg.AdhocMode.Repo, + Revision: "", + TerraformRoot: terraform.Root{}, + GithubRepo: github.Repo{}, + }, } return adhoc.NewServer(cfg) } diff --git a/server/neptune/adhoc/adhocexecutionhelpers/adhoc_execution_params.go b/server/neptune/adhoc/adhocexecutionhelpers/adhoc_execution_params.go new file mode 100644 index 000000000..c21423ebf --- /dev/null +++ b/server/neptune/adhoc/adhocexecutionhelpers/adhoc_execution_params.go @@ -0,0 +1,15 @@ +package adhoc + +import ( + "github.com/runatlantis/atlantis/server/neptune/workflows/activities/github" + "github.com/runatlantis/atlantis/server/neptune/workflows/activities/terraform" +) + +type AdhocTerraformWorkflowExecutionParams struct { + AtlantisRoot string + AtlantisRepo string + Revision string + TerraformRoot terraform.Root + GithubRepo github.Repo + // Note that deploymentID is used in NewWorkflowStore(), but we don't care about that in adhoc mode so can leave it blank +} diff --git a/server/neptune/adhoc/config/config.go b/server/neptune/adhoc/config/config.go index dd77db7f1..11f7cc5fd 100644 --- a/server/neptune/adhoc/config/config.go +++ b/server/neptune/adhoc/config/config.go @@ -4,6 +4,7 @@ import ( "github.com/palantir/go-githubapp/githubapp" "github.com/runatlantis/atlantis/server/config/valid" "github.com/runatlantis/atlantis/server/logging" + adhoc "github.com/runatlantis/atlantis/server/neptune/adhoc/adhocexecutionhelpers" neptune "github.com/runatlantis/atlantis/server/neptune/temporalworker/config" ) @@ -19,7 +20,8 @@ type Config struct { StatsNamespace string - DataDir string - CtxLogger logging.Logger - App githubapp.Config + DataDir string + CtxLogger logging.Logger + App githubapp.Config + AdhocExecutionParams adhoc.AdhocTerraformWorkflowExecutionParams } diff --git a/server/neptune/adhoc/server.go b/server/neptune/adhoc/server.go index 94b53e27f..405311946 100644 --- a/server/neptune/adhoc/server.go +++ b/server/neptune/adhoc/server.go @@ -24,6 +24,7 @@ import ( "github.com/pkg/errors" "github.com/runatlantis/atlantis/server/logging" "github.com/runatlantis/atlantis/server/metrics" + adhoc "github.com/runatlantis/atlantis/server/neptune/adhoc/adhocexecutionhelpers" adhocconfig "github.com/runatlantis/atlantis/server/neptune/adhoc/config" neptune_http "github.com/runatlantis/atlantis/server/neptune/http" internalSync "github.com/runatlantis/atlantis/server/neptune/sync" @@ -39,18 +40,18 @@ import ( ) type Server struct { - Logger logging.Logger - CronScheduler *internalSync.CronScheduler - Crons []*internalSync.Cron - HTTPServerProxy *neptune_http.ServerProxy - Port int - StatsScope tally.Scope - StatsCloser io.Closer - TemporalClient *temporal.ClientWrapper - TerraformActivities *activities.Terraform - GithubActivities *activities.Github - - TerraformTaskQueue string + Logger logging.Logger + CronScheduler *internalSync.CronScheduler + Crons []*internalSync.Cron + HTTPServerProxy *neptune_http.ServerProxy + Port int + StatsScope tally.Scope + StatsCloser io.Closer + TemporalClient *temporal.ClientWrapper + TerraformActivities *activities.Terraform + GithubActivities *activities.Github + AdhocExecutionParams adhoc.AdhocTerraformWorkflowExecutionParams + TerraformTaskQueue string } func NewServer(config *adhocconfig.Config) (*Server, error) { @@ -160,14 +161,15 @@ func NewServer(config *adhocconfig.Config) (*Server, error) { Frequency: 1 * time.Minute, }, }, - HTTPServerProxy: httpServerProxy, - Port: config.ServerCfg.Port, - StatsScope: scope, - StatsCloser: statsCloser, - TemporalClient: temporalClient, - TerraformActivities: terraformActivities, - TerraformTaskQueue: config.TemporalCfg.TerraformTaskQueue, - GithubActivities: githubActivities, + HTTPServerProxy: httpServerProxy, + Port: config.ServerCfg.Port, + StatsScope: scope, + StatsCloser: statsCloser, + TemporalClient: temporalClient, + TerraformActivities: terraformActivities, + TerraformTaskQueue: config.TemporalCfg.TerraformTaskQueue, + GithubActivities: githubActivities, + AdhocExecutionParams: config.AdhocExecutionParams, } return &server, nil }