Skip to content

Commit

Permalink
chore: refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
eladb committed Aug 8, 2024
1 parent 9890151 commit 3bab75b
Show file tree
Hide file tree
Showing 29 changed files with 85 additions and 93 deletions.
25 changes: 0 additions & 25 deletions containers/containers.test.w

This file was deleted.

15 changes: 0 additions & 15 deletions containers/ecr.main.w

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
bring "./api.w" as api;
bring "../api.w" as api;
bring "./tfaws-eks.w" as eks;
bring "cdk8s-plus-27" as plus;
bring "cdk8s" as cdk8s;
bring "cdktf" as cdktf;
bring "./tfaws-ecr.w" as ecr;
bring "@cdktf/provider-kubernetes" as k8s;
bring "@cdktf/provider-helm" as helm_provider;
bring "./helm.w" as helm;
bring "../helm/helm.w" as helm;
bring fs;
bring cloud;

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion containers/helm.w → containers/helm/helm.w
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bring "./api.w" as api;
bring "../api.w" as api;
bring "cdk8s-plus-27" as plus;
bring "cdk8s" as cdk8s;

Expand Down
4 changes: 2 additions & 2 deletions containers/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 containers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@winglibs/containers",
"version": "0.1.5",
"version": "0.1.6",
"description": "Container support for Wing",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ bring util;
bring cloud;
bring sim;
bring ui;
bring "./api.w" as api;
bring "../api.w" as api;

