From 86d484f215bfb2caf4cec982d9845e2d7284ebce Mon Sep 17 00:00:00 2001 From: Cosmin Cojocar Date: Fri, 6 Sep 2019 12:22:21 +0200 Subject: [PATCH] feat: embed the ingress config in each environment configuration from requirements config Signed-off-by: Cosmin Cojocar --- pkg/cmd/step/verify/step_verify_environments.go | 11 +++++++++-- pkg/config/install_requirements.go | 12 ++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/step/verify/step_verify_environments.go b/pkg/cmd/step/verify/step_verify_environments.go index 5b3138049e4..7385572883f 100644 --- a/pkg/cmd/step/verify/step_verify_environments.go +++ b/pkg/cmd/step/verify/step_verify_environments.go @@ -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" diff --git a/pkg/config/install_requirements.go b/pkg/config/install_requirements.go index e720d4853cf..62f4b3e6663 100644 --- a/pkg/config/install_requirements.go +++ b/pkg/config/install_requirements.go @@ -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 @@ -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)