Skip to content

Commit

Permalink
still making progress
Browse files Browse the repository at this point in the history
  • Loading branch information
smonero committed Mar 6, 2024
1 parent fd7c8ba commit 1ad555f
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 27 deletions.
2 changes: 1 addition & 1 deletion cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ var stringFlags = map[string]stringFlag{
"gateway: Runs atlantis with gateway event handler that publishes events through sns.\n" +
"worker: Runs atlantis with a sqs handler that polls for events in the queue to process.\n" +
"hybrid: Runs atlantis with both a gateway event handler and sqs handler to perform both gateway and worker behaviors.\n" +
"terraformadmin: Runs atlantis in a mode that allows for running terraform commands.",
"admin: Runs atlantis in an admin mode that allows for running terraform commands.",
defaultValue: "",
},
LyftWorkerQueueURLFlag: {
Expand Down
12 changes: 6 additions & 6 deletions cmd/terraformadmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/runatlantis/atlantis/server/config/valid"
"github.com/runatlantis/atlantis/server/legacy"
"github.com/runatlantis/atlantis/server/logging"
neptune "github.com/runatlantis/atlantis/server/neptune/temporalworker/config"
"github.com/runatlantis/atlantis/server/neptune/terraformadmin"

Check failure on line 9 in cmd/terraformadmin.go

View workflow job for this annotation

GitHub Actions / runner / gotest

no required module provides package github.com/runatlantis/atlantis/server/neptune/terraformadmin; to add it:
adminconfig "github.com/runatlantis/atlantis/server/neptune/terraformadmin/config"

Check failure on line 10 in cmd/terraformadmin.go

View workflow job for this annotation

GitHub Actions / runner / gotest

no required module provides package github.com/runatlantis/atlantis/server/neptune/terraformadmin/config; to add it:
)

type TerraformAdmin struct{}
Expand Down Expand Up @@ -42,27 +42,27 @@ func (t *TerraformAdmin) NewServer(userConfig legacy.UserConfig, config legacy.C
}

// we don't need the feature config
cfg := &neptune.Config{
cfg := &adminconfig.Config{
// we need the authCfg and ssl stuff for the http server
AuthCfg: neptune.AuthConfig{
AuthCfg: adminconfig.AuthConfig{
SslCertFile: userConfig.SSLCertFile,
SslKeyFile: userConfig.SSLKeyFile,
},
// we need the servercfg stuff, see setAtlantisURL() TODO: is this true?
ServerCfg: neptune.ServerConfig{
ServerCfg: adminconfig.ServerConfig{
URL: parsedURL,
Version: config.AtlantisVersion,
Port: userConfig.Port,
},
// we need the terraformcfg stuff, since we need terraformActivities
TerraformCfg: neptune.TerraformConfig{
TerraformCfg: adminconfig.TerraformConfig{
DefaultVersion: userConfig.DefaultTFVersion,
DownloadURL: userConfig.TFDownloadURL,
LogFilters: globalCfg.TerraformLogFilter,
},
// also passed to terraform activities, even though we don't need conf test OPA stuff
// TODO: But we have to introduce branching if we remove this...
ValidationConfig: neptune.ValidationConfig{
ValidationConfig: adminconfig.ValidationConfig{
DefaultVersion: globalCfg.PolicySets.Version,
Policies: globalCfg.PolicySets,
},
Expand Down
6 changes: 3 additions & 3 deletions server/legacy/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const (
Gateway
Worker
TemporalWorker
TerraformAdmin
Admin
)

// UserConfig holds config values passed in by the user.
Expand Down Expand Up @@ -105,8 +105,8 @@ func (u UserConfig) ToLyftMode() Mode {
return Worker
case "temporalworker":
return TemporalWorker
case "terraformadmin":
return TerraformAdmin
case "admin":
return Admin
}
return Default
}
4 changes: 2 additions & 2 deletions server/legacy/user_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func TestUserConfig_ToLyftMode(t *testing.T) {
server.Default,
},
{
"terraformadmin",
server.TerraformAdmin,
"admin",
server.Admin,
},
{
"temporalworker",
Expand Down
61 changes: 61 additions & 0 deletions server/neptune/admin/config/adminconfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package adminconfig

import (
"net/url"

"github.com/hashicorp/go-version"

"github.com/palantir/go-githubapp/githubapp"
"github.com/runatlantis/atlantis/server/config/valid"
"github.com/runatlantis/atlantis/server/logging"
)

type AuthConfig struct {
SslCertFile string
SslKeyFile string
}

type ServerConfig struct {
URL *url.URL
Version string
Port int
}

type TerraformConfig struct {
DefaultVersion string
DownloadURL string
LogFilters valid.TerraformLogFilters
}

type ValidationConfig struct {
DefaultVersion *version.Version
Policies valid.PolicySets
}

type FeatureConfig struct {
FFOwner string
FFRepo string
FFPath string
FFBranch string
}

// Config is TerraformAdmin (admin mode) specific user config
type Config struct {
AuthCfg AuthConfig
ServerCfg ServerConfig
FeatureConfig FeatureConfig
TemporalCfg valid.Temporal
GithubCfg valid.Github
TerraformCfg TerraformConfig
ValidationConfig ValidationConfig
DeploymentConfig valid.StoreConfig
JobConfig valid.StoreConfig
Metrics valid.Metrics

StatsNamespace string

DataDir string
CtxLogger logging.Logger
App githubapp.Config
LyftAuditJobsSnsTopicArn string
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package terraformadmin
package admin

import (
"context"
Expand All @@ -25,7 +25,7 @@ import (
"github.com/runatlantis/atlantis/server/metrics"
neptune_http "github.com/runatlantis/atlantis/server/neptune/http"
"github.com/runatlantis/atlantis/server/neptune/temporal"
"github.com/runatlantis/atlantis/server/neptune/temporalworker/config"
adminconfig "github.com/runatlantis/atlantis/server/neptune/terraformadmin/config"
"github.com/runatlantis/atlantis/server/neptune/workflows"
"github.com/runatlantis/atlantis/server/neptune/workflows/activities"
"github.com/runatlantis/atlantis/server/static"
Expand All @@ -44,20 +44,11 @@ type Server struct {
TemporalClient *temporal.ClientWrapper
TerraformActivities *activities.Terraform
GithubActivities *activities.Github
// differences from temporal worker:
// - no additional notifiers
// - no revision setter
// - no PRRevisionGithubActivities
// - no AuditActivity
// - no RevisionSetterActivities
// - no DeployActivities
// - no JobStreamHandler
// - no CronScheduler
// - no crons

TerraformTaskQueue string
}

func NewServer(config *config.Config) (*Server, error) {
func NewServer(config *adminconfig.Config) (*Server, error) {
statsReporter, err := metrics.NewReporter(config.Metrics, config.CtxLogger)

if err != nil {
Expand All @@ -70,7 +61,7 @@ func NewServer(config *config.Config) (*Server, error) {
}

scope = scope.Tagged(map[string]string{
"mode": "terraformadmin",
"mode": "admin",
})

// difference from temporalworker: no job stuff (handler, controller, etc)
Expand Down Expand Up @@ -115,7 +106,7 @@ func NewServer(config *config.Config) (*Server, error) {
config.TemporalCfg.TerraformTaskQueue,
config.GithubCfg.TemporalAppInstallationID,
nil,
// difference from temporalworker: no jobstreamhandler TODO: test if this actually works
// difference from temporalworker: no jobstreamhandler TODO: test if this actually works
)
if err != nil {
return nil, errors.Wrap(err, "initializing terraform activities")
Expand Down

0 comments on commit 1ad555f

Please sign in to comment.