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"
|
"alpha.dagger.io/os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Default Azure CLI version
|
||||||
|
let defaultVersion = "2.27.1@sha256:1e117183100c9fce099ebdc189d73e506e7b02d2b73d767d3fc07caee72f9fb1"
|
||||||
|
|
||||||
//Azure Config shared by all Azure packages
|
//Azure Config shared by all Azure packages
|
||||||
#Config: {
|
#Config: {
|
||||||
// AZURE tenant id
|
// AZURE tenant id
|
||||||
tenantId: dagger.#Secret @dagger(input)
|
tenantId: dagger.#Secret & dagger.#Input
|
||||||
// AZURE subscription id
|
// AZURE subscription id
|
||||||
subscriptionId: dagger.#Secret @dagger(input)
|
subscriptionId: dagger.#Secret & dagger.#Input
|
||||||
// AZURE app id for the service principal used
|
// 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
|
// 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
|
// Azure Cli to be used by all Azure packages
|
||||||
@ -24,11 +27,15 @@ import (
|
|||||||
// Azure Config
|
// Azure Config
|
||||||
config: #Config
|
config: #Config
|
||||||
|
|
||||||
|
// Azure CLI version to install
|
||||||
|
version: string | *defaultVersion
|
||||||
|
|
||||||
// Container image
|
// Container image
|
||||||
os.#Container & {
|
os.#Container & {
|
||||||
image: docker.#Pull & {
|
image: docker.#Pull & {
|
||||||
from: "mcr.microsoft.com/azure-cli"
|
from: "mcr.microsoft.com/azure-cli:\(version)"
|
||||||
}
|
}
|
||||||
|
|
||||||
always: true
|
always: true
|
||||||
|
|
||||||
command: """
|
command: """
|
||||||
@ -36,9 +43,11 @@ import (
|
|||||||
az account set -s "$(cat /run/secrets/subscriptionId)"
|
az account set -s "$(cat /run/secrets/subscriptionId)"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
secret: "/run/secrets/appId": config.appId
|
secret: {
|
||||||
secret: "/run/secrets/password": config.password
|
"/run/secrets/appId": config.appId
|
||||||
secret: "/run/secrets/tenantId": config.tenantId
|
"/run/secrets/password": config.password
|
||||||
secret: "/run/secrets/subscriptionId": config.subscriptionId
|
"/run/secrets/tenantId": config.tenantId
|
||||||
|
"/run/secrets/subscriptionId": config.subscriptionId
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package resourcegroup
|
|||||||
import (
|
import (
|
||||||
"alpha.dagger.io/azure"
|
"alpha.dagger.io/azure"
|
||||||
"alpha.dagger.io/os"
|
"alpha.dagger.io/os"
|
||||||
|
"alpha.dagger.io/dagger"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create a resource group
|
// Create a resource group
|
||||||
@ -11,10 +12,13 @@ import (
|
|||||||
config: azure.#Config
|
config: azure.#Config
|
||||||
|
|
||||||
// ResourceGroup name
|
// ResourceGroup name
|
||||||
rgName: string @dagger(input)
|
rgName: string & dagger.#Input
|
||||||
|
|
||||||
// ResourceGroup location
|
// ResourceGroup location
|
||||||
rgLocation: string @dagger(input)
|
rgLocation: string & dagger.#Input
|
||||||
|
|
||||||
|
// ResourceGroup Id
|
||||||
|
id: string & dagger.#Output
|
||||||
|
|
||||||
// Container image
|
// Container image
|
||||||
ctr: os.#Container & {
|
ctr: os.#Container & {
|
||||||
@ -24,16 +28,21 @@ import (
|
|||||||
always: true
|
always: true
|
||||||
|
|
||||||
command: """
|
command: """
|
||||||
az group create -l "\(rgLocation)" -n "\(rgName)"
|
az group create -l "$AZURE_DEFAULTS_LOCATION" -n "$AZURE_DEFAULTS_GROUP"
|
||||||
az group show -n "\(rgName)" --query "id" -o json | jq -r . | tr -d "\n" > /resourceGroupId
|
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
|
// Resource Id
|
||||||
id: {
|
id: ({
|
||||||
os.#File & {
|
os.#File & {
|
||||||
from: ctr
|
from: ctr
|
||||||
path: "/resourceGroupId"
|
path: "/resourceGroupId"
|
||||||
}
|
}
|
||||||
}.contents @dagger(output)
|
}).contents
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,12 @@ import (
|
|||||||
"alpha.dagger.io/random"
|
"alpha.dagger.io/random"
|
||||||
)
|
)
|
||||||
|
|
||||||
suffix: random.#String & {
|
TestSuffix: random.#String & {
|
||||||
seed: "azrg"
|
seed: "azrg"
|
||||||
}
|
}
|
||||||
|
|
||||||
rg: resourcegroup.#ResourceGroup & {
|
TestRG: resourcegroup.#ResourceGroup & {
|
||||||
config: azure.#Config
|
config: azure.#Config
|
||||||
rgName: "rg-test-\(suffix.out)"
|
rgName: "rg-test-\(TestSuffix.out)"
|
||||||
rgLocation: "eastus2"
|
rgLocation: "eastus2"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user