Skip to content

Commit

Permalink
Node
Browse files Browse the repository at this point in the history
  • Loading branch information
lblackstone committed Jun 10, 2021
1 parent 389b3d9 commit e662173
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 28 deletions.
12 changes: 3 additions & 9 deletions provider/pkg/gen/nodejs-templates/helm/v3/helm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2020, Pulumi Corporation.
// Copyright 2016-2021, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -220,14 +220,8 @@ export class Chart extends yaml.CollectionComponentResource {
const jsonOpts = JSON.stringify(blob)

const transformations: ((o: any, opts: pulumi.CustomResourceOptions) => void)[] = config.transformations ?? [];
if (config.skipAwait) {
transformations.push((o: any, opts: pulumi.ComponentResourceOptions) => {
if (o.metadata.annotations === undefined) {
o.metadata.annotations = {"pulumi.com/skipAwait": "true"};
} else {
o.metadata.annotations["pulumi.com/skipAwait"] = "true";
}
});
if (config?.skipAwait) {
transformations.push(yaml.skipAwait);
}

// Rather than using the default provider for the following invoke call, use the version specified
Expand Down
40 changes: 35 additions & 5 deletions provider/pkg/gen/nodejs-templates/yaml/yaml.tmpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2020, Pulumi Corporation.
// Copyright 2016-2021, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -283,11 +283,16 @@ export class ConfigFile extends CollectionComponentResource {
text = Promise.resolve(fs.readFileSync(fileId).toString());
}

const transformations = config?.transformations ?? [];
if (config?.skipAwait) {
transformations.push(skipAwait);
}

