Skip to content

Commit 7724199

Browse files
authored
Update default stack to 9.1 (#2804)
1 parent 7850899 commit 7724199

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

‎internal/install/stack_version.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ package install
66

77
const (
88
// DefaultStackVersion is the default version of the stack
9-
DefaultStackVersion = "9.0.4"
9+
DefaultStackVersion = "9.1.0"
1010
)

‎internal/testrunner/runners/policy/policy.go‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"os"
1313
"path/filepath"
1414
"regexp"
15+
"slices"
1516
"strings"
1617

1718
"github.com/pmezard/go-difflib/difflib"
@@ -98,6 +99,7 @@ type policyEntryFilter struct {
9899
elementsEntries []policyEntryFilter
99100
memberReplace *policyEntryReplace
100101
onlyIfEmpty bool
102+
ignoreValues []any
101103
}
102104

103105
type policyEntryReplace struct {
@@ -151,7 +153,17 @@ var policyEntryFilters = []policyEntryFilter{
151153
}},
152154

153155
// Namespaces may not be present in older versions of the stack.
154-
{name: "namespaces", onlyIfEmpty: true},
156+
{name: "namespaces", onlyIfEmpty: true, ignoreValues: []any{"default"}},
157+
158+
// Values set by Fleet in input packages starting on 9.1.0.
159+
{name: "inputs", elementsEntries: []policyEntryFilter{
160+
{name: "streams", elementsEntries: []policyEntryFilter{
161+
{name: "data_stream.type"},
162+
{name: "data_stream.elasticsearch.dynamic_dataset"},
163+
{name: "data_stream.elasticsearch.dynamic_namespace"},
164+
{name: "data_stream.elasticsearch", onlyIfEmpty: true},
165+
}},
166+
}},
155167
}
156168

157169
// cleanPolicy prepares a policy YAML as returned by the download API to be compared with other
@@ -213,7 +225,7 @@ func cleanPolicyMap(policyMap common.MapStr, entries []policyEntryFilter) (commo
213225
}
214226
}
215227
default:
216-
if entry.onlyIfEmpty && !isEmpty(v) {
228+
if entry.onlyIfEmpty && !isEmpty(v, entry.ignoreValues) {
217229
continue
218230
}
219231
err := policyMap.Delete(entry.name)
@@ -229,15 +241,23 @@ func cleanPolicyMap(policyMap common.MapStr, entries []policyEntryFilter) (commo
229241
return policyMap, nil
230242
}
231243

232-
func isEmpty(v any) bool {
244+
func isEmpty(v any, ignoreValues []any) bool {
233245
switch v := v.(type) {
234246
case nil:
235247
return true
236248
case []any:
237-
return len(v) == 0
249+
return len(filterIgnored(v, ignoreValues)) == 0
238250
case map[string]any:
239251
return len(v) == 0
252+
case common.MapStr:
253+
return len(v) == 0
240254
}
241255

242256
return false
243257
}
258+
259+
func filterIgnored(v []any, ignoredValues []any) []any {
260+
return slices.DeleteFunc(v, func(e any) bool {
261+
return slices.Contains(ignoredValues, e)
262+
})
263+
}

‎internal/testrunner/runners/policy/policy_test.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ id: "2e19c1c4-185b-11ef-a7fc-43855f39047f"
6464
`,
6565
found: `
6666
namespaces: []
67+
`,
68+
equal: true,
69+
},
70+
{
71+
title: "clean namespaces if default",
72+
expected: `
73+
`,
74+
found: `
75+
namespaces: [default]
6776
`,
6877
equal: true,
6978
},

0 commit comments

Comments
 (0)