Skip to content

Commit 4c8b1ff

Browse files
authored
Fix: use two Docker images of elastic-agent (#521)
* Define two different images * Fix
1 parent d39f666 commit 4c8b1ff

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

internal/install/application_configuration.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ import (
99
"os"
1010
"path/filepath"
1111

12+
"github.com/Masterminds/semver"
1213
"github.com/pkg/errors"
1314
"gopkg.in/yaml.v3"
1415

1516
"github.com/elastic/elastic-package/internal/configuration/locations"
17+
"github.com/elastic/elastic-package/internal/logger"
1618
)
1719

20+
var elasticAgentCompleteFirstSupportedVersion = semver.MustParse("7.15.0-SNAPSHOT")
21+
1822
// ApplicationConfiguration represents the configuration of the elastic-package.
1923
type ApplicationConfiguration struct {
2024
c configFile
@@ -60,12 +64,24 @@ func (ac *ApplicationConfiguration) DefaultStackImageRefs() ImageRefs {
6064
// StackImageRefs function selects the appropriate set of Docker image references for the given stack version.
6165
func (ac *ApplicationConfiguration) StackImageRefs(version string) ImageRefs {
6266
refs := ac.c.Stack.ImageRefOverridesForVersion(version)
63-
refs.ElasticAgent = stringOrDefault(refs.ElasticAgent, fmt.Sprintf("%s:%s", elasticAgentImageName, version))
67+
refs.ElasticAgent = stringOrDefault(refs.ElasticAgent, fmt.Sprintf("%s:%s", selectElasticAgentImageName(version), version))
6468
refs.Elasticsearch = stringOrDefault(refs.Elasticsearch, fmt.Sprintf("%s:%s", elasticsearchImageName, version))
6569
refs.Kibana = stringOrDefault(refs.Kibana, fmt.Sprintf("%s:%s", kibanaImageName, version))
6670
return refs
6771
}
6872

73+
// selectElasticAgentImageName function returns the appropriate image name for Elastic-Agent depending on the stack version.
74+
// This is mandatory as "elastic-agent-complete" is available since 7.15.0-SNAPSHOT.
75+
func selectElasticAgentImageName(version string) string {
76+
v, err := semver.NewVersion(version)
77+
if err != nil {
78+
logger.Errorf("stack version not in semver format (value: %s): %v", v, err)
79+
} else if !v.LessThan(elasticAgentCompleteFirstSupportedVersion) {
80+
return elasticAgentCompleteImageName
81+
}
82+
return elasticAgentImageName
83+
}
84+
6985
// Configuration function returns the elastic-package configuration.
7086
func Configuration() (*ApplicationConfiguration, error) {
7187
configPath, err := locations.NewLocationManager()

internal/install/application_configuration_yml.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
package install
66

77
const (
8-
elasticAgentImageName = "docker.elastic.co/beats/elastic-agent-complete"
9-
elasticsearchImageName = "docker.elastic.co/elasticsearch/elasticsearch"
10-
kibanaImageName = "docker.elastic.co/kibana/kibana"
8+
elasticAgentImageName = "docker.elastic.co/beats/elastic-agent"
9+
elasticAgentCompleteImageName = "docker.elastic.co/beats/elastic-agent-complete"
10+
elasticsearchImageName = "docker.elastic.co/elasticsearch/elasticsearch"
11+
kibanaImageName = "docker.elastic.co/kibana/kibana"
1112
)
1213

1314
const applicationConfigurationYmlFile = "config.yml"

0 commit comments

Comments
 (0)