Port azure.#CLI from up to os.#Container + manual testing + integrate bats test

Signed-off-by: Guillaume de Rouville <guillaume.derouville@gmail.com>
This commit is contained in:
Guillaume de Rouville 2021-08-11 15:16:56 +02:00
parent 5908aa628e
commit bdd6b5a56e
10 changed files with 68 additions and 63 deletions

View File

@ -16,12 +16,13 @@ Azure Cli to be used by all Azure packages
### azure.#CLI Inputs ### azure.#CLI Inputs
| Name | Type | Description | | Name | Type | Description |
| ------------- |:-------------: |:-------------: | | ------------- |:-------------: |:-------------: |
|*config.tenantId* | `dagger.#Secret` |AZURE tenant id | |*config.tenantId* | `dagger.#Secret` |AZURE tenant id |
|*config.subscriptionId* | `dagger.#Secret` |AZURE subscription id | |*config.subscriptionId* | `dagger.#Secret` |AZURE subscription id |
|*config.appId* | `dagger.#Secret` |AZURE app id for the service principal used | |*config.appId* | `dagger.#Secret` |AZURE app id for the service principal used |
|*config.password* | `dagger.#Secret` |AZURE password for the service principal used | |*config.password* | `dagger.#Secret` |AZURE password for the service principal used |
|*image.from* | `"mcr.microsoft.com/azure-cli"` |Remote ref (example: "index.docker.io/alpine:latest") |
### azure.#CLI Outputs ### azure.#CLI Outputs

View File

@ -14,18 +14,19 @@ Create a resource group
### resourcegroup.#ResourceGroup Inputs ### resourcegroup.#ResourceGroup Inputs
| Name | Type | Description | | Name | Type | Description |
| ------------- |:-------------: |:-------------: | | ------------- |:-------------: |:-------------: |
|*config.tenantId* | `dagger.#Secret` |AZURE tenant id | |*config.tenantId* | `dagger.#Secret` |AZURE tenant id |
|*config.subscriptionId* | `dagger.#Secret` |AZURE subscription id | |*config.subscriptionId* | `dagger.#Secret` |AZURE subscription id |
|*config.appId* | `dagger.#Secret` |AZURE app id for the service principal used | |*config.appId* | `dagger.#Secret` |AZURE app id for the service principal used |
|*config.password* | `dagger.#Secret` |AZURE password for the service principal used | |*config.password* | `dagger.#Secret` |AZURE password for the service principal used |
|*rgName* | `string` |ResourceGroup name | |*rgName* | `string` |ResourceGroup name |
|*rgLocation* | `string` |ResourceGroup location | |*rgLocation* | `string` |ResourceGroup location |
|*ctr.image.config.tenantId* | `dagger.#Secret` |AZURE tenant id | |*ctr.image.config.tenantId* | `dagger.#Secret` |AZURE tenant id |
|*ctr.image.config.subscriptionId* | `dagger.#Secret` |AZURE subscription id | |*ctr.image.config.subscriptionId* | `dagger.#Secret` |AZURE subscription id |
|*ctr.image.config.appId* | `dagger.#Secret` |AZURE app id for the service principal used | |*ctr.image.config.appId* | `dagger.#Secret` |AZURE app id for the service principal used |
|*ctr.image.config.password* | `dagger.#Secret` |AZURE password for the service principal used | |*ctr.image.config.password* | `dagger.#Secret` |AZURE password for the service principal used |
|*ctr.image.image.from* | `"mcr.microsoft.com/azure-cli"` |Remote ref (example: "index.docker.io/alpine:latest") |
### resourcegroup.#ResourceGroup Outputs ### resourcegroup.#ResourceGroup Outputs

View File

@ -0,0 +1,2 @@
# dagger state
state/**

View File

@ -1 +0,0 @@
module: ""

View File

@ -1,2 +0,0 @@
# dagger universe
alpha.dagger.io

View File

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

View File

@ -0,0 +1,23 @@
plan:
package: ./azure/resourcegroup/tests
name: azure-resourcegroup
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age:
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
enc: |
-----BEGIN AGE ENCRYPTED FILE-----
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSAwcVNxbzdlRHczM3hoSlFB
OCtid2ZyNDZsMmRYeXRJM0hmY09rUWFjanpFClNjUnFXT09yb3BJMmJKNXN1MUIw
eTNIcmZKTG5YR0h6a0UxL0lIeFRBQkEKLS0tIHk4TFRYZkdmVGFWM3lWQ0pwcmx1
TWlwSE9KTFlod21qbm5jQUdsZXVTT3cK7HMCg+rmRPy3d+uihLMPg7SvxVI7Xyr5
Jv6BZJovEyX8PaB/dozzCwGMsGB4fALG2TRNbgskjR0LTGUgzv+yhQ==
-----END AGE ENCRYPTED FILE-----
lastmodified: "2021-08-11T13:13:45Z"
mac: ENC[AES256_GCM,data:lldSGzZoJV4V56chs0Iue+gCBqvwViRY4ZeY4MajyeNBTH6i/k3YXGEZ1lI4suXLyf4BABILMQz0Y34G9oPk8cBWgPx4ZP0iCpvVa/H06xVkBVfntym7p/GWkNsOGiU3KpdGwD/0LLdjDOmL3vKbxNrpS7RvvTgQQtI4+jXtKEc=,iv:vB6P7SPT77ZOEAjTyOO6oSWRWUUWTrC4ekgT5kXvofQ=,tag:ucfzyP9V6HIfIlI8pMDROg==,type:str]
pgp: []
encrypted_suffix: secret
version: 3.7.1

View File

@ -3,7 +3,8 @@ package azure
import ( import (
"alpha.dagger.io/dagger" "alpha.dagger.io/dagger"
"alpha.dagger.io/dagger/op" "alpha.dagger.io/docker"
"alpha.dagger.io/os"
) )
//Azure Config shared by all Azure packages //Azure Config shared by all Azure packages
@ -23,22 +24,21 @@ import (
// Azure Config // Azure Config
config: #Config config: #Config
#up: [ // Container image
op.#FetchContainer & { os.#Container & {
ref: "mcr.microsoft.com/azure-cli" image: docker.#Pull & {
}, from: "mcr.microsoft.com/azure-cli"
}
always: true
op.#Exec & { command: """
args: ["sh", "-c", 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)"
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
mount: "/run/secrets/appId": secret: config.appId secret: "/run/secrets/tenantId": config.tenantId
mount: "/run/secrets/password": secret: config.password secret: "/run/secrets/subscriptionId": config.subscriptionId
mount: "/run/secrets/tenantId": secret: config.tenantId }
mount: "/run/secrets/subscriptionId": secret: config.subscriptionId
},
]
} }

View File

@ -1,8 +1,8 @@
package resourcegroup package resourcegroup
import ( import (
"alpha.dagger.io/os"
"alpha.dagger.io/azure" "alpha.dagger.io/azure"
"alpha.dagger.io/os"
) )
// Create a resource group // Create a resource group
@ -21,9 +21,6 @@ import (
image: azure.#CLI & { image: azure.#CLI & {
"config": config "config": config
} }
// Path of the shell to execute
shell: path: "/bin/bash"
always: true always: true
command: """ command: """

View File

@ -185,6 +185,7 @@ setup() {
assert_success assert_success
} }
# @test "azure-resourcegroup" { @test "azure-resourcegroup" {
# dagger -e azure-resourcegroup up skip "Azure CI infra not implemented yet - manually tested and working"
# } #dagger -e azure-resourcegroup up
}