Skip to content

Commit 490f752

Browse files
committed
rename Config to EnvironmentConfig
1 parent 3172005 commit 490f752

File tree

8 files changed

+28
-28
lines changed

8 files changed

+28
-28
lines changed

cmd/config.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func RuntimeConfigFromFlags(envDir, envName string) RuntimeConfig {
4343
}
4444
}
4545

46-
type Config struct {
46+
type EnvironmentConfig struct {
4747
Global GlobalConfig `yaml:"global"`
4848
Features FeatureConfig `yaml:"features"`
4949
Cloudserver CloudserverConfig `yaml:"cloudserver"`
@@ -190,8 +190,8 @@ type RedisConfig struct {
190190
LogLevel string `yaml:"log_level"`
191191
}
192192

193-
func DefaultConfig() Config {
194-
return Config{
193+
func DefaultEnvironmentConfig() EnvironmentConfig {
194+
return EnvironmentConfig{
195195
Global: GlobalConfig{
196196
LogLevel: "info",
197197
// Profile: "default",
@@ -238,8 +238,8 @@ func DefaultConfig() Config {
238238
}
239239
}
240240

241-
func LoadConfig(path string) (Config, error) {
242-
cfg := DefaultConfig()
241+
func LoadEnvironmentConfig(path string) (EnvironmentConfig, error) {
242+
cfg := DefaultEnvironmentConfig()
243243

244244
if path == "" {
245245
return cfg, nil
@@ -252,7 +252,7 @@ func LoadConfig(path string) (Config, error) {
252252
}
253253

254254
// Parse the YAML into a temporary config
255-
var fileCfg Config
255+
var fileCfg EnvironmentConfig
256256
if err := yaml.Unmarshal(data, &fileCfg); err != nil {
257257
return cfg, fmt.Errorf("failed to parse config file: %w", err)
258258
}

cmd/configure.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ type ConfigureCmd struct {
1313
Name string `help:"Name of the environment to create. default: 'default'" short:"n"`
1414
}
1515

16-
type configGenFunc func(cfg Config, path string) error
16+
type configGenFunc func(cfg EnvironmentConfig, path string) error
1717

1818
func (c *ConfigureCmd) Run() error {
1919
rc := RuntimeConfigFromFlags(c.EnvDir, c.Name)
2020
envPath := filepath.Join(rc.EnvDir, rc.EnvName)
2121
configPath := filepath.Join(envPath, "config.yaml")
2222

2323
// Load the global configuration
24-
cfg, err := LoadConfig(configPath)
24+
cfg, err := LoadEnvironmentConfig(configPath)
2525
if err != nil {
2626
return fmt.Errorf("failed to load config: %w", err)
2727
}
@@ -49,7 +49,7 @@ func createLogDirectories(envDir string) error {
4949
return nil
5050
}
5151

52-
func configureEnv(cfg Config, envDir string) error {
52+
func configureEnv(cfg EnvironmentConfig, envDir string) error {
5353
log.Info().Msgf("Configuring environment %s", envDir)
5454

5555
if err := createLogDirectories(envDir); err != nil {
@@ -86,16 +86,16 @@ func configureEnv(cfg Config, envDir string) error {
8686
return nil
8787
}
8888

89-
func generateDefaultsEnv(cfg Config, envDir string) error {
89+
func generateDefaultsEnv(cfg EnvironmentConfig, envDir string) error {
9090
defaultsEnvPath := filepath.Join(envDir, "defaults.env")
9191
return renderTemplateToFile(getTemplates(), "templates/global/defaults.env", cfg, defaultsEnvPath)
9292
}
9393

94-
func generateCloudserverConfig(cfg Config, path string) error {
94+
func generateCloudserverConfig(cfg EnvironmentConfig, path string) error {
9595
return renderTemplateToFile(getTemplates(), "templates/cloudserver/config.json", cfg, filepath.Join(path, "cloudserver", "config.json"))
9696
}
9797

98-
func generateBackbeatConfig(cfg Config, path string) error {
98+
func generateBackbeatConfig(cfg EnvironmentConfig, path string) error {
9999
templates := []string{
100100
"env",
101101
"supervisord.conf",
@@ -107,7 +107,7 @@ func generateBackbeatConfig(cfg Config, path string) error {
107107
return renderTemplates(cfg, "templates/backbeat", filepath.Join(path, "backbeat"), templates)
108108
}
109109

110-
func generateVaultConfig(cfg Config, path string) error {
110+
func generateVaultConfig(cfg EnvironmentConfig, path string) error {
111111
templates := []string{
112112
"config.json",
113113
"create-management-account.sh",
@@ -118,7 +118,7 @@ func generateVaultConfig(cfg Config, path string) error {
118118
return renderTemplates(cfg, "templates/vault", filepath.Join(path, "vault"), templates)
119119
}
120120

121-
func generateScubaConfig(cfg Config, path string) error {
121+
func generateScubaConfig(cfg EnvironmentConfig, path string) error {
122122
templates := []string{
123123
"config.json",
124124
"create-service-user.sh",
@@ -133,17 +133,17 @@ func generateMetadataConfig(cfg MetadataConfig, path string) error {
133133
return renderTemplateToFile(getTemplates(), "templates/metadata/config.json", cfg, filepath.Join(path, "config.json"))
134134
}
135135

136-
func generateS3MetadataConfig(cfg Config, path string) error {
136+
func generateS3MetadataConfig(cfg EnvironmentConfig, path string) error {
137137
cfgPath := filepath.Join(path, "metadata-s3")
138138
return generateMetadataConfig(cfg.S3Metadata, cfgPath)
139139
}
140140

141-
func generateScubaMetadataConfig(cfg Config, path string) error {
141+
func generateScubaMetadataConfig(cfg EnvironmentConfig, path string) error {
142142
cfgPath := filepath.Join(path, "metadata-scuba")
143143
return generateMetadataConfig(cfg.ScubaMetadata, cfgPath)
144144
}
145145

146-
func generateKafkaConfig(cfg Config, path string) error {
146+
func generateKafkaConfig(cfg EnvironmentConfig, path string) error {
147147
templates := []string{
148148
"Dockerfile",
149149
"setup.sh",
@@ -156,6 +156,6 @@ func generateKafkaConfig(cfg Config, path string) error {
156156
return renderTemplates(cfg, "templates/kafka", filepath.Join(path, "kafka"), templates)
157157
}
158158

159-
func generateUtapiConfig(cfg Config, path string) error {
159+
func generateUtapiConfig(cfg EnvironmentConfig, path string) error {
160160
return renderTemplateToFile(getTemplates(), "templates/utapi/config.json", cfg, filepath.Join(path, "utapi", "config.json"))
161161
}

cmd/create-env.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ func (c *CreateEnvCmd) Run() error {
2323
return fmt.Errorf("failed to create environment: %w", err)
2424
}
2525

26-
var cfg Config
26+
var cfg EnvironmentConfig
2727
if c.WithConfig != "" {
28-
cfg, err = LoadConfig(c.WithConfig)
28+
cfg, err = LoadEnvironmentConfig(c.WithConfig)
2929
if err != nil {
3030
return fmt.Errorf("failed to load custom config: %w", err)
3131
}
3232
} else {
33-
cfg, err = LoadConfig(filepath.Join(envPath, "config.yaml"))
33+
cfg, err = LoadEnvironmentConfig(filepath.Join(envPath, "config.yaml"))
3434
if err != nil {
3535
return fmt.Errorf("failed to load config: %w", err)
3636
}

cmd/destroy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (c *DestroyCmd) Run() error {
3535
}
3636

3737
cfgPath := filepath.Join(envPath, "config.yaml")
38-
cfg, err := LoadConfig(cfgPath)
38+
cfg, err := LoadEnvironmentConfig(cfgPath)
3939
if err != nil {
4040
return err
4141
}

cmd/down.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (c *DownCmd) Run() error {
3434
}
3535

3636
cfgPath := filepath.Join(envPath, "config.yaml")
37-
cfg, err := LoadConfig(cfgPath)
37+
cfg, err := LoadEnvironmentConfig(cfgPath)
3838
if err != nil {
3939
return err
4040
}

cmd/logs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (c *LogsCmd) Run() error {
2424
envPath := filepath.Join(rc.EnvDir, rc.EnvName)
2525

2626
cfgPath := filepath.Join(envPath, "config.yaml")
27-
cfg, err := LoadConfig(cfgPath)
27+
cfg, err := LoadEnvironmentConfig(cfgPath)
2828
if err != nil {
2929
return err
3030
}

cmd/up.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (c *UpCmd) Run() error {
3535
}
3636

3737
cfgPath := filepath.Join(envPath, "config.yaml")
38-
cfg, err := LoadConfig(cfgPath)
38+
cfg, err := LoadEnvironmentConfig(cfgPath)
3939
if err != nil {
4040
return err
4141
}

cmd/util.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func renderTemplateToFile(templates fs.FS, tmplPath string, data any, outPath st
5151
return nil
5252
}
5353

54-
func renderTemplates(cfg Config, srcDir, destDir string, templates []string) error {
54+
func renderTemplates(cfg EnvironmentConfig, srcDir, destDir string, templates []string) error {
5555
templateFS := getTemplates()
5656
for _, tmpl := range templates {
5757
templatePath := filepath.Join(srcDir, tmpl)
@@ -63,7 +63,7 @@ func renderTemplates(cfg Config, srcDir, destDir string, templates []string) err
6363
return nil
6464
}
6565

66-
func getComposeProfiles(cfg Config) []string {
66+
func getComposeProfiles(cfg EnvironmentConfig) []string {
6767
profiles := []string{"base"}
6868

6969
if cfg.Features.Scuba.Enabled {
@@ -81,7 +81,7 @@ func getComposeProfiles(cfg Config) []string {
8181
return profiles
8282
}
8383

84-
func buildDockerComposeCommand(cfg Config, args ...string) []string {
84+
func buildDockerComposeCommand(cfg EnvironmentConfig, args ...string) []string {
8585
profiles := getComposeProfiles(cfg)
8686

8787
dockerComposeCmd := []string{

0 commit comments

Comments
 (0)