Skip to content

Commit

Permalink
[DEVCON-6859] Add adhoc execution params struct that will be used for…
Browse files Browse the repository at this point in the history
… ExecuteWorkflow(terraform..) (#735)
  • Loading branch information
smonero authored Mar 21, 2024
1 parent 4653d77 commit d9bcb95
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 23 deletions.
10 changes: 10 additions & 0 deletions cmd/adhoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
@@ -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
}
8 changes: 5 additions & 3 deletions server/neptune/adhoc/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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
}
42 changes: 22 additions & 20 deletions server/neptune/adhoc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit d9bcb95

Please sign in to comment.