Skip to content

Commit

Permalink
fix(pulumi): enable config cloning (#3572)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 authored Oct 4, 2023
1 parent 6a1281b commit 88829ab
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/pulumi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
},
"dependencies": {
"@pulumi/pulumi": "^3.34.0",
"find-up": "^5.0.0"
"find-up": "^5.0.0",
"lodash": "^4.17.21"
},
"devDependencies": {
"@babel/cli": "^7.22.6",
Expand Down
2 changes: 2 additions & 0 deletions packages/pulumi/src/PulumiAppResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export interface PulumiAppResourceConfigSetter<T> {

export type PulumiAppResourceConfigProxy<T extends object> = {
readonly [K in keyof T]-?: PulumiAppResourceConfigSetter<T[K]>;
} & {
clone(): T;
};

export interface PulumiAppResource<T extends PulumiAppResourceConstructor> {
Expand Down
5 changes: 5 additions & 0 deletions packages/pulumi/src/createPulumiApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
ResourceHandler
} from "~/types";
import { PulumiAppRemoteResource } from "~/PulumiAppRemoteResource";
import cloneDeep from "lodash/cloneDeep";

export function createPulumiApp<TResources extends Record<string, unknown>>(
params: CreatePulumiAppParams<TResources>
Expand Down Expand Up @@ -219,6 +220,10 @@ export function createPulumiApp<TResources extends Record<string, unknown>>(
function createPulumiAppResourceConfigProxy<T extends object>(obj: T) {
return new Proxy(obj, {
get(target, p: string) {
if (p === "clone") {
return () => cloneDeep(obj);
}

type V = T[keyof T];
const key = p as keyof T;
const setter: PulumiAppResourceConfigSetter<V> = (
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16506,6 +16506,7 @@ __metadata:
"@webiny/cli": 0.0.0
"@webiny/project-utils": 0.0.0
find-up: ^5.0.0
lodash: ^4.17.21
rimraf: ^3.0.2
typescript: 4.7.4
languageName: unknown
Expand Down

0 comments on commit 88829ab

Please sign in to comment.