Skip to content

Commit 8c9cbca

Browse files
authored
Merge pull request #10192 from olemarkus/updates-helm
Upgrade helm to 2.17 and use the helm.sh reference
2 parents f12c7ff + d24d9e0 commit 8c9cbca

File tree

9 files changed

+108
-32
lines changed

9 files changed

+108
-32
lines changed

cmd/kops/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ go_library(
104104
"//vendor/github.com/spf13/cobra/doc:go_default_library",
105105
"//vendor/github.com/spf13/viper:go_default_library",
106106
"//vendor/golang.org/x/crypto/ssh:go_default_library",
107+
"//vendor/helm.sh/helm/pkg/strvals:go_default_library",
107108
"//vendor/k8s.io/api/core/v1:go_default_library",
108109
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
109110
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
@@ -115,7 +116,6 @@ go_library(
115116
"//vendor/k8s.io/client-go/plugin/pkg/client/auth:go_default_library",
116117
"//vendor/k8s.io/client-go/tools/clientcmd:go_default_library",
117118
"//vendor/k8s.io/client-go/util/homedir:go_default_library",
118-
"//vendor/k8s.io/helm/pkg/strvals:go_default_library",
119119
"//vendor/k8s.io/klog/v2:go_default_library",
120120
"//vendor/k8s.io/kubectl/pkg/cmd/util:go_default_library",
121121
"//vendor/k8s.io/kubectl/pkg/cmd/util/editor:go_default_library",

cmd/kops/toolbox_template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727

2828
"github.com/ghodss/yaml"
2929
"github.com/spf13/cobra"
30-
"k8s.io/helm/pkg/strvals"
30+
"helm.sh/helm/pkg/strvals"
3131
"k8s.io/kubectl/pkg/util/i18n"
3232
"k8s.io/kubectl/pkg/util/templates"
3333

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ require (
103103
gopkg.in/gcfg.v1 v1.2.3
104104
gopkg.in/inf.v0 v0.9.1
105105
gopkg.in/yaml.v2 v2.3.0
106+
helm.sh/helm v2.17.0+incompatible
106107
honnef.co/go/tools v0.0.1-2020.1.4
107108
k8s.io/api v0.19.0
108109
k8s.io/apimachinery v0.19.0
@@ -111,7 +112,6 @@ require (
111112
k8s.io/cloud-provider-openstack v1.18.0
112113
k8s.io/component-base v0.19.0
113114
k8s.io/gengo v0.0.0-20200710205751-c0d492a0f3ca
114-
k8s.io/helm v2.9.0+incompatible
115115
k8s.io/klog/v2 v2.3.0
116116
k8s.io/kubectl v0.0.0
117117
k8s.io/legacy-cloud-providers v0.0.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,8 @@ gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81
12661266
gotest.tools/gotestsum v0.3.5/go.mod h1:Mnf3e5FUzXbkCfynWBGOwLssY7gTQgCHObK9tMpAriY=
12671267
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
12681268
grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o=
1269+
helm.sh/helm v2.17.0+incompatible h1:cSe3FaQOpRWLDXvTObQNj0P7WI98IG5yloU6tQVls2k=
1270+
helm.sh/helm v2.17.0+incompatible/go.mod h1:0Xbc6ErzwWH9qC55X1+hE3ZwhM3atbhCm/NbFZw5i+4=
12691271
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
12701272
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
12711273
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
@@ -1304,8 +1306,6 @@ k8s.io/gengo v0.0.0-20200428234225-8167cfdcfc14/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8
13041306
k8s.io/gengo v0.0.0-20200710205751-c0d492a0f3ca h1:/o8XeHsWWmi4lTKp3uxWAZY7Eq/v1HelCDmrKZM4SVQ=
13051307
k8s.io/gengo v0.0.0-20200710205751-c0d492a0f3ca/go.mod h1:aG2eeomYfcUw8sE3fa7YdkjgnGtyY56TjZlaJJ0ZoWo=
13061308
k8s.io/heapster v1.2.0-beta.1/go.mod h1:h1uhptVXMwC8xtZBYsPXKVi8fpdlYkTs6k949KozGrM=
1307-
k8s.io/helm v2.9.0+incompatible h1:3EFDJoqKSUe1BpC9qP+YaHi2Oua9hFT+C24/LhX2G1g=
1308-
k8s.io/helm v2.9.0+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI=
13091309
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
13101310
k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
13111311
k8s.io/klog v0.3.1/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=

vendor/k8s.io/helm/LICENSE renamed to vendor/helm.sh/helm/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
same "printed page" as the copyright notice for easier
188188
identification within third-party archives.
189189

190-
Copyright 2016 The Kubernetes Authors All Rights Reserved
190+
Copyright The Helm Authors.
191191

192192
Licensed under the Apache License, Version 2.0 (the "License");
193193
you may not use this file except in compliance with the License.

vendor/k8s.io/helm/pkg/strvals/BUILD.bazel renamed to vendor/helm.sh/helm/pkg/strvals/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ go_library(
66
"doc.go",
77
"parser.go",
88
],
9-
importmap = "k8s.io/kops/vendor/k8s.io/helm/pkg/strvals",
10-
importpath = "k8s.io/helm/pkg/strvals",
9+
importmap = "k8s.io/kops/vendor/helm.sh/helm/pkg/strvals",
10+
importpath = "helm.sh/helm/pkg/strvals",
1111
visibility = ["//visibility:public"],
1212
deps = ["//vendor/github.com/ghodss/yaml:go_default_library"],
1313
)

vendor/k8s.io/helm/pkg/strvals/doc.go renamed to vendor/helm.sh/helm/pkg/strvals/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Kubernetes Authors All rights reserved.
2+
Copyright The Helm Authors.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at

vendor/k8s.io/helm/pkg/strvals/parser.go renamed to vendor/helm.sh/helm/pkg/strvals/parser.go

Lines changed: 96 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Kubernetes Authors All rights reserved.
2+
Copyright The Helm Authors.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at
@@ -36,7 +36,7 @@ func ToYAML(s string) (string, error) {
3636
return "", err
3737
}
3838
d, err := yaml.Marshal(m)
39-
return strings.TrimSuffix(string(d), "\n"), err
39+
return string(d), err
4040
}
4141

4242
// Parse parses a set line.
@@ -50,6 +50,20 @@ func Parse(s string) (map[string]interface{}, error) {
5050
return vals, err
5151
}
5252

53+
// ParseFile parses a set line, but its final value is loaded from the file at the path specified by the original value.
54+
//
55+
// A set line is of the form name1=path1,name2=path2
56+
//
57+
// When the files at path1 and path2 contained "val1" and "val2" respectively, the set line is consumed as
58+
// name1=val1,name2=val2
59+
func ParseFile(s string, runesToVal runesToVal) (map[string]interface{}, error) {
60+
vals := map[string]interface{}{}
61+
scanner := bytes.NewBufferString(s)
62+
t := newFileParser(scanner, vals, runesToVal)
63+
err := t.parse()
64+
return vals, err
65+
}
66+
5367
// ParseString parses a set line and forces a string value.
5468
//
5569
// A set line is of the form name1=value1,name2=value2
@@ -71,7 +85,16 @@ func ParseInto(s string, dest map[string]interface{}) error {
7185
return t.parse()
7286
}
7387

74-
// ParseIntoString parses a strvals line nad merges the result into dest.
88+
// ParseIntoFile parses a filevals line and merges the result into dest.
89+
//
90+
// This method always returns a string as the value.
91+
func ParseIntoFile(s string, dest map[string]interface{}, runesToVal runesToVal) error {
92+
scanner := bytes.NewBufferString(s)
93+
t := newFileParser(scanner, dest, runesToVal)
94+
return t.parse()
95+
}
96+
97+
// ParseIntoString parses a strvals line and merges the result into dest.
7598
//
7699
// This method always returns a string as the value.
77100
func ParseIntoString(s string, dest map[string]interface{}) error {
@@ -82,14 +105,27 @@ func ParseIntoString(s string, dest map[string]interface{}) error {
82105

83106
// parser is a simple parser that takes a strvals line and parses it into a
84107
// map representation.
108+
//
109+
// where sc is the source of the original data being parsed
110+
// where data is the final parsed data from the parses with correct types
111+
// where st is a boolean to figure out if we're forcing it to parse values as string
85112
type parser struct {
86-
sc *bytes.Buffer
87-
data map[string]interface{}
88-
st bool
113+
sc *bytes.Buffer
114+
data map[string]interface{}
115+
runesToVal runesToVal
89116
}
90117

118+
type runesToVal func([]rune) (interface{}, error)
119+
91120
func newParser(sc *bytes.Buffer, data map[string]interface{}, stringBool bool) *parser {
92-
return &parser{sc: sc, data: data, st: stringBool}
121+
rs2v := func(rs []rune) (interface{}, error) {
122+
return typedVal(rs, stringBool), nil
123+
}
124+
return &parser{sc: sc, data: data, runesToVal: rs2v}
125+
}
126+
127+
func newFileParser(sc *bytes.Buffer, data map[string]interface{}, runesToVal runesToVal) *parser {
128+
return &parser{sc: sc, data: data, runesToVal: runesToVal}
93129
}
94130

95131
func (t *parser) parse() error {
@@ -153,8 +189,12 @@ func (t *parser) key(data map[string]interface{}) error {
153189
set(data, string(k), "")
154190
return e
155191
case ErrNotList:
156-
v, e := t.val()
157-
set(data, string(k), typedVal(v, t.st))
192+
rs, e := t.val()
193+
if e != nil && e != io.EOF {
194+
return e
195+
}
196+
v, e := t.runesToVal(rs)
197+
set(data, string(k), v)
158198
return e
159199
default:
160200
return e
@@ -226,25 +266,43 @@ func (t *parser) listItem(list []interface{}, i int) ([]interface{}, error) {
226266
case io.EOF:
227267
return setIndex(list, i, ""), err
228268
case ErrNotList:
229-
v, e := t.val()
230-
return setIndex(list, i, typedVal(v, t.st)), e
269+
rs, e := t.val()
270+
if e != nil && e != io.EOF {
271+
return list, e
272+
}
273+
v, e := t.runesToVal(rs)
274+
return setIndex(list, i, v), e
231275
default:
232276
return list, e
233277
}
234278
case last == '[':
235279
// now we have a nested list. Read the index and handle.
236-
i, err := t.keyIndex()
280+
nextI, err := t.keyIndex()
237281
if err != nil {
238282
return list, fmt.Errorf("error parsing index: %s", err)
239283
}
284+
var crtList []interface{}
285+
if len(list) > i {
286+
// If nested list already exists, take the value of list to next cycle.
287+
existed := list[i]
288+
if existed != nil {
289+
crtList = list[i].([]interface{})
290+
}
291+
}
240292
// Now we need to get the value after the ].
241-
list2, err := t.listItem(list, i)
293+
list2, err := t.listItem(crtList, nextI)
242294
return setIndex(list, i, list2), err
243295
case last == '.':
244296
// We have a nested object. Send to t.key
245297
inner := map[string]interface{}{}
246298
if len(list) > i {
247-
inner = list[i].(map[string]interface{})
299+
var ok bool
300+
inner, ok = list[i].(map[string]interface{})
301+
if !ok {
302+
// We have indices out of order. Initialize empty value.
303+
list[i] = map[string]interface{}{}
304+
inner = list[i].(map[string]interface{})
305+
}
248306
}
249307

250308
// Recurse
@@ -275,7 +333,7 @@ func (t *parser) valList() ([]interface{}, error) {
275333
list := []interface{}{}
276334
stop := runeSet([]rune{',', '}'})
277335
for {
278-
switch v, last, err := runesUntil(t.sc, stop); {
336+
switch rs, last, err := runesUntil(t.sc, stop); {
279337
case err != nil:
280338
if err == io.EOF {
281339
err = errors.New("list must terminate with '}'")
@@ -286,10 +344,15 @@ func (t *parser) valList() ([]interface{}, error) {
286344
if r, _, e := t.sc.ReadRune(); e == nil && r != ',' {
287345
t.sc.UnreadRune()
288346
}
289-
list = append(list, typedVal(v, t.st))
290-
return list, nil
347+
v, e := t.runesToVal(rs)
348+
list = append(list, v)
349+
return list, e
291350
case last == ',':
292-
list = append(list, typedVal(v, t.st))
351+
v, e := t.runesToVal(rs)
352+
if e != nil {
353+
return list, e
354+
}
355+
list = append(list, v)
293356
}
294357
}
295358
}
@@ -321,6 +384,11 @@ func inMap(k rune, m map[rune]bool) bool {
321384

322385
func typedVal(v []rune, st bool) interface{} {
323386
val := string(v)
387+
388+
if st {
389+
return val
390+
}
391+
324392
if strings.EqualFold(val, "true") {
325393
return true
326394
}
@@ -329,8 +397,16 @@ func typedVal(v []rune, st bool) interface{} {
329397
return false
330398
}
331399

332-
// If this value does not start with zero, and not returnString, try parsing it to an int
333-
if !st && len(val) != 0 && val[0] != '0' {
400+
if strings.EqualFold(val, "null") {
401+
return nil
402+
}
403+
404+
if strings.EqualFold(val, "0") {
405+
return int64(0)
406+
}
407+
408+
// If this value does not start with zero, try parsing it to an int
409+
if len(val) != 0 && val[0] != '0' {
334410
if iv, err := strconv.ParseInt(val, 10, 64); err == nil {
335411
return iv
336412
}

vendor/modules.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,9 @@ gopkg.in/warnings.v0
816816
gopkg.in/yaml.v2
817817
# gopkg.in/yaml.v3 v3.0.0-20190905181640-827449938966
818818
gopkg.in/yaml.v3
819+
# helm.sh/helm v2.17.0+incompatible
820+
## explicit
821+
helm.sh/helm/pkg/strvals
819822
# honnef.co/go/tools v0.0.1-2020.1.4
820823
## explicit
821824
honnef.co/go/tools/arg
@@ -1226,9 +1229,6 @@ k8s.io/gengo/generator
12261229
k8s.io/gengo/namer
12271230
k8s.io/gengo/parser
12281231
k8s.io/gengo/types
1229-
# k8s.io/helm v2.9.0+incompatible
1230-
## explicit
1231-
k8s.io/helm/pkg/strvals
12321232
# k8s.io/klog v1.0.0
12331233
k8s.io/klog
12341234
# k8s.io/klog/v2 v2.3.0

0 commit comments

Comments
 (0)