pub class Workload_sim impl api.IWorkload {
pub publicUrl: str?;
Expand Down
4 changes: 2 additions & 2 deletions containers/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ else
fi

DEBUG=1 wing test
wing test -t tf-aws -s $snapshot_mode containers.test.w
wing test -t tf-aws -s $snapshot_mode containers-with-readiness.test.w
WING_CONTAINERS_PROVIDER="eks" wing test -t tf-aws -s $snapshot_mode test/containers.test.w
WING_CONTAINERS_PROVIDER="eks" wing test -t tf-aws -s $snapshot_mode test/containers-with-readiness.test.w
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bring "./workload.w" as containers;
bring "../" as containers;
bring expect;
bring http;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
"required_providers": {
"aws": {
"source": "aws",
"version": "5.31.0"
"version": "5.56.1"
},
"helm": {
"source": "helm",
Expand Down
18 changes: 18 additions & 0 deletions containers/test/containers.test.w
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
bring "../" as containers;
bring expect;
bring http;
bring sim;

let echo = new containers.Workload(
name: "http-echo",
image: "hashicorp/http-echo",
port: 5678,
public: true,
replicas: 2,
args: ["-text=hello1234"],
);

// test "access public url" {
// let echoBody = http.get(echo.publicUrl!).body;
// assert(echoBody.contains("hello1234"));
// }
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@
}
},
"kubernetes_ingress_v1": {
"http-echo_DataKubernetesIngressV1_14943683": {
"Workload_http-echo_DataKubernetesIngressV1_A36C9067": {
"//": {
"metadata": {
"path": "root/Default/Default/http-echo/http-echo/DataKubernetesIngressV1",
"uniqueId": "http-echo_DataKubernetesIngressV1_14943683"
"path": "root/Default/Default/Workload/http-echo/DataKubernetesIngressV1",
"uniqueId": "Workload_http-echo_DataKubernetesIngressV1_A36C9067"
}
},
"depends_on": [
"helm_release.http-echo_Release_2E4AC011"
"helm_release.Workload_http-echo_Release_73477725"
],
"metadata": {
"name": "http-echo"
Expand All @@ -92,7 +92,7 @@
"enable_dns_hostnames": true,
"enable_nat_gateway": true,
"private_subnet_tags": {
"kubernetes.io/cluster/wing-eks-c81852": "shared",
"kubernetes.io/cluster/wing-eks-c8281f": "shared",
"kubernetes.io/role/internal-elb": "1"
},
"private_subnets": [
Expand All @@ -101,7 +101,7 @@
"10.0.3.0/24"
],
"public_subnet_tags": {
"kubernetes.io/cluster/wing-eks-c81852": "shared",
"kubernetes.io/cluster/wing-eks-c8281f": "shared",
"kubernetes.io/role/elb": "1"
},
"public_subnets": [
Expand Down Expand Up @@ -130,7 +130,7 @@
}
},
"cluster_endpoint_public_access": true,
"cluster_name": "wing-eks-c81852",
"cluster_name": "wing-eks-c8281f",
"cluster_version": "1.27",
"create_cluster_security_group": false,
"create_node_security_group": false,
Expand Down Expand Up @@ -179,7 +179,7 @@
},
"WingEksCluster_ekscluster_name_E1D79024": {
"description": "eks.cluster_name",
"value": "wing-eks-c81852"
"value": "wing-eks-c8281f"
},
"WingEksCluster_eksendpoint_FD8710BA": {
"description": "eks.endpoint",
Expand All @@ -201,7 +201,7 @@
"eks",
"get-token",
"--cluster-name",
"wing-eks-c81852"
"wing-eks-c8281f"
],
"command": "aws"
},
Expand All @@ -218,7 +218,7 @@
"eks",
"get-token",
"--cluster-name",
"wing-eks-c81852"
"wing-eks-c8281f"
],
"command": "aws"
},
Expand Down Expand Up @@ -262,18 +262,18 @@
},
{
"name": "clusterName",
"value": "wing-eks-c81852"
"value": "wing-eks-c8281f"
}
]
},
"http-echo_Release_2E4AC011": {
"Workload_http-echo_Release_73477725": {
"//": {
"metadata": {
"path": "root/Default/Default/http-echo/http-echo/Release",
"uniqueId": "http-echo_Release_2E4AC011"
"path": "root/Default/Default/Workload/http-echo/Release",
"uniqueId": "Workload_http-echo_Release_73477725"
}
},
"chart": ".wing/helm/http-echo-273a4641f9f305c101f6b0ae07761c77",
"chart": ".wing/helm/http-echo-63344863709bcf4e44f7b887311641a4",
"depends_on": [
],
"name": "http-echo",
Expand Down Expand Up @@ -316,7 +316,7 @@
"required_providers": {
"aws": {
"source": "aws",
"version": "5.31.0"
"version": "5.56.1"
},
"helm": {
"source": "helm",
Expand Down
11 changes: 11 additions & 0 deletions containers/test/ecr.main.w
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
bring "../eks/tfaws-ecr.w" as ecr;
bring util;

if util.env("WING_TARGET") == "tf-aws" {
new ecr.Repository(
name: "my-repository",
directory: "{@dirname}/test/my-app",
tag: "tag1"
);
}

2 changes: 1 addition & 1 deletion containers/eks.main.w → containers/test/eks.main.w
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bring "./tfaws-eks.w" as eks;
bring "../eks/tfaws-eks.w" as eks;
bring util;

if util.env("WING_TARGET") == "tf-aws" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ bring cloud;
bring util;
bring http;
bring expect;
bring "./workload.w" as w;
bring "../" as containers;

let workload = new w.Workload(
image: "./test/forwarders",
let workload = new containers.Workload(
image: "{@dirname}/forwarders",
name: "forwarders",
port: 3000,
public: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
bring "./workload.w" as containers;
bring "../" as containers;
bring http;
bring expect;

let app = new containers.Workload(
name: "my-app",
image: "./test/my_app",
image: "{@dirname}/my_app",
port: 3000,
public: true,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
bring "./workload.w" as containers;
bring "../" as containers;
bring cloud;
bring http;
bring expect;

let producer = new containers.Workload(
name: "producer",
image: "./test/microservices_producer",
image: "{@dirname}/microservices_producer",
port: 4000,
) as "producer";

let consumer = new containers.Workload(
name: "consumer",
image: "./test/microservices_consumer",
image: "{@dirname}/microservices_consumer",
port: 3000,
public: true,
env: {
Expand Down
2 changes: 1 addition & 1 deletion containers/simple.test.w → containers/test/simple.test.w
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
bring cloud;
bring http;
bring "./workload.w" as containers;
bring "../" as containers;
bring expect;

let app = new containers.Workload(
Expand Down
3 changes: 0 additions & 3 deletions containers/utils.extern.d.ts

This file was deleted.

5 changes: 0 additions & 5 deletions containers/utils.js

This file was deleted.

2 changes: 0 additions & 2 deletions containers/wing.toml

This file was deleted.

25 changes: 19 additions & 6 deletions containers/workload.w
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
bring util;
bring "./workload.sim.w" as sim;
bring "./workload.tfaws.w" as tfaws;
bring "./sim/workload.sim.w" as sim;
bring "./eks/workload.tfaws.w" as tfaws;
bring "./api.w" as api;
bring "./helm.w" as helm;
bring "./helm/helm.w" as helm;
bring http;
bring fs;
bring ui;
Expand Down Expand Up @@ -63,9 +63,22 @@ pub class Workload impl api.IWorkload {
}

resolveProvider(target: str): str {
let allowed = ["eks", "helm"];
let params: Json = nodeof(this).app.parameters.value("containers");
let provider = params?.tryGet("provider")?.tryAsStr();
let value = (): str? => {
if let p = util.tryEnv("WING_CONTAINERS_PROVIDER") {
return p;
}

let params: Json = nodeof(this).app.parameters.value("containers");
if let provider = params?.tryGet("provider")?.tryAsStr() {
return provider;
}

return "ecs";
};

let allowed = ["eks", "helm", "ecs"];
let provider = value();

if provider == nil {
throw "Missing 'provider' under 'containers' in wing.toml. Allowed values are {allowed.join(", ")}";
}
Expand Down

0 comments on commit 3bab75b

Please sign in to comment.