Skip to content
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

Conform to Helm's YAML parsing semantics #289

Merged
merged 1 commit into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pkg/gen/nodejs-templates/helm.ts.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,15 @@ export namespace v2 {
transformations: ((o: any) => void)[] | undefined,
dependsOn: pulumi.Resource[]
): pulumi.Output<{ [key: string]: pulumi.CustomResource }> {
const objs = jsyaml
.safeLoadAll(yamlStream)
// NOTE: We must manually split the YAML stream because of js-yaml#456. Perusing the
// code and the spec, it looks like a YAML stream is delimited by `^---`, though it is
// difficult to know for sure.
//
// NOTE: We use `{json: true}` here so that we conform to Helm's YAML parsing
// semantics. Specifically, a duplicate key overrides its predecessory, rather than
// throwing an exception.
const objs = yamlStream.split(/^---/m)
.map(yaml => jsyaml.safeLoad(yaml, {json: true}))
.filter(a => a != null && "kind" in a)
.sort(helmSort);
return k8s.yaml.parse(
Expand Down
11 changes: 9 additions & 2 deletions sdk/nodejs/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,15 @@ export namespace v2 {
transformations: ((o: any) => void)[] | undefined,
dependsOn: pulumi.Resource[]
): pulumi.Output<{ [key: string]: pulumi.CustomResource }> {
const objs = jsyaml
.safeLoadAll(yamlStream)
// NOTE: We must manually split the YAML stream because of js-yaml#456. Perusing the
// code and the spec, it looks like a YAML stream is delimited by `^---`, though it is
// difficult to know for sure.
//
// NOTE: We use `{json: true}` here so that we conform to Helm's YAML parsing
// semantics. Specifically, a duplicate key overrides its predecessory, rather than
// throwing an exception.
const objs = yamlStream.split(/^---/m)
.map(yaml => jsyaml.safeLoad(yaml, {json: true}))
.filter(a => a != null && "kind" in a)
.sort(helmSort);
return k8s.yaml.parse(
Expand Down