mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Improve robutness of helper code
As per request, changed usage of pointer to int into plain int. Use -1 value where nil use to be used.
This commit is contained in:
@@ -31,7 +31,11 @@ import (
|
||||
// field of the first item in the foo list
|
||||
type PathSection struct {
|
||||
fields []string
|
||||
idx *int
|
||||
idx int
|
||||
}
|
||||
|
||||
func newPathSection() PathSection {
|
||||
return PathSection{idx: -1}
|
||||
}
|
||||
|
||||
func appendNonEmpty(section *PathSection, field string) {
|
||||
@@ -41,7 +45,7 @@ func appendNonEmpty(section *PathSection, field string) {
|
||||
}
|
||||
|
||||
func parseFields(path string) ([]PathSection, error) {
|
||||
section := PathSection{}
|
||||
section := newPathSection()
|
||||
sectionset := []PathSection{}
|
||||
if !strings.Contains(path, "[") {
|
||||
section.fields = strings.Split(path, ".")
|
||||
@@ -75,9 +79,9 @@ func parseFields(path string) ([]PathSection, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid index %s", path)
|
||||
}
|
||||
section.idx = &tmpIdx
|
||||
section.idx = tmpIdx
|
||||
sectionset = append(sectionset, section)
|
||||
section = PathSection{}
|
||||
section = newPathSection()
|
||||
|
||||
start = i + 1
|
||||
insideParentheses = false
|
||||
|
||||
Reference in New Issue
Block a user