-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The fields of the Kubernetes core resource types are tagged with Go's `"json:"` serialization metadata. They expect things like JavaScript's `Date` to be serialized as string. Fixes #501.
- Loading branch information
Showing
3 changed files
with
26 additions
and
8 deletions.
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 |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
import * as pulumi from "@pulumi/pulumi"; | ||
import * as fs from "fs"; | ||
import * as glob from "glob"; | ||
import * as jsyaml from "js-yaml"; | ||
import fetch from "node-fetch"; | ||
import * as k8s from "../index"; | ||
import * as outputApi from "../types/output"; | ||
|
@@ -66,6 +65,16 @@ import * as outputApi from "../types/output"; | |
resourcePrefix?: string; | ||
} | ||
|
||
/** @ignore */ export function yamlLoadAll(text: string): any[] { | ||
// NOTE[pulumi-kubernetes#501]: Use `loadAll` with `JSON_SCHEMA` here instead of | ||
// `safeLoadAll` because the latter is incompatible with `JSON_SCHEMA`. It is | ||
// important to use `JSON_SCHEMA` here because the fields of the Kubernetes core | ||
// API types are all tagged with `json:`, and they don't deal very well with things | ||
// like dates. | ||
const jsyaml = require("js-yaml"); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
hausdorff
Author
Contributor
|
||
return jsyaml.loadAll(text, undefined, {schema: jsyaml.JSON_SCHEMA}); | ||
} | ||
/** @ignore */ export function parse( | ||
config: ConfigGroupOpts, opts?: pulumi.CustomResourceOptions | ||
): pulumi.Output<{[key: string]: pulumi.CustomResource}> { | ||
|
@@ -112,9 +121,8 @@ import * as outputApi from "../types/output"; | |
} | ||
for (const text of yamlTexts) { | ||
const objs = jsyaml.safeLoadAll(text); | ||
const docResources = parseYamlDocument({ | ||
objs: objs, | ||
objs: yamlLoadAll(text), | ||
transformations: config.transformations, | ||
resourcePrefix: config.resourcePrefix | ||
}, | ||
|
@@ -258,7 +266,7 @@ import * as outputApi from "../types/output"; | |
this.resources = pulumi.output(text.then(t => { | ||
try { | ||
return parseYamlDocument({ | ||
objs: jsyaml.safeLoadAll(t), | ||
objs: yamlLoadAll(t), | ||
transformations: config && config.transformations || [], | ||
resourcePrefix: config && config.resourcePrefix || undefined | ||
}, {parent: this}) | ||
|
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 |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
import * as pulumi from "@pulumi/pulumi"; | ||
import * as fs from "fs"; | ||
import * as glob from "glob"; | ||
import * as jsyaml from "js-yaml"; | ||
import fetch from "node-fetch"; | ||
import * as k8s from "../index"; | ||
import * as outputApi from "../types/output"; | ||
|
@@ -66,6 +65,16 @@ import * as outputApi from "../types/output"; | |
resourcePrefix?: string; | ||
} | ||
|
||
/** @ignore */ export function yamlLoadAll(text: string): any[] { | ||
This comment has been minimized.
Sorry, something went wrong.
lukehoban
Member
|
||
// NOTE[pulumi-kubernetes#501]: Use `loadAll` with `JSON_SCHEMA` here instead of | ||
// `safeLoadAll` because the latter is incompatible with `JSON_SCHEMA`. It is | ||
// important to use `JSON_SCHEMA` here because the fields of the Kubernetes core | ||
// API types are all tagged with `json:`, and they don't deal very well with things | ||
// like dates. | ||
const jsyaml = require("js-yaml"); | ||
return jsyaml.loadAll(text, undefined, {schema: jsyaml.JSON_SCHEMA}); | ||
} | ||
|
||
/** @ignore */ export function parse( | ||
config: ConfigGroupOpts, opts?: pulumi.CustomResourceOptions | ||
): pulumi.Output<{[key: string]: pulumi.CustomResource}> { | ||
|
@@ -112,9 +121,8 @@ import * as outputApi from "../types/output"; | |
} | ||
|
||
for (const text of yamlTexts) { | ||
const objs = jsyaml.safeLoadAll(text); | ||
const docResources = parseYamlDocument({ | ||
objs: objs, | ||
objs: yamlLoadAll(text), | ||
transformations: config.transformations, | ||
resourcePrefix: config.resourcePrefix | ||
}, | ||
|
@@ -2234,7 +2242,7 @@ import * as outputApi from "../types/output"; | |
this.resources = pulumi.output(text.then(t => { | ||
try { | ||
return parseYamlDocument({ | ||
objs: jsyaml.safeLoadAll(t), | ||
objs: yamlLoadAll(t), | ||
transformations: config && config.transformations || [], | ||
resourcePrefix: config && config.resourcePrefix || undefined | ||
}, {parent: this}) | ||
|
Why was this moved to be a local require instead of an
import
?