@@ -13,7 +13,7 @@ import (
1313 "sigs.k8s.io/yaml"
1414)
1515
16- // Config holds an arbitrary tree-like data structure, such as parsed JSON or
16+ // Values holds an arbitrary tree-like data structure, such as parsed JSON or
1717// YAML. It can be used to represent Helm-like values.
1818//
1919// You can use convenient accessors to work with this data structure.
@@ -22,10 +22,10 @@ import (
2222// type of the embedded lists and objects. To avoid any error or an unexpected
2323// behavior use `[]interface{}` for lists and `map[string]interface{}` for
2424// nested objects.
25- type Config map [string ]interface {}
25+ type Values map [string ]interface {}
2626
2727// AsMap returns the underlying map. This maybe be useful for external libraries.
28- func (v Config ) AsMap () map [string ]interface {} {
28+ func (v Values ) AsMap () map [string ]interface {} {
2929 return v
3030}
3131
@@ -34,7 +34,7 @@ func (v Config) AsMap() map[string]interface{} {
3434//
3535// It will return an error, if the key does not exist or can not be traversed,
3636// for example nested keys of a leaf node of the tree.
37- func (v Config ) GetValue (key string ) (interface {}, error ) {
37+ func (v Values ) GetValue (key string ) (interface {}, error ) {
3838 cursor := v
3939 keyElements := []string {}
4040
@@ -74,7 +74,7 @@ func (v Config) GetValue(key string) (interface{}, error) {
7474// or an empty string.
7575//
7676// Use `HasKey` to check if the `key` exist.
77- func (v Config ) GetString (key string , defaultValue ... string ) string {
77+ func (v Values ) GetString (key string , defaultValue ... string ) string {
7878 defaultValueToUse := ""
7979 if len (defaultValue ) > 0 {
8080 defaultValueToUse = defaultValue [0 ]
@@ -102,7 +102,7 @@ func (v Config) GetString(key string, defaultValue ...string) string {
102102// optional `defaultValue` or `false`.
103103//
104104// Use `HasKey` to check if the `key` exist.
105- func (v Config ) GetBool (key string , defaultValue ... bool ) bool {
105+ func (v Values ) GetBool (key string , defaultValue ... bool ) bool {
106106 defaultValueToUse := false
107107 if len (defaultValue ) > 0 {
108108 defaultValueToUse = defaultValue [0 ]
@@ -121,7 +121,7 @@ func (v Config) GetBool(key string, defaultValue ...bool) bool {
121121// and it does not support array indexing. When it returns `true` the getter
122122// methods, e.g. `GetValue`, can successfully retrieve the associated value of
123123// the key.
124- func (v Config ) HasKey (key string ) bool {
124+ func (v Values ) HasKey (key string ) bool {
125125 if _ , err := v .GetValue (key ); err == nil {
126126 return true
127127 }
@@ -136,7 +136,7 @@ func (v Config) HasKey(key string) bool {
136136// the provided value. It will create any intermediate nested object that
137137// doesn't exist. But it will return an error when the key can not be traversed,
138138// for example nested keys of a leaf node of the tree.
139- func (v Config ) SetValue (key string , value interface {}) error {
139+ func (v Values ) SetValue (key string , value interface {}) error {
140140 if key == "" {
141141 return errors .Errorf ("can not set the root element" )
142142 }
@@ -178,7 +178,7 @@ func (v Config) SetValue(key string, value interface{}) error {
178178// values as valid values.
179179//
180180// It retruns an error if the underlying merge utility encounters an error.
181- func (v Config ) Merge (newValues Config ) error {
181+ func (v Values ) Merge (newValues Values ) error {
182182 if err := mergo .Merge (& v , newValues , mergo .WithOverride ); err != nil {
183183 return errors .Wrapf (err , "can not merge new values" )
184184 }
@@ -194,15 +194,15 @@ func (v Config) Merge(newValues Config) error {
194194//
195195// It uses Helm SDK coalesce function and does not return an error when fails
196196// to merge specific entries. Therefore it may lead to an incorrect output.
197- func (v Config ) Coalesce (newValues Config ) {
197+ func (v Values ) Coalesce (newValues Values ) {
198198 chartutil .CoalesceTables (v , newValues )
199199}
200200
201201// AddHelmValue sets the specified value using Helm style key and value format.
202202// This is similar to `--set key=value` command argument of Helm. It does not
203203// support multiple keys and values. It returns an error if it can not parse
204204// the key or assign the value.
205- func (v Config ) AddHelmValue (key , value string ) error {
205+ func (v Values ) AddHelmValue (key , value string ) error {
206206 if err := strvals .ParseInto (fmt .Sprintf ("%s=%s" , key , value ), v ); err != nil {
207207 return errors .Wrapf (err , "failed to set value: %s=%s" , key , value )
208208 }
@@ -214,16 +214,16 @@ func (v Config) AddHelmValue(key, value string) error {
214214//
215215// It will return an error if it fails to parse the YAML content or encounters
216216// an error while merging. For more details see `Merge` function.
217- func (v Config ) AddFromYAML (content string ) error {
217+ func (v Values ) AddFromYAML (content string ) error {
218218 return v .AddFromYAMLBuffer ([]byte (content ))
219219}
220220
221221// AddFromYAMLBuffer merges the values from the provided YAML.
222222//
223223// It will return an error if it fails to parse the YAML content or encounters
224224// an error while merging. For more details see `Merge` function.
225- func (v Config ) AddFromYAMLBuffer (content []byte ) error {
226- newValues := Config {}
225+ func (v Values ) AddFromYAMLBuffer (content []byte ) error {
226+ newValues := Values {}
227227
228228 if err := yaml .Unmarshal (content , & newValues ); err != nil {
229229 return errors .Wrapf (err , "failed to parse yaml content" )
@@ -236,7 +236,7 @@ func (v Config) AddFromYAMLBuffer(content []byte) error {
236236//
237237// It will return an error if it fails to read or parse the YAML file or
238238// encounters an error while merging. For more details see `Merge` function.
239- func (v Config ) AddFromYAMLFile (filePath string ) error {
239+ func (v Values ) AddFromYAMLFile (filePath string ) error {
240240 fileContent , err := os .ReadFile (filePath )
241241 if err != nil {
242242 return errors .Wrapf (err , "failed to read file: %s" , filePath )
0 commit comments