Skip to content

Commit

Permalink
feat: embed the ingress config in each environment configuration from…
Browse files Browse the repository at this point in the history
… requirements config

Signed-off-by: Cosmin Cojocar <cosmin.cojocar@gmx.ch>
  • Loading branch information
ccojocar committed Sep 6, 2019
1 parent 6cc184c commit 86d484f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/cmd/step/verify/step_verify_environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,17 @@ func (o *StepVerifyEnvironmentsOptions) createEnvGitRepository(name string, requ
}

func (o *StepVerifyEnvironmentsOptions) createEnvironmentHelmValues(requirements *config.RequirementsConfig, environment *v1.Environment) (config.HelmValuesConfig, error) {
// lets default the ingress requirements
envCfg, err := requirements.Environment(environment.GetName())
if err != nil || envCfg == nil {
return config.HelmValuesConfig{}, errors.Wrapf(err,
"looking the configuration of environment %q in the requirements configuration", environment.GetName())
}
domain := requirements.Ingress.Domain
if envCfg.Ingress.Domain != "" {
domain = envCfg.Ingress.Domain
}
useHTTP := "true"
tlsAcme := ""
tlsAcme := "false"
if requirements.Ingress.TLS.Enabled {
useHTTP = "false"
tlsAcme = "true"
Expand Down
12 changes: 12 additions & 0 deletions pkg/config/install_requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ type EnvironmentConfig struct {
GitServer string `json:"gitServer,omitempty"`
// GitKind is the kind of git server (github, bitbucketserver etc)
GitKind string `json:"gitKind,omitempty"`
// Ingress contains ingress specific requirements
Ingress IngressConfig `json:"ingress,omitempty"`
}

// IngressConfig contains dns specific requirements
Expand Down Expand Up @@ -374,6 +376,16 @@ func (c *RequirementsConfig) EnvironmentMap() map[string]interface{} {
return answer
}

// Environment looks up the environment configuration based on environment name
func (c *RequirementsConfig) Environment(name string) (*EnvironmentConfig, error) {
for _, env := range c.Environments {
if env.Key == name {
return &env, nil
}
}
return nil, fmt.Errorf("environment %q not found", name)
}

// ToMap converts this object to a map of maps for use in helm templating
func (c *RequirementsConfig) ToMap() (map[string]interface{}, error) {
m, err := util.ToObjectMap(c)
Expand Down

0 comments on commit 86d484f

Please sign in to comment.