Skip to content

Commit

Permalink
chore(containers): modernize (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
eladb authored Nov 28, 2023
1 parent 1d3bfed commit cc94970
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
16 changes: 2 additions & 14 deletions containers/helm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,9 @@ const fs = require('fs');
const path = require('path');
const crypto = require('crypto');

function findWorkdir(scope) {
if (typeof(scope.workdir) == "string") {
return scope.workdir;
}

const parent = scope.node.scope;
if (!parent) {
throw new Error("cannot determine workdir");
}
return findWorkdir(parent);
}

exports.toHelmChart = function(chart) {

exports.toHelmChart = function (wingdir, chart) {
const app = cdk8s.App.of(chart);
const wingdir = findWorkdir(chart);

app.resolvers = [new cdk8s.LazyResolver(), new cdk8s.ImplicitTokenResolver(), new cdk8s.NumberStringUnionResolver()];
const docs = cdk8s.App._synthChart(chart);
Expand Down
2 changes: 1 addition & 1 deletion containers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@winglibs/containers",
"version": "0.0.16",
"version": "0.0.17",
"description": "Container support for Wing",
"repository": {
"type": "git",
Expand Down
5 changes: 4 additions & 1 deletion containers/utils.w
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ bring fs;
pub class Util {
extern "./utils.js" pub static inflight shell(command: str, args: Array<str>, cwd: str?): str;
extern "./utils.js" pub static contentHash(files: Array<str>, cwd: str): str;
extern "./utils.js" pub static entrypointDir(scope: std.IResource): str;
extern "./utils.js" pub static dirname(): str;

pub static entrypointDir(scope: std.IResource): str {
return std.Node.of(scope).app.entrypointDir;
}

pub static isPath(s: str): bool {
return s.startsWith("/") || s.startsWith("./");
}
Expand Down
5 changes: 3 additions & 2 deletions containers/workload.tfaws.w
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ pub class Workload_tfaws {
}

pub toHelm(): str {
return _Chart.toHelmChart(this);
let wingdir = std.Node.of(this).app.workdir;
return _Chart.toHelmChart(wingdir, this);
}

extern "./helm.js" pub static toHelmChart(chart: cdk8s.Chart): str;
extern "./helm.js" pub static toHelmChart(wingdir: str, chart: cdk8s.Chart): str;
}


Expand Down

0 comments on commit cc94970

Please sign in to comment.