-
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.
[DEVCON-6849] First part of new flow of adhoc mode (#727)
- Loading branch information
Showing
8 changed files
with
384 additions
and
9 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,67 @@ | ||
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" | ||
adhoc "github.com/runatlantis/atlantis/server/neptune/adhoc" | ||
adhocconfig "github.com/runatlantis/atlantis/server/neptune/adhoc/config" | ||
neptune "github.com/runatlantis/atlantis/server/neptune/temporalworker/config" | ||
) | ||
|
||
type Adhoc struct{} | ||
|
||
func (a *Adhoc) 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{} | ||
|
||
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 := &adhocconfig.Config{ | ||
AuthCfg: neptune.AuthConfig{ | ||
SslCertFile: userConfig.SSLCertFile, | ||
SslKeyFile: userConfig.SSLKeyFile, | ||
}, | ||
ServerCfg: neptune.ServerConfig{ | ||
URL: parsedURL, | ||
Version: config.AtlantisVersion, | ||
Port: userConfig.Port, | ||
}, | ||
TerraformCfg: neptune.TerraformConfig{ | ||
DefaultVersion: userConfig.DefaultTFVersion, | ||
DownloadURL: userConfig.TFDownloadURL, | ||
LogFilters: globalCfg.TerraformLogFilter, | ||
}, | ||
DataDir: userConfig.DataDir, | ||
TemporalCfg: globalCfg.Temporal, | ||
GithubCfg: globalCfg.Github, | ||
App: appConfig, | ||
CtxLogger: ctxLogger, | ||
StatsNamespace: userConfig.StatsNamespace, | ||
Metrics: globalCfg.Metrics, | ||
} | ||
return adhoc.NewServer(cfg) | ||
} |
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
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
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
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
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
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,25 @@ | ||
package adhocconfig | ||
|
||
import ( | ||
"github.com/palantir/go-githubapp/githubapp" | ||
"github.com/runatlantis/atlantis/server/config/valid" | ||
"github.com/runatlantis/atlantis/server/logging" | ||
neptune "github.com/runatlantis/atlantis/server/neptune/temporalworker/config" | ||
) | ||
|
||
// Config is TerraformAdmin (Adhoc mode) specific user config | ||
type Config struct { | ||
AuthCfg neptune.AuthConfig | ||
ServerCfg neptune.ServerConfig | ||
FeatureConfig neptune.FeatureConfig | ||
TemporalCfg valid.Temporal | ||
GithubCfg valid.Github | ||
TerraformCfg neptune.TerraformConfig | ||
Metrics valid.Metrics | ||
|
||
StatsNamespace string | ||
|
||
DataDir string | ||
CtxLogger logging.Logger | ||
App githubapp.Config | ||
} |
Oops, something went wrong.