From 88e7e1415e415012d2bc372d6231412186f56cb5 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 7 Oct 2021 16:07:17 +0200 Subject: [PATCH] Fix: don't fallback to default stack version (#535) * WIP * Fix: don't fallback to default stack version --- internal/install/application_configuration.go | 31 +++++-------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/internal/install/application_configuration.go b/internal/install/application_configuration.go index be0d7dd8b..eee9483f8 100644 --- a/internal/install/application_configuration.go +++ b/internal/install/application_configuration.go @@ -34,35 +34,18 @@ type stack struct { ImageRefOverrides map[string]ImageRefs `yaml:"image_ref_overrides"` } -func checkImageRefOverride(envVar string, fallback string) string { +func checkImageRefOverride(envVar, fallback string) string { refOverride := os.Getenv(envVar) - if refOverride == "" { - return fallback - } - - return refOverride + return stringOrDefault(refOverride, fallback) } func (s stack) ImageRefOverridesForVersion(version string) ImageRefs { - refs, ok := s.ImageRefOverrides[version] - - elasticAgentRefOverride := checkImageRefOverride("ELASTIC_AGENT_IMAGE_REF_OVERRIDE", fmt.Sprintf("%s:%s", elasticAgentImageName, DefaultStackVersion)) - elasticsearchRefOverride := checkImageRefOverride("ELASTICSEARCH_IMAGE_REF_OVERRIDE", fmt.Sprintf("%s:%s", elasticsearchImageName, DefaultStackVersion)) - kibanaRefOverride := checkImageRefOverride("KIBANA_IMAGE_REF_OVERRIDE", fmt.Sprintf("%s:%s", kibanaImageName, DefaultStackVersion)) - - if !ok { - return ImageRefs{ - ElasticAgent: elasticAgentRefOverride, - Elasticsearch: elasticsearchRefOverride, - Kibana: kibanaRefOverride, - } + appConfigImageRefs := s.ImageRefOverrides[version] + return ImageRefs{ + ElasticAgent: checkImageRefOverride("ELASTIC_AGENT_IMAGE_REF_OVERRIDE", stringOrDefault(appConfigImageRefs.ElasticAgent, "")), + Elasticsearch: checkImageRefOverride("ELASTICSEARCH_IMAGE_REF_OVERRIDE", stringOrDefault(appConfigImageRefs.Elasticsearch, "")), + Kibana: checkImageRefOverride("KIBANA_IMAGE_REF_OVERRIDE", stringOrDefault(appConfigImageRefs.Kibana, "")), } - - refs.ElasticAgent = elasticAgentRefOverride - refs.Elasticsearch = elasticsearchRefOverride - refs.Kibana = kibanaRefOverride - - return refs } // ImageRefs stores Docker image references used to create the Elastic stack containers.