Skip to content

Commit

Permalink
Fix hosts renames
Browse files Browse the repository at this point in the history
  • Loading branch information
David Kowalski committed Jan 13, 2022
1 parent e3d6518 commit 742d662
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ metadata:
name: kibana-sample
spec:
config:
xpack.fleet.agents.elasticsearch.hosts: ["https://elasticsearch-quickstart-es-http.default.svc:9200"]
xpack.fleet.agents.elasticsearch.hosts: ["https://elasticsearch-sample-es-http.default.svc:9200"]
xpack.fleet.agents.fleet_server.hosts: ["https://fleet-server-sample-agent-http.default.svc:8220"]
----

Expand Down
33 changes: 17 additions & 16 deletions test/e2e/test/helper/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,29 +392,30 @@ func tweakConfigLiterals(config *commonv1.Config, suffix string, namespace strin
data := config.Data

elasticsearchHostsKey := "xpack.fleet.agents.elasticsearch.hosts"
if val1, ok := data[elasticsearchHostsKey]; ok {
if val2, ok := val1.(string); ok {
val2 = strings.ReplaceAll(
val2,
"elasticsearch-es-http.default",
fmt.Sprintf("elasticsearch-%s-es-http.%s", suffix, namespace),
)
data[elasticsearchHostsKey] = val2
if untypedHosts, ok := data[elasticsearchHostsKey]; ok {
if untypedHostsSlice, ok := untypedHosts.([]interface{}); ok {
for i, untypedHost := range untypedHostsSlice {
if host, ok := untypedHost.(string); ok {
untypedHostsSlice[i] = strings.ReplaceAll(
host,
"elasticsearch-es-http.default",
fmt.Sprintf("elasticsearch-%s-es-http.%s", suffix, namespace),
)
}
}
}
}

fleetServerHostsKey := "xpack.fleet.agents.fleet_server.hosts"
//nolint:nestif
if val1, ok := data[fleetServerHostsKey]; ok {
if val2, ok := val1.([]interface{}); ok {
if len(val2) > 0 {
if val3, ok := val2[0].(string); ok {
val3 = strings.ReplaceAll(
val3,
if untypedHosts, ok := data[fleetServerHostsKey]; ok {
if untypedHostsSlice, ok := untypedHosts.([]interface{}); ok {
for i, untypedHost := range untypedHostsSlice {
if host, ok := untypedHost.(string); ok {
untypedHostsSlice[i] = strings.ReplaceAll(
host,
"fleet-server-agent-http.default",
fmt.Sprintf("fleet-server-%s-agent-http.%s", suffix, namespace),
)
data[fleetServerHostsKey] = []interface{}{val3}
}
}
}
Expand Down

0 comments on commit 742d662

Please sign in to comment.