File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed
Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,9 @@ import (
1717 "github.com/elastic/elastic-package/internal/logger"
1818)
1919
20- var elasticAgentCompleteFirstSupportedVersion = semver .MustParse ("7.15.0-SNAPSHOT" )
20+ const stackVersion715 = "7.15.0-SNAPSHOT"
21+
22+ var elasticAgentCompleteFirstSupportedVersion = semver .MustParse (stackVersion715 )
2123
2224// ApplicationConfiguration represents the configuration of the elastic-package.
2325type ApplicationConfiguration struct {
@@ -73,6 +75,10 @@ func (ac *ApplicationConfiguration) StackImageRefs(version string) ImageRefs {
7375// selectElasticAgentImageName function returns the appropriate image name for Elastic-Agent depending on the stack version.
7476// This is mandatory as "elastic-agent-complete" is available since 7.15.0-SNAPSHOT.
7577func selectElasticAgentImageName (version string ) string {
78+ if version == "" { // as version is optional and can be empty
79+ return elasticAgentImageName
80+ }
81+
7682 v , err := semver .NewVersion (version )
7783 if err != nil {
7884 logger .Errorf ("stack version not in semver format (value: %s): %v" , v , err )
Original file line number Diff line number Diff line change 1+ // Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2+ // or more contributor license agreements. Licensed under the Elastic License;
3+ // you may not use this file except in compliance with the Elastic License.
4+
5+ package install
6+
7+ import (
8+ "testing"
9+
10+ "github.com/stretchr/testify/assert"
11+ )
12+
13+ func TestSelectElasticAgentImageName_NoVersion (t * testing.T ) {
14+ var version string
15+ selected := selectElasticAgentImageName (version )
16+ assert .Equal (t , selected , elasticAgentImageName )
17+ }
18+
19+ func TestSelectElasticAgentImageName_OlderStack (t * testing.T ) {
20+ version := "7.14.99-SNAPSHOT"
21+ selected := selectElasticAgentImageName (version )
22+ assert .Equal (t , selected , elasticAgentImageName )
23+ }
24+
25+ func TestSelectElasticAgentImageName_FirstStackWithCompleteAgent (t * testing.T ) {
26+ version := stackVersion715
27+ selected := selectElasticAgentImageName (version )
28+ assert .Equal (t , selected , elasticAgentCompleteImageName )
29+ }
30+
31+ func TestSelectElasticAgentImageName_NextStackWithAgentComplete (t * testing.T ) {
32+ version := "7.16.0-SNAPSHOT"
33+ selected := selectElasticAgentImageName (version )
34+ assert .Equal (t , selected , elasticAgentCompleteImageName )
35+ }
You can’t perform that action at this time.
0 commit comments