mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Fix comment on SplitIndexNameValue
It was incorrect and suggested some behaviour which isn't present. Added test to verify the documented behaviour.
This commit is contained in:
@@ -605,7 +605,7 @@ func IsListIndex(p string) bool {
|
||||
// SplitIndexNameValue splits a lookup part Val index into the field name
|
||||
// and field value to match.
|
||||
// e.g. splits [name=nginx] into (name, nginx)
|
||||
// e.g. splits [=-jar] into ("", jar)
|
||||
// e.g. splits [=-jar] into ("", -jar)
|
||||
func SplitIndexNameValue(p string) (string, string, error) {
|
||||
elem := strings.TrimSuffix(p, "]")
|
||||
elem = strings.TrimPrefix(elem, "[")
|
||||
|
||||
@@ -518,6 +518,11 @@ func TestSplitIndexNameValue(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "a", k)
|
||||
assert.Equal(t, "b=c", v)
|
||||
|
||||
k, v, err = SplitIndexNameValue("=-jar")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "", k)
|
||||
assert.Equal(t, "-jar", v)
|
||||
}
|
||||
|
||||
type filter struct {
|
||||
|
||||
Reference in New Issue
Block a user