this.resources = pulumi.output(text.then(t => {
try {
return parseYamlDocument({
objs: yamlLoadAll(t),
transformations: config && config.transformations || [],
transformations,
resourcePrefix: config && config.resourcePrefix || undefined
}, {parent: this})
} catch (e) {
Expand Down Expand Up @@ -318,6 +323,12 @@ export interface ConfigGroupOpts {
* Example: A resource created with resourcePrefix="foo" would produce a resource named "foo-resourceName".
*/
resourcePrefix?: string;

/**
* Skip await logic for all resources in this YAML. Resources will be marked ready as soon as they are created.
* Warning: This option should not be used if you have resources depending on Outputs from the YAML.
*/
skipAwait?: boolean;
}

/**
Expand All @@ -335,6 +346,12 @@ export interface ConfigFileOpts {
* Example: A resource created with resourcePrefix="foo" would produce a resource named "foo-resourceName".
*/
resourcePrefix?: string;

/**
* Skip await logic for all resources in this YAML. Resources will be marked ready as soon as they are created.
* Warning: This option should not be used if you have resources depending on Outputs from the YAML.
*/
skipAwait?: boolean;
}

/**
Expand Down Expand Up @@ -363,11 +380,24 @@ export interface ConfigOpts {
.then((p => p.result));
}

/** @ignore */ export function skipAwait(o: any, opts: pulumi.ComponentResourceOptions) {
if (o.metadata.annotations === undefined) {
o.metadata.annotations = {"pulumi.com/skipAwait": "true"};
} else {
o.metadata.annotations["pulumi.com/skipAwait"] = "true";
}
}

/** @ignore */ export function parse(
config: ConfigGroupOpts, opts?: pulumi.CustomResourceOptions
): pulumi.Output<{[key: string]: pulumi.CustomResource}> {
let resources = pulumi.output<{[key: string]: pulumi.CustomResource}>({});

const transformations = config.transformations ?? [];
if (config.skipAwait) {
transformations.push(skipAwait);
}

if (config.files !== undefined) {
let files: string[] = [];
if (typeof config.files === 'string') {
Expand All @@ -391,7 +421,7 @@ export interface ConfigOpts {
file,
{
file: file,
transformations: config.transformations,
transformations,
resourcePrefix: config.resourcePrefix
},
opts
Expand All @@ -411,7 +441,7 @@ export interface ConfigOpts {
for (const text of yamlTexts) {
const docResources = parseYamlDocument({
objs: yamlLoadAll(text),
transformations: config.transformations,
transformations,
resourcePrefix: config.resourcePrefix
},
opts);
Expand All @@ -423,7 +453,7 @@ export interface ConfigOpts {
const objs: Promise<any[]> = Array.isArray(config.objs) ? Promise.resolve(config.objs) : Promise.resolve([config.objs]);
const docResources = parseYamlDocument({
objs,
transformations: config.transformations,
transformations,
resourcePrefix: config.resourcePrefix
}, opts);
resources = pulumi.all([resources, docResources]).apply(([rs, drs]) => ({...rs, ...drs}));
Expand Down
12 changes: 3 additions & 9 deletions sdk/nodejs/helm/v3/helm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2020, Pulumi Corporation.
// Copyright 2016-2021, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -220,14 +220,8 @@ export class Chart extends yaml.CollectionComponentResource {
const jsonOpts = JSON.stringify(blob)

const transformations: ((o: any, opts: pulumi.CustomResourceOptions) => void)[] = config.transformations ?? [];
if (config.skipAwait) {
transformations.push((o: any, opts: pulumi.ComponentResourceOptions) => {
if (o.metadata.annotations === undefined) {
o.metadata.annotations = {"pulumi.com/skipAwait": "true"};
} else {
o.metadata.annotations["pulumi.com/skipAwait"] = "true";
}
});
if (config?.skipAwait) {
transformations.push(yaml.skipAwait);
}

// Rather than using the default provider for the following invoke call, use the version specified
Expand Down
40 changes: 35 additions & 5 deletions sdk/nodejs/yaml/yaml.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2020, Pulumi Corporation.
// Copyright 2016-2021, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -2741,11 +2741,16 @@ export class ConfigFile extends CollectionComponentResource {
text = Promise.resolve(fs.readFileSync(fileId).toString());
}

const transformations = config?.transformations ?? [];
if (config?.skipAwait) {
transformations.push(skipAwait);
}

this.resources = pulumi.output(text.then(t => {
try {
return parseYamlDocument({
objs: yamlLoadAll(t),
transformations: config && config.transformations || [],
transformations,
resourcePrefix: config && config.resourcePrefix || undefined
}, {parent: this})
} catch (e) {
Expand Down Expand Up @@ -2776,6 +2781,12 @@ export interface ConfigGroupOpts {
* Example: A resource created with resourcePrefix="foo" would produce a resource named "foo-resourceName".
*/
resourcePrefix?: string;

/**
* Skip await logic for all resources in this YAML. Resources will be marked ready as soon as they are created.
* Warning: This option should not be used if you have resources depending on Outputs from the YAML.
*/
skipAwait?: boolean;
}

/**
Expand All @@ -2793,6 +2804,12 @@ export interface ConfigFileOpts {
* Example: A resource created with resourcePrefix="foo" would produce a resource named "foo-resourceName".
*/
resourcePrefix?: string;

/**
* Skip await logic for all resources in this YAML. Resources will be marked ready as soon as they are created.
* Warning: This option should not be used if you have resources depending on Outputs from the YAML.
*/
skipAwait?: boolean;
}

/**
Expand Down Expand Up @@ -2821,11 +2838,24 @@ export interface ConfigOpts {
.then((p => p.result));
}

/** @ignore */ export function skipAwait(o: any, opts: pulumi.ComponentResourceOptions) {
if (o.metadata.annotations === undefined) {
o.metadata.annotations = {"pulumi.com/skipAwait": "true"};
} else {
o.metadata.annotations["pulumi.com/skipAwait"] = "true";
}
}

/** @ignore */ export function parse(
config: ConfigGroupOpts, opts?: pulumi.CustomResourceOptions
): pulumi.Output<{[key: string]: pulumi.CustomResource}> {
let resources = pulumi.output<{[key: string]: pulumi.CustomResource}>({});

const transformations = config.transformations ?? [];
if (config.skipAwait) {
transformations.push(skipAwait);
}

if (config.files !== undefined) {
let files: string[] = [];
if (typeof config.files === 'string') {
Expand All @@ -2849,7 +2879,7 @@ export interface ConfigOpts {
file,
{
file: file,
transformations: config.transformations,
transformations,
resourcePrefix: config.resourcePrefix
},
opts
Expand All @@ -2869,7 +2899,7 @@ export interface ConfigOpts {
for (const text of yamlTexts) {
const docResources = parseYamlDocument({
objs: yamlLoadAll(text),
transformations: config.transformations,
transformations,
resourcePrefix: config.resourcePrefix
},
opts);
Expand All @@ -2881,7 +2911,7 @@ export interface ConfigOpts {
const objs: Promise<any[]> = Array.isArray(config.objs) ? Promise.resolve(config.objs) : Promise.resolve([config.objs]);
const docResources = parseYamlDocument({
objs,
transformations: config.transformations,
transformations,
resourcePrefix: config.resourcePrefix
}, opts);
resources = pulumi.all([resources, docResources]).apply(([rs, drs]) => ({...rs, ...drs}));
Expand Down

0 comments on commit e662173

Please sign in to comment.