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 56d94a5 commit 0e831f3
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions cmd/admin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package cmd

import (
"github.com/pkg/errors"
cfgParser "github.com/runatlantis/atlantis/server/config"
"github.com/runatlantis/atlantis/server/config/valid"
"github.com/runatlantis/atlantis/server/legacy"
"github.com/runatlantis/atlantis/server/logging"
"github.com/runatlantis/atlantis/server/neptune/admin"
adminconfig "github.com/runatlantis/atlantis/server/neptune/admin/config"
neptune "github.com/runatlantis/atlantis/server/neptune/temporalworker/config"
)

type Admin struct{}

// NewServer returns the real Atlantis server object.
func (a *Admin) NewServer(userConfig legacy.UserConfig, config legacy.Config) (ServerStarter, error) {
ctxLogger, err := logging.NewLoggerFromLevel(userConfig.ToLogLevel())
if err != nil {
return nil, errors.Wrap(err, "failed to build context logger")
}

globalCfg := valid.NewGlobalCfg(userConfig.DataDir)
validator := &cfgParser.ParserValidator{}

// TODO: should terraformadminmode pass in this stuff?
if userConfig.RepoConfig != "" {
globalCfg, err = validator.ParseGlobalCfg(userConfig.RepoConfig, globalCfg)
if err != nil {
return nil, errors.Wrapf(err, "parsing %s file", userConfig.RepoConfig)
}
}

parsedURL, err := legacy.ParseAtlantisURL(userConfig.AtlantisURL)
if err != nil {
return nil, errors.Wrapf(err,
"parsing atlantis url %q", userConfig.AtlantisURL)
}

appConfig, err := createGHAppConfig(userConfig)
if err != nil {
return nil, err
}

cfg := &adminconfig.Config{
AuthCfg: neptune.AuthConfig{
SslCertFile: userConfig.SSLCertFile,
SslKeyFile: userConfig.SSLKeyFile,
},
ServerCfg: neptune.ServerConfig{
URL: parsedURL,
Version: config.AtlantisVersion,
Port: userConfig.Port,
},
// we need the terraformcfg stuff, since we need terraformActivities
TerraformCfg: neptune.TerraformConfig{
DefaultVersion: userConfig.DefaultTFVersion,
DownloadURL: userConfig.TFDownloadURL,
LogFilters: globalCfg.TerraformLogFilter,
},
// Do not need deployment config
// do need datadir, we will save the archive there
DataDir: userConfig.DataDir,
// do need temporalconfig since we use temporal
TemporalCfg: globalCfg.Temporal,
// do need githubcfg, since we use github to get the archive
GithubCfg: globalCfg.Github,
// same as above
App: appConfig,
// we do need logging
CtxLogger: ctxLogger,
// we do need stats
StatsNamespace: userConfig.StatsNamespace,
// we do need metrics
Metrics: globalCfg.Metrics,
// no SnsTopicArn since we don't use the auditing
// no revision setter
}
return admin.NewServer(cfg)
}

0 comments on commit 0e831f3

Please sign in to comment.