Skip to content

Commit

Permalink
fix(cdk8s): unable to obtain root node
Browse files Browse the repository at this point in the history
  • Loading branch information
Chriscbr committed Jul 1, 2024
1 parent 6ad8d99 commit e25244c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions cdk8s/examples/nodejs.main.w
Original file line number Diff line number Diff line change
@@ -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);

Expand All @@ -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);
deployment.exposeViaService(serviceType: k8s.ServiceType.LOAD_BALANCER);
5 changes: 3 additions & 2 deletions cdk8s/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const cdk8s = require('cdk8s');
const { core } = require('@winglang/sdk');;
const { core, std } = require('@winglang/sdk');;

exports.Platform = class {
target = "cdk8s";
Expand All @@ -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");
}

Expand All @@ -31,4 +32,4 @@ exports.Platform = class {

return new App();
}
};
};
4 changes: 2 additions & 2 deletions cdk8s/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cdk8s/package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]"
Expand Down
2 changes: 2 additions & 0 deletions cdk8s/root.test.w
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
let root = nodeof(this).root;
log("root: " + nodeof(root).path);
7 changes: 4 additions & 3 deletions cdk8s/test.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e25244c

Please sign in to comment.