Amending changes from @TomChv

Signed-off-by: Sujay Pillai <sujayopillai@gmail.com>
This commit is contained in:
Sujay Pillai
2021-08-12 01:37:17 +08:00
parent bdd6b5a56e
commit d74753bca7
3 changed files with 37 additions and 19 deletions

View File

@@ -3,6 +3,7 @@ package resourcegroup
import (
"alpha.dagger.io/azure"
"alpha.dagger.io/os"
"alpha.dagger.io/dagger"
)
// Create a resource group
@@ -11,10 +12,13 @@ import (
config: azure.#Config
// ResourceGroup name
rgName: string @dagger(input)
rgName: string & dagger.#Input
// ResourceGroup location
rgLocation: string @dagger(input)
rgLocation: string & dagger.#Input
// ResourceGroup Id
id: string & dagger.#Output
// Container image
ctr: os.#Container & {
@@ -24,16 +28,21 @@ import (
always: true
command: """
az group create -l "\(rgLocation)" -n "\(rgName)"
az group show -n "\(rgName)" --query "id" -o json | jq -r . | tr -d "\n" > /resourceGroupId
az group create -l "$AZURE_DEFAULTS_LOCATION" -n "$AZURE_DEFAULTS_GROUP"
az group show -n "$AZURE_DEFAULTS_GROUP" --query "id" -o json | jq -r . | tr -d "\n" > /resourceGroupId
"""
env: {
AZURE_DEFAULTS_GROUP: rgName
AZURE_DEFAULTS_LOCATION: rgLocation
}
}
// Resource Id
id: {
id: ({
os.#File & {
from: ctr
path: "/resourceGroupId"
}
}.contents @dagger(output)
}).contents
}

View File

@@ -6,12 +6,12 @@ import (
"alpha.dagger.io/random"
)
suffix: random.#String & {
TestSuffix: random.#String & {
seed: "azrg"
}
rg: resourcegroup.#ResourceGroup & {
TestRG: resourcegroup.#ResourceGroup & {
config: azure.#Config
rgName: "rg-test-\(suffix.out)"
rgName: "rg-test-\(TestSuffix.out)"
rgLocation: "eastus2"
}