-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |