Skip to content

Commit 135dfa5

Browse files
committed
Move settings to stack package
1 parent bbcd692 commit 135dfa5

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

internal/testrunner/common.go renamed to internal/stack/settings.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
// or more contributor license agreements. Licensed under the Elastic License;
33
// you may not use this file except in compliance with the Elastic License.
44

5-
package testrunner
5+
package stack
66

77
import "os"
88

9-
// StackSettings encapsulate the various settings required to connect to the Elastic Stack.
10-
type StackSettings struct {
9+
// Settings encapsulate the various settings required to connect to the Elastic Stack.
10+
type Settings struct {
1111
Elasticsearch struct {
1212
Host string
1313
Username string
@@ -18,20 +18,20 @@ type StackSettings struct {
1818
}
1919
}
2020

21-
// GetStackSettingsFromEnv loads Elastic stack connnection settings from
21+
// CurrentSettings loads Elastic stack connection settings from
2222
// environment variables and returns them.
23-
func GetStackSettingsFromEnv() StackSettings {
24-
s := StackSettings{}
23+
func CurrentSettings() Settings {
24+
s := Settings{}
2525

26-
s.Elasticsearch.Host = os.Getenv("ELASTIC_PACKAGE_ELASTICSEARCH_HOST")
26+
s.Elasticsearch.Host = os.Getenv(ElasticsearchHostEnv)
2727
if s.Elasticsearch.Host == "" {
2828
s.Elasticsearch.Host = "http://localhost:9200"
2929
}
3030

31-
s.Elasticsearch.Username = os.Getenv("ELASTIC_PACKAGE_ELASTICSEARCH_USERNAME")
32-
s.Elasticsearch.Password = os.Getenv("ELASTIC_PACKAGE_ELASTICSEARCH_PASSWORD")
31+
s.Elasticsearch.Username = os.Getenv(ElasticsearchUsernameEnv)
32+
s.Elasticsearch.Password = os.Getenv(ElasticsearchPasswordEnv)
3333

34-
s.Kibana.Host = os.Getenv("ELASTIC_PACKAGE_KIBANA_HOST")
34+
s.Kibana.Host = os.Getenv(KibanaHostEnv)
3535
if s.Kibana.Host == "" {
3636
s.Kibana.Host = "http://localhost:5601"
3737
}

internal/testrunner/runners/asset/runner.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/elastic/elastic-package/internal/kibana/ingestmanager"
1616
"github.com/elastic/elastic-package/internal/logger"
1717
"github.com/elastic/elastic-package/internal/packages"
18+
"github.com/elastic/elastic-package/internal/stack"
1819
"github.com/elastic/elastic-package/internal/testrunner"
1920
)
2021

@@ -30,7 +31,7 @@ const (
3031
type runner struct {
3132
testFolder testrunner.TestFolder
3233
packageRootPath string
33-
stackSettings testrunner.StackSettings
34+
stackSettings stack.Settings
3435
esClient *es.Client
3536

3637
// Execution order of following handlers is defined in runner.tearDown() method.
@@ -62,7 +63,7 @@ func (r runner) IsConfigRequired() bool {
6263
func (r runner) Run(options testrunner.TestOptions) ([]testrunner.TestResult, error) {
6364
r.testFolder = options.TestFolder
6465
r.packageRootPath = options.PackageRootPath
65-
r.stackSettings = testrunner.GetStackSettingsFromEnv()
66+
r.stackSettings = stack.CurrentSettings()
6667
r.esClient = options.ESClient
6768

6869
return r.run()

0 commit comments

Comments
 (0)