From 3975a1aff1353d616a91de682d0d2126396553af Mon Sep 17 00:00:00 2001 From: Hasan Date: Tue, 12 Mar 2024 16:38:09 -0400 Subject: [PATCH] fix: updates for wing 0.61.0 --- containers/local-build.test.w | 2 +- containers/package.json | 2 +- containers/workload.sim.w | 8 ++++---- containers/workload.tfaws.w | 2 +- fifoqueue/fifo-queue.aws.w | 34 ++++++++++++++++++---------------- github/lib.test.w | 2 +- github/package.json | 2 +- websockets/package.json | 2 +- websockets/platform/awscdk.w | 2 +- 9 files changed, 29 insertions(+), 27 deletions(-) diff --git a/containers/local-build.test.w b/containers/local-build.test.w index dc4c6e86..4e98c1b1 100644 --- a/containers/local-build.test.w +++ b/containers/local-build.test.w @@ -9,6 +9,6 @@ let app = new containers.Workload( ); test "can access container" { - let response = http.get("{app.publicUrl}"); + let response = http.get("{app.publicUrl!}"); assert(response.body == "Hello, Wingnuts!"); } \ No newline at end of file diff --git a/containers/package.json b/containers/package.json index a36a3b4f..7935a6b6 100644 --- a/containers/package.json +++ b/containers/package.json @@ -1,6 +1,6 @@ { "name": "@winglibs/containers", - "version": "0.0.21", + "version": "0.0.22", "description": "Container support for Wing", "repository": { "type": "git", diff --git a/containers/workload.sim.w b/containers/workload.sim.w index a4eb64f1..2870b3a4 100644 --- a/containers/workload.sim.w +++ b/containers/workload.sim.w @@ -26,7 +26,7 @@ pub class Workload_sim { this.containerIdKey = "container_id"; let hash = utils.resolveContentHash(this, props); - if hash? { + if let hash = hash { this.imageTag = "{props.name}:{hash}"; } else { this.imageTag = props.image; @@ -98,7 +98,7 @@ pub class Workload_sim { if env.size() > 0 { dockerRun.push("-e"); for k in env.keys() { - dockerRun.push("{k}={env.get(k)}"); + dockerRun.push("{k}={env.get(k)!}"); } } } @@ -126,14 +126,14 @@ pub class Workload_sim { throw "Container does not listen to port {port}"; } - let publicUrl = "http://localhost:{hostPort}"; + let publicUrl = "http://localhost:{hostPort!}"; if let k = this.publicUrlKey { this.state.set(k, publicUrl); } if let k = this.internalUrlKey { - this.state.set(k, "http://host.docker.internal:{hostPort}"); + this.state.set(k, "http://host.docker.internal:{hostPort!}"); } if let readiness = opts.readiness { diff --git a/containers/workload.tfaws.w b/containers/workload.tfaws.w index 66ceddad..f349d093 100644 --- a/containers/workload.tfaws.w +++ b/containers/workload.tfaws.w @@ -130,7 +130,7 @@ pub class Workload_tfaws { ); if let port = props.port { - this.internalUrl = "http://{props.name}:{props.port}"; + this.internalUrl = "http://{props.name}:{port}"; } // if "public" is set, lookup the address from the ingress resource created by the helm chart diff --git a/fifoqueue/fifo-queue.aws.w b/fifoqueue/fifo-queue.aws.w index e0964f4e..b48cf141 100644 --- a/fifoqueue/fifo-queue.aws.w +++ b/fifoqueue/fifo-queue.aws.w @@ -39,22 +39,24 @@ pub class FifoQueue_aws impl api.IFifoQueue { }, env: options?.env, logRetentionDays: options?.logRetentionDays, memory: options?.memory, timeout: options?.timeout); let lambda = awsUtil.Function.from(lambdaFn); - lambda?.addPolicyStatements({ - actions: [ - "sqs:ReceiveMessage", - "sqs:ChangeMessageVisibility", - "sqs:GetQueueUrl", - "sqs:DeleteMessage", - "sqs:GetQueueAttributes", - ], - resources: [this.arn], - }); - - new aws.lambdaEventSourceMapping.LambdaEventSourceMapping( - functionName: "{lambda?.functionName}", - eventSourceArn: this.arn, - batchSize: options?.batchSize ?? 1 - ); + if let lambda = lambda { + lambda?.addPolicyStatements({ + actions: [ + "sqs:ReceiveMessage", + "sqs:ChangeMessageVisibility", + "sqs:GetQueueUrl", + "sqs:DeleteMessage", + "sqs:GetQueueAttributes", + ], + resources: [this.arn], + }); + + new aws.lambdaEventSourceMapping.LambdaEventSourceMapping( + functionName: lambda.functionName, + eventSourceArn: this.arn, + batchSize: options?.batchSize ?? 1 + ); + } } pub onLift(host: std.IInflightHost, ops: Array) { diff --git a/github/lib.test.w b/github/lib.test.w index 2fb113e0..aeaf9a9d 100644 --- a/github/lib.test.w +++ b/github/lib.test.w @@ -40,7 +40,7 @@ let handler = inflight (ctx) => { ref: ctx.payload.pull_request.head.sha ); - let fileContents = util.base64Decode("{contents.data.content}"); + let fileContents = util.base64Decode(contents.data.content ?? ""); ctx.octokit.repos.createOrUpdateFileContents( owner: repo.owner.login, diff --git a/github/package.json b/github/package.json index a9108de0..17007139 100644 --- a/github/package.json +++ b/github/package.json @@ -1,7 +1,7 @@ { "name": "@winglibs/github", "description": "A Wing library for GitHub Probot", - "version": "0.0.5", + "version": "0.0.6", "author": { "name": "Elad Cohen", "email": "eladc@wing.cloud" diff --git a/websockets/package.json b/websockets/package.json index f336523c..0023f6ba 100644 --- a/websockets/package.json +++ b/websockets/package.json @@ -1,7 +1,7 @@ { "name": "@winglibs/websockets", "description": "WebSocket library for Wing", - "version": "0.3.1", + "version": "0.3.2", "repository": { "type": "git", "url": "https://github.com/winglang/winglibs.git", diff --git a/websockets/platform/awscdk.w b/websockets/platform/awscdk.w index b7e3e0f2..8b2a6a89 100644 --- a/websockets/platform/awscdk.w +++ b/websockets/platform/awscdk.w @@ -45,7 +45,7 @@ pub class WebSocket_awscdk impl awsapi.IAwsWebSocket { ) as "url"; new awscdk.CfnOutput( - value: "https://{this.api.attrApiId}.execute-api.{this.region}.{urlSuffix}/{stageName}", + value: "https://{this.api.attrApiId}.execute-api.{this.region!}.{urlSuffix}/{stageName}", exportName: "callbackUrl" ) as "callbackUrl"; }