From a413692187ca83a95c610f7163d5e1c34a7416cc Mon Sep 17 00:00:00 2001 From: Christian Nunciato Date: Thu, 20 Oct 2022 11:10:15 -0700 Subject: [PATCH] Make CPU and memory configurable in the TS template --- container-azure-csharp/Pulumi.yaml | 3 +++ container-azure-go/main.go | 8 ++++---- container-azure-python/__main__.py | 2 +- container-azure-typescript/index.ts | 8 +++++--- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/container-azure-csharp/Pulumi.yaml b/container-azure-csharp/Pulumi.yaml index 80b641c0e..ea24a5793 100644 --- a/container-azure-csharp/Pulumi.yaml +++ b/container-azure-csharp/Pulumi.yaml @@ -7,6 +7,9 @@ template: azure-native:location: description: The Azure region to deploy into default: WestUS + appName: + description: The name of the application to deploy + default: my-app appPath: description: The path to the container application to deploy default: app diff --git a/container-azure-go/main.go b/container-azure-go/main.go index 1ea3148c0..656c76896 100644 --- a/container-azure-go/main.go +++ b/container-azure-go/main.go @@ -18,14 +18,14 @@ func main() { // Import the program's configuration settings. cfg := config.New(ctx, "") - imageName := "my-app" - if param := cfg.Get("imageName"); param != "" { - imageName = param - } appPath := "./app" if param := cfg.Get("appPath"); param != "" { appPath = param } + imageName := "my-app" + if param := cfg.Get("imageName"); param != "" { + imageName = param + } containerPort := 80 if param := cfg.GetInt("containerPort"); param != 0 { containerPort = param diff --git a/container-azure-python/__main__.py b/container-azure-python/__main__.py index b0c17e447..6e4e3cdde 100644 --- a/container-azure-python/__main__.py +++ b/container-azure-python/__main__.py @@ -5,8 +5,8 @@ # Import the program's configuration settings. config = pulumi.Config() -image_name = config.get("imageName", "my-app") app_path = config.get("appPath", "./app") +image_name = config.get("imageName", "my-app") container_port = config.get_int("containerPort", 80) cpu = config.get_float("cpu", 1.0) memory = config.get_float("memory", 1.5) diff --git a/container-azure-typescript/index.ts b/container-azure-typescript/index.ts index 84d5407bb..2fd0bda6d 100644 --- a/container-azure-typescript/index.ts +++ b/container-azure-typescript/index.ts @@ -7,9 +7,11 @@ import * as docker from "@pulumi/docker"; // Import the program's configuration settings. const config = new pulumi.Config(); -const imageName = config.get("imageName") || "my-app"; const appPath = config.get("appPath") || "./app"; +const imageName = config.get("imageName") || "my-app"; const containerPort = config.getNumber("containerPort") || 80; +const cpu = config.getNumber("cpu") || 1.0; +const memory = config.getNumber("memory") || 1.5; // Create a resource group for the container registry. const resourceGroup = new resources.ResourceGroup("resource-group"); @@ -83,8 +85,8 @@ const containerGroup = new containerinstance.ContainerGroup("container-group", { ], resources: { requests: { - cpu: 1.0, - memoryInGB: 1.5, + cpu: cpu, + memoryInGB: memory, }, }, },