From e25244cc24596b6c444c111d0e9daac58f16cb06 Mon Sep 17 00:00:00 2001 From: Chris Rybicki Date: Mon, 1 Jul 2024 12:00:44 -0400 Subject: [PATCH] fix(cdk8s): unable to obtain root node --- cdk8s/examples/nodejs.main.w | 5 +++-- cdk8s/lib/index.js | 5 +++-- cdk8s/package-lock.json | 4 ++-- cdk8s/package.json | 2 +- cdk8s/root.test.w | 2 ++ cdk8s/test.sh | 7 ++++--- 6 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 cdk8s/root.test.w diff --git a/cdk8s/examples/nodejs.main.w b/cdk8s/examples/nodejs.main.w index 10c3d9c1..43b9fe2f 100644 --- a/cdk8s/examples/nodejs.main.w +++ b/cdk8s/examples/nodejs.main.w @@ -1,8 +1,9 @@ bring "cdk8s-plus-27" as k8s; +bring fs; // lets create a volume that contains our app. let appData = new k8s.ConfigMap(); -appData.addDirectory("./nodejs-app"); +appData.addDirectory(fs.join(@dirname, "./nodejs-app")); let appVolume = k8s.Volume.fromConfigMap(this, "App", appData); @@ -25,4 +26,4 @@ let container = deployment.addContainer({ container.mount(appPath, appVolume); // finally, we expose the deployment as a load balancer service and make it run -deployment.exposeViaService(serviceType: k8s.ServiceType.LOAD_BALANCER); \ No newline at end of file +deployment.exposeViaService(serviceType: k8s.ServiceType.LOAD_BALANCER); diff --git a/cdk8s/lib/index.js b/cdk8s/lib/index.js index 517438aa..bf7cc59a 100644 --- a/cdk8s/lib/index.js +++ b/cdk8s/lib/index.js @@ -1,5 +1,5 @@ const cdk8s = require('cdk8s'); -const { core } = require('@winglang/sdk');; +const { core, std } = require('@winglang/sdk');; exports.Platform = class { target = "cdk8s"; @@ -20,6 +20,7 @@ exports.Platform = class { root.newAbstract = (fqn, scope, id, ...args) => this.newAbstract(fqn, scope, id, ...args); root.typeForFqn = fqn => this.typeForFqn(fqn); + std.Node._markRoot(props.rootConstruct); new props.rootConstruct(this, props.rootId ?? "Default"); } @@ -31,4 +32,4 @@ exports.Platform = class { return new App(); } -}; \ No newline at end of file +}; diff --git a/cdk8s/package-lock.json b/cdk8s/package-lock.json index bee17fc1..7fd82242 100644 --- a/cdk8s/package-lock.json +++ b/cdk8s/package-lock.json @@ -1,12 +1,12 @@ { "name": "@winglibs/cdk8s", - "version": "0.0.1", + "version": "0.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@winglibs/cdk8s", - "version": "0.0.1", + "version": "0.0.3", "license": "MIT", "devDependencies": { "cdk8s-plus-27": "^2.9.0" diff --git a/cdk8s/package.json b/cdk8s/package.json index 31827aac..3fed58fb 100644 --- a/cdk8s/package.json +++ b/cdk8s/package.json @@ -1,7 +1,7 @@ { "name": "@winglibs/cdk8s", "description": "cdk8s library for Wing", - "version": "0.0.2", + "version": "0.0.3", "author": { "name": "Elad Ben-Israel", "email": "eladb@wing.cloud" diff --git a/cdk8s/root.test.w b/cdk8s/root.test.w new file mode 100644 index 00000000..4ee3e2a5 --- /dev/null +++ b/cdk8s/root.test.w @@ -0,0 +1,2 @@ +let root = nodeof(this).root; +log("root: " + nodeof(root).path); diff --git a/cdk8s/test.sh b/cdk8s/test.sh index 7535ae1b..4f6b4422 100755 --- a/cdk8s/test.sh +++ b/cdk8s/test.sh @@ -1,4 +1,5 @@ #!/bin/sh -cd examples -wing compile -t ../lib/index.js nodejs.main.w -wing compile -t ../lib/index.js ubuntu.main.w + +wing compile -t ./lib/index.js examples/nodejs.main.w +wing compile -t ./lib/index.js examples/ubuntu.main.w +wing compile -t ./lib/index.js root.test.w