Amending changes from @TomChv
Signed-off-by: Sujay Pillai <sujayopillai@gmail.com>
This commit is contained in:
parent
bdd6b5a56e
commit
d74753bca7
@ -7,16 +7,19 @@ import (
|
||||
"alpha.dagger.io/os"
|
||||
)
|
||||
|
||||
// Default Azure CLI version
|
||||
let defaultVersion = "2.27.1@sha256:1e117183100c9fce099ebdc189d73e506e7b02d2b73d767d3fc07caee72f9fb1"
|
||||
|
||||
//Azure Config shared by all Azure packages
|
||||
#Config: {
|
||||
// AZURE tenant id
|
||||
tenantId: dagger.#Secret @dagger(input)
|
||||
tenantId: dagger.#Secret & dagger.#Input
|
||||
// AZURE subscription id
|
||||
subscriptionId: dagger.#Secret @dagger(input)
|
||||
subscriptionId: dagger.#Secret & dagger.#Input
|
||||
// AZURE app id for the service principal used
|
||||
appId: dagger.#Secret @dagger(input)
|
||||
appId: dagger.#Secret & dagger.#Input
|
||||
// AZURE password for the service principal used
|
||||
password: dagger.#Secret @dagger(input)
|
||||
password: dagger.#Secret & dagger.#Input
|
||||
}
|
||||
|
||||
// Azure Cli to be used by all Azure packages
|
||||
@ -24,21 +27,27 @@ import (
|
||||
// Azure Config
|
||||
config: #Config
|
||||
|
||||
// Azure CLI version to install
|
||||
version: string | *defaultVersion
|
||||
|
||||
// Container image
|
||||
os.#Container & {
|
||||
image: docker.#Pull & {
|
||||
from: "mcr.microsoft.com/azure-cli"
|
||||
from: "mcr.microsoft.com/azure-cli:\(version)"
|
||||
}
|
||||
|
||||
always: true
|
||||
|
||||
command: """
|
||||
az login --service-principal -u "$(cat /run/secrets/appId)" -p "$(cat /run/secrets/password)" -t "$(cat /run/secrets/tenantId)"
|
||||
az account set -s "$(cat /run/secrets/subscriptionId)"
|
||||
"""
|
||||
|
||||
secret: "/run/secrets/appId": config.appId
|
||||
secret: "/run/secrets/password": config.password
|
||||
secret: "/run/secrets/tenantId": config.tenantId
|
||||
secret: "/run/secrets/subscriptionId": config.subscriptionId
|
||||
|
||||
secret: {
|
||||
"/run/secrets/appId": config.appId
|
||||
"/run/secrets/password": config.password
|
||||
"/run/secrets/tenantId": config.tenantId
|
||||
"/run/secrets/subscriptionId": config.subscriptionId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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"
|
||||
}
|
||||
|
Reference in New Issue
Block a user