mirror of https://github.com/pulumi/pulumi.git
[nodejs] Fix serialization/deserialization for StackSettings (#6754)
This commit is contained in:
parent
49241d5f74
commit
126c7849a3
|
@ -47,9 +47,6 @@
|
|||
- [sdk/nodejs] Allow prompt values in `construct` for multi-lang components.
|
||||
[#6522](https://github.com/pulumi/pulumi/pull/6522)
|
||||
|
||||
- [automation/dotnet] Fix (de)serialization of StackSettings.
|
||||
[#6752](https://github.com/pulumi/pulumi/pull/6752)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- [cli] Handle non-existent creds file in `pulumi logout --all`
|
||||
|
@ -68,7 +65,7 @@
|
|||
[#6520](https://github.com/pulumi/pulumi/pull/6520)
|
||||
|
||||
- [sdk/nodejs] Fix `Construct` to wait for child resources of a multi-lang components to be created.
|
||||
[#6452](https://github.com/pulumi/pulumi/pull/6452
|
||||
[#6452](https://github.com/pulumi/pulumi/pull/6452)
|
||||
|
||||
- [sdk/python] Fix serialization bug if output contains 'items' property.
|
||||
[#6701](https://github.com/pulumi/pulumi/pull/6701)
|
||||
|
@ -78,6 +75,8 @@
|
|||
|
||||
- [automation/dotnet] Fix GetConfigValueAsync failing to deserialize
|
||||
[#6698](https://github.com/pulumi/pulumi/pull/6698)
|
||||
|
||||
- [automation/python] Fix (de)serialization of StackSettings.
|
||||
|
||||
- [automation] Fix (de)serialization of StackSettings in .NET, Node, and Python.
|
||||
[#6752](https://github.com/pulumi/pulumi/pull/6752)
|
||||
[#6754](https://github.com/pulumi/pulumi/pull/6754)
|
||||
[#6749](https://github.com/pulumi/pulumi/pull/6749)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"secretsProvider": "abc",
|
||||
"secretsprovider": "abc",
|
||||
"config": {
|
||||
"plain": "plain",
|
||||
"secure": {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
secretsProvider: abc
|
||||
secretsprovider: abc
|
||||
config:
|
||||
plain: plain
|
||||
secure:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
secretsProvider: abc
|
||||
secretsprovider: abc
|
||||
config:
|
||||
plain: plain
|
||||
secure:
|
||||
|
|
|
@ -23,7 +23,7 @@ import { ConfigMap, ConfigValue } from "./config";
|
|||
import { minimumVersion } from "./minimumVersion";
|
||||
import { ProjectSettings } from "./projectSettings";
|
||||
import { Stack } from "./stack";
|
||||
import { StackSettings } from "./stackSettings";
|
||||
import { StackSettings, stackSettingsSerDeKeys } from "./stackSettings";
|
||||
import { Deployment, PluginInfo, PulumiFn, StackSummary, WhoAmIResult, Workspace } from "./workspace";
|
||||
|
||||
/**
|
||||
|
@ -289,10 +289,20 @@ export class LocalWorkspace implements Workspace {
|
|||
const path = upath.joinSafe(this.workDir, `Pulumi.${stackSettingsName}${ext}`);
|
||||
if (!fs.existsSync(path)) { continue; }
|
||||
const contents = fs.readFileSync(path).toString();
|
||||
let stackSettings: any;
|
||||
if (isJSON) {
|
||||
return JSON.parse(contents);
|
||||
stackSettings = JSON.parse(contents);
|
||||
}
|
||||
return yaml.safeLoad(contents) as StackSettings;
|
||||
stackSettings = yaml.safeLoad(contents) as StackSettings;
|
||||
|
||||
// Transform the serialized representation back to what we expect.
|
||||
for (const key of stackSettingsSerDeKeys) {
|
||||
if (stackSettings.hasOwnProperty(key[0])) {
|
||||
stackSettings[key[1]] = stackSettings[key[0]];
|
||||
delete stackSettings[key[0]];
|
||||
}
|
||||
}
|
||||
return stackSettings as StackSettings;
|
||||
}
|
||||
throw new Error(`failed to find stack settings file in workdir: ${this.workDir}`);
|
||||
}
|
||||
|
@ -314,12 +324,22 @@ export class LocalWorkspace implements Workspace {
|
|||
}
|
||||
}
|
||||
const path = upath.joinSafe(this.workDir, `Pulumi.${stackSettingsName}${foundExt}`);
|
||||
const serializeSettings = settings as any;
|
||||
let contents;
|
||||
|
||||
// Transform the keys to the serialized representation that we expect.
|
||||
for (const key of stackSettingsSerDeKeys) {
|
||||
if (serializeSettings.hasOwnProperty(key[1])) {
|
||||
serializeSettings[key[0]] = serializeSettings[key[1]];
|
||||
delete serializeSettings[key[1]];
|
||||
}
|
||||
}
|
||||
|
||||
if (foundExt === ".json") {
|
||||
contents = JSON.stringify(settings, null, 4);
|
||||
contents = JSON.stringify(serializeSettings, null, 4);
|
||||
}
|
||||
else {
|
||||
contents = yaml.safeDump(settings, { skipInvalid: true });
|
||||
contents = yaml.safeDump(serializeSettings, { skipInvalid: true });
|
||||
}
|
||||
return fs.writeFileSync(path, contents);
|
||||
}
|
||||
|
|
|
@ -35,3 +35,10 @@ export type StackSettingsConfigValue = string | StackSettingsSecureConfigValue |
|
|||
export interface StackSettingsSecureConfigValue {
|
||||
secure: string;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export const stackSettingsSerDeKeys = [
|
||||
["secretsprovider", "secretsProvider"],
|
||||
["encryptedkey", "encryptedKey"],
|
||||
["encryptionsalt", "encryptionSalt"],
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue