-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for using values from yaml files #1828
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e315a18
Add support for using values from yaml files
viveklak a13b537
Update test to use a values yaml file
viveklak 8dca024
Changelog
viveklak 8329f01
Fix test
viveklak 68e93d8
More test fixes
viveklak fbeb954
Fix description for valueYamlFiles
viveklak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ import ( | |
"log" | ||
"net/url" | ||
"os" | ||
"reflect" | ||
"strings" | ||
"time" | ||
|
||
|
@@ -113,8 +114,6 @@ type Release struct { | |
SkipCrds bool `json:"skipCrds,omitempty"` | ||
// Time in seconds to wait for any individual kubernetes operation. | ||
Timeout int `json:"timeout,omitempty"` | ||
// ValueYamlFiles List of assets (raw yaml files) to pass to helm. | ||
//ValueYamlFiles []*resource.Asset `json:"valueYamlFiles,omitempty"` | ||
// Verify the package before installing it. | ||
Verify bool `json:"verify,omitempty"` | ||
// Specify the exact chart version to install. If this is not specified, the latest version is installed. | ||
|
@@ -250,11 +249,37 @@ func (r *helmReleaseProvider) getActionConfig(namespace string) (*action.Configu | |
|
||
func decodeRelease(pm resource.PropertyMap) (*Release, error) { | ||
var release Release | ||
values := map[string]interface{}{} | ||
stripped := pm.MapRepl(nil, mapReplStripSecrets) | ||
logger.V(9).Infof("Decoding release: %#v", stripped) | ||
|
||
if pm.HasValue("valueYamlFiles") { | ||
v := stripped["valueYamlFiles"] | ||
switch reflect.TypeOf(v).Kind() { | ||
case reflect.Slice, reflect.Array: | ||
s := reflect.ValueOf(v) | ||
for i := 0; i < s.Len(); i++ { | ||
val := s.Index(i).Interface() | ||
switch t := val.(type) { | ||
case *resource.Asset: | ||
b, err := t.Bytes() | ||
if err != nil { | ||
return nil, err | ||
} | ||
if err = yaml.Unmarshal(b, &values); err != nil { | ||
return nil, err | ||
} | ||
default: | ||
return nil, fmt.Errorf("unsupported type for 'valueYamlFiles' arg: %T", v) | ||
} | ||
} | ||
} | ||
} | ||
|
||
if err := mapstructure.Decode(stripped, &release); err != nil { | ||
return nil, fmt.Errorf("decoding failure: %w", err) | ||
} | ||
release.Values = mergeMaps(release.Values, values) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The precedence - if it's not clear - will prioritize the values in the |
||
return &release, nil | ||
} | ||
|
||
|
@@ -1067,7 +1092,7 @@ func setReleaseAttributes(release *Release, r *release.Release, isPreview bool) | |
release.Chart = r.Chart.Metadata.Name | ||
} | ||
logger.V(9).Infof("Setting release values: %+v", r.Config) | ||
release.Values = r.Config | ||
release.Values = mergeMaps(release.Values, r.Config) | ||
release.Version = r.Chart.Metadata.Version | ||
|
||
_, resources, err := convertYAMLManifestToJSON(r.Manifest) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
metrics: | ||
enabled: true | ||
service: | ||
annotations: | ||
"prometheus.io/port": "9127" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to also support Archives? I just noticed that the SDK type supports both Assets and Archives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to keep this in-line with the helm CLI. The CLI takes yaml files and not archives. We can reconsider if we get requests from users. I can't think of an obvious use case where archives would be preferred.