Adding support for azure and create a resource group
Signed-off-by: Sujay Pillai <sujayopillai@gmail.com>
This commit is contained in:
parent
eadd075254
commit
5908aa628e
@ -9,6 +9,8 @@
|
||||
- [aws/elb](./aws/elb.md) - AWS Elastic Load Balancer (ELBv2)
|
||||
- [aws/rds](./aws/rds.md) - AWS Relational Database Service (RDS)
|
||||
- [aws/s3](./aws/s3.md) - AWS Simple Storage Service
|
||||
- [azure](./azure/README.md) - Azure base package
|
||||
- [azure/resourcegroup](./azure/resourcegroup.md) - -
|
||||
- [dagger](./dagger/README.md) - Dagger core types
|
||||
- [dagger/op](./dagger/op.md) - op: low-level operations for Dagger processing pipelines
|
||||
- [docker](./docker/README.md) - Docker container operations
|
||||
|
45
docs/reference/universe/azure/README.md
Normal file
45
docs/reference/universe/azure/README.md
Normal file
@ -0,0 +1,45 @@
|
||||
---
|
||||
sidebar_label: azure
|
||||
---
|
||||
|
||||
# alpha.dagger.io/azure
|
||||
|
||||
Azure base package
|
||||
|
||||
```cue
|
||||
import "alpha.dagger.io/azure"
|
||||
```
|
||||
|
||||
## azure.#CLI
|
||||
|
||||
Azure Cli to be used by all Azure packages
|
||||
|
||||
### azure.#CLI Inputs
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------- |:-------------: |:-------------: |
|
||||
|*config.tenantId* | `dagger.#Secret` |AZURE tenant id |
|
||||
|*config.subscriptionId* | `dagger.#Secret` |AZURE subscription id |
|
||||
|*config.appId* | `dagger.#Secret` |AZURE app id for the service principal used |
|
||||
|*config.password* | `dagger.#Secret` |AZURE password for the service principal used |
|
||||
|
||||
### azure.#CLI Outputs
|
||||
|
||||
_No output._
|
||||
|
||||
## azure.#Config
|
||||
|
||||
Azure Config shared by all Azure packages
|
||||
|
||||
### azure.#Config Inputs
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------- |:-------------: |:-------------: |
|
||||
|*tenantId* | `dagger.#Secret` |AZURE tenant id |
|
||||
|*subscriptionId* | `dagger.#Secret` |AZURE subscription id |
|
||||
|*appId* | `dagger.#Secret` |AZURE app id for the service principal used |
|
||||
|*password* | `dagger.#Secret` |AZURE password for the service principal used |
|
||||
|
||||
### azure.#Config Outputs
|
||||
|
||||
_No output._
|
34
docs/reference/universe/azure/resourcegroup.md
Normal file
34
docs/reference/universe/azure/resourcegroup.md
Normal file
@ -0,0 +1,34 @@
|
||||
---
|
||||
sidebar_label: resourcegroup
|
||||
---
|
||||
|
||||
# alpha.dagger.io/azure/resourcegroup
|
||||
|
||||
```cue
|
||||
import "alpha.dagger.io/azure/resourcegroup"
|
||||
```
|
||||
|
||||
## resourcegroup.#ResourceGroup
|
||||
|
||||
Create a resource group
|
||||
|
||||
### resourcegroup.#ResourceGroup Inputs
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------- |:-------------: |:-------------: |
|
||||
|*config.tenantId* | `dagger.#Secret` |AZURE tenant id |
|
||||
|*config.subscriptionId* | `dagger.#Secret` |AZURE subscription id |
|
||||
|*config.appId* | `dagger.#Secret` |AZURE app id for the service principal used |
|
||||
|*config.password* | `dagger.#Secret` |AZURE password for the service principal used |
|
||||
|*rgName* | `string` |ResourceGroup name |
|
||||
|*rgLocation* | `string` |ResourceGroup location |
|
||||
|*ctr.image.config.tenantId* | `dagger.#Secret` |AZURE tenant 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.password* | `dagger.#Secret` |AZURE password for the service principal used |
|
||||
|
||||
### resourcegroup.#ResourceGroup Outputs
|
||||
|
||||
| Name | Type | Description |
|
||||
| ------------- |:-------------: |:-------------: |
|
||||
|*id* | `string` |Resource Id |
|
1
stdlib/.dagger/env/azure-resourcegroup/cue.mod/module.cue
vendored
Normal file
1
stdlib/.dagger/env/azure-resourcegroup/cue.mod/module.cue
vendored
Normal file
@ -0,0 +1 @@
|
||||
module: ""
|
2
stdlib/.dagger/env/azure-resourcegroup/cue.mod/pkg/.gitignore
vendored
Normal file
2
stdlib/.dagger/env/azure-resourcegroup/cue.mod/pkg/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# dagger universe
|
||||
alpha.dagger.io
|
17
stdlib/.dagger/env/azure-resourcegroup/rg.cue
vendored
Normal file
17
stdlib/.dagger/env/azure-resourcegroup/rg.cue
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
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"
|
||||
}
|
44
stdlib/azure/azure.cue
Normal file
44
stdlib/azure/azure.cue
Normal file
@ -0,0 +1,44 @@
|
||||
// Azure base package
|
||||
package azure
|
||||
|
||||
import (
|
||||
"alpha.dagger.io/dagger"
|
||||
"alpha.dagger.io/dagger/op"
|
||||
)
|
||||
|
||||
//Azure Config shared by all Azure packages
|
||||
#Config: {
|
||||
// AZURE tenant id
|
||||
tenantId: dagger.#Secret @dagger(input)
|
||||
// AZURE subscription id
|
||||
subscriptionId: dagger.#Secret @dagger(input)
|
||||
// AZURE app id for the service principal used
|
||||
appId: dagger.#Secret @dagger(input)
|
||||
// AZURE password for the service principal used
|
||||
password: dagger.#Secret @dagger(input)
|
||||
}
|
||||
|
||||
// Azure Cli to be used by all Azure packages
|
||||
#CLI: {
|
||||
// Azure Config
|
||||
config: #Config
|
||||
|
||||
#up: [
|
||||
op.#FetchContainer & {
|
||||
ref: "mcr.microsoft.com/azure-cli"
|
||||
},
|
||||
|
||||
op.#Exec & {
|
||||
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)"
|
||||
"""#,
|
||||
]
|
||||
mount: "/run/secrets/appId": secret: config.appId
|
||||
mount: "/run/secrets/password": secret: config.password
|
||||
mount: "/run/secrets/tenantId": secret: config.tenantId
|
||||
mount: "/run/secrets/subscriptionId": secret: config.subscriptionId
|
||||
},
|
||||
]
|
||||
}
|
42
stdlib/azure/resourcegroup/rg.cue
Normal file
42
stdlib/azure/resourcegroup/rg.cue
Normal file
@ -0,0 +1,42 @@
|
||||
package resourcegroup
|
||||
|
||||
import (
|
||||
"alpha.dagger.io/os"
|
||||
"alpha.dagger.io/azure"
|
||||
)
|
||||
|
||||
// Create a resource group
|
||||
#ResourceGroup: {
|
||||
// Azure Config
|
||||
config: azure.#Config
|
||||
|
||||
// ResourceGroup name
|
||||
rgName: string @dagger(input)
|
||||
|
||||
// ResourceGroup location
|
||||
rgLocation: string @dagger(input)
|
||||
|
||||
// Container image
|
||||
ctr: os.#Container & {
|
||||
image: azure.#CLI & {
|
||||
"config": config
|
||||
}
|
||||
// Path of the shell to execute
|
||||
shell: path: "/bin/bash"
|
||||
|
||||
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
|
||||
"""
|
||||
}
|
||||
|
||||
// Resource Id
|
||||
id: {
|
||||
os.#File & {
|
||||
from: ctr
|
||||
path: "/resourceGroupId"
|
||||
}
|
||||
}.contents @dagger(output)
|
||||
}
|
17
stdlib/azure/resourcegroup/tests/rg.cue
Normal file
17
stdlib/azure/resourcegroup/tests/rg.cue
Normal file
@ -0,0 +1,17 @@
|
||||
package resourcegroup
|
||||
|
||||
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"
|
||||
}
|
@ -184,3 +184,7 @@ setup() {
|
||||
run dagger -w "$DAGGER_SANDBOX" -e terraform input unset TestTerraform.apply.tfvars.input
|
||||
assert_success
|
||||
}
|
||||
|
||||
# @test "azure-resourcegroup" {
|
||||
# dagger -e azure-resourcegroup up
|
||||
# }
|
Reference in New Issue
Block a user