Skip to content

Commit

Permalink
Use different namespace for elastic-agent (#723)
Browse files Browse the repository at this point in the history
* Use different namespace for elastic-agent

* Fix

* Test: release version

* Fix
  • Loading branch information
mtojek authored May 17, 2022
1 parent 712e237 commit 6ebf5de
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
17 changes: 14 additions & 3 deletions internal/install/application_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ import (
"github.com/elastic/elastic-package/internal/logger"
)

const stackVersion715 = "7.15.0-SNAPSHOT"
const (
stackVersion715 = "7.15.0-SNAPSHOT"
stackVersion820 = "8.2.0-SNAPSHOT"
)

var elasticAgentCompleteFirstSupportedVersion = semver.MustParse(stackVersion715)
var (
elasticAgentCompleteFirstSupportedVersion = semver.MustParse(stackVersion715)
elasticAgentCompleteOwnNamespaceVersion = semver.MustParse(stackVersion820)
)

// ApplicationConfiguration represents the configuration of the elastic-package.
type ApplicationConfiguration struct {
Expand Down Expand Up @@ -83,9 +89,14 @@ func selectElasticAgentImageName(version string) string {
v, err := semver.NewVersion(version)
if err != nil {
logger.Errorf("stack version not in semver format (value: %s): %v", v, err)
} else if !v.LessThan(elasticAgentCompleteFirstSupportedVersion) {
return elasticAgentImageName
}
if !v.LessThan(elasticAgentCompleteOwnNamespaceVersion) {
return elasticAgentCompleteImageName
}
if !v.LessThan(elasticAgentCompleteFirstSupportedVersion) {
return elasticAgentCompleteLegacyImageName
}
return elasticAgentImageName
}

Expand Down
20 changes: 19 additions & 1 deletion internal/install/application_configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,29 @@ func TestSelectElasticAgentImageName_OlderStack(t *testing.T) {
func TestSelectElasticAgentImageName_FirstStackWithCompleteAgent(t *testing.T) {
version := stackVersion715
selected := selectElasticAgentImageName(version)
assert.Equal(t, selected, elasticAgentCompleteImageName)
assert.Equal(t, selected, elasticAgentCompleteLegacyImageName)
}

func TestSelectElasticAgentImageName_NextStackWithAgentComplete(t *testing.T) {
version := "7.16.0-SNAPSHOT"
selected := selectElasticAgentImageName(version)
assert.Equal(t, selected, elasticAgentCompleteLegacyImageName)
}

func TestSelectElasticAgentImageName_OwnNamespace(t *testing.T) {
version := "8.2.0-SNAPSHOT"
selected := selectElasticAgentImageName(version)
assert.Equal(t, selected, elasticAgentCompleteImageName)
}

func TestSelectElasticAgentImageName_OwnNamespace_Release(t *testing.T) {
version := "8.2.0"
selected := selectElasticAgentImageName(version)
assert.Equal(t, selected, elasticAgentCompleteImageName)
}

func TestSelectElasticAgentImageName_NextStackInOwnNamespace(t *testing.T) {
version := "8.4.0-SNAPSHOT"
selected := selectElasticAgentImageName(version)
assert.Equal(t, selected, elasticAgentCompleteImageName)
}
9 changes: 5 additions & 4 deletions internal/install/application_configuration_yml.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
package install

const (
elasticAgentImageName = "docker.elastic.co/beats/elastic-agent"
elasticAgentCompleteImageName = "docker.elastic.co/beats/elastic-agent-complete"
elasticsearchImageName = "docker.elastic.co/elasticsearch/elasticsearch"
kibanaImageName = "docker.elastic.co/kibana/kibana"
elasticAgentImageName = "docker.elastic.co/beats/elastic-agent"
elasticAgentCompleteLegacyImageName = "docker.elastic.co/beats/elastic-agent-complete"
elasticAgentCompleteImageName = "docker.elastic.co/elastic-agent/elastic-agent-complete"
elasticsearchImageName = "docker.elastic.co/elasticsearch/elasticsearch"
kibanaImageName = "docker.elastic.co/kibana/kibana"
)

const applicationConfigurationYmlFile = "config.yml"
Expand Down

0 comments on commit 6ebf5de

Please sign in to comment.