cue modules: move stdlib to pkg/alpha.dagger.io

In preparation for Europa, we will vendor multiple CUE modules:

- `pkg/alpha.dagger.io`: legacy non-europa packages
- `pkg/dagger.io`: core Europa packages
- `pkg/universe.dagger.io`: Europa universe

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2022-01-11 12:40:02 -08:00
parent e5316f3a1e
commit 282759c0e5
277 changed files with 33 additions and 31 deletions

View File

@@ -0,0 +1,53 @@
// Azure base package
package azure
import (
"alpha.dagger.io/dagger"
"alpha.dagger.io/docker"
"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
// 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
// Azure CLI version to install
version: string | *defaultVersion
// Container image
os.#Container & {
image: docker.#Pull & {
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
"/run/secrets/password": config.password
"/run/secrets/tenantId": config.tenantId
"/run/secrets/subscriptionId": config.subscriptionId
}
}
}

View File

@@ -0,0 +1,48 @@
package resourcegroup
import (
"alpha.dagger.io/azure"
"alpha.dagger.io/os"
"alpha.dagger.io/dagger"
)
// Create a resource group
#ResourceGroup: {
// Azure Config
config: azure.#Config
// ResourceGroup name
rgName: string & dagger.#Input
// ResourceGroup location
rgLocation: string & dagger.#Input
// ResourceGroup Id
id: string & dagger.#Output
// Container image
ctr: os.#Container & {
image: azure.#CLI & {
"config": config
}
always: true
command: """
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: ({
os.#File & {
from: ctr
path: "/resourceGroupId"
}
}).contents
}

View File

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

View File

@@ -0,0 +1,79 @@
package staticwebapp
import (
"alpha.dagger.io/azure"
"alpha.dagger.io/os"
"alpha.dagger.io/dagger"
)
// Create a static web app
#StaticWebApp: {
// Azure Config
config: azure.#Config
// ResourceGroup name in which to create static webapp
rgName: string & dagger.#Input
// StaticWebApp location
stappLocation: string & dagger.#Input
// StaticWebApp name
stappName: string & dagger.#Input
// GitHubRepository URL
remote: string & dagger.#Input
// GitHub Branch
ref: *"main" | string & dagger.#Input
// Location of your application code
appLocation: *"/" | string & dagger.#Input
// Location of your build artifacts
buildLocation: *"build" | string & dagger.#Input
// GitHub Personal Access Token
authToken: dagger.#Secret & dagger.#Input
// DefaultHostName generated by Azure
defaultHostName: string & dagger.#Output
// Container image
ctr: os.#Container & {
image: azure.#CLI & {
"config": config
}
always: true
command: #"""
az staticwebapp create -n "$AZURE_STATICWEBAPP_NAME" \
-g "$AZURE_DEFAULTS_GROUP" \
-l "$AZURE_DEFAULTS_LOCATION" \
-s "$GIT_URL" \
-b "$GIT_BRANCH" \
-t "$(cat /run/secrets/git_pat)" \
--app-location "$APP_LOCATION" \
--output-location "$BUILD_LOCATION" | jq -r '.defaultHostname' | tr -d "\n" > /defaultHostName
"""#
secret: "/run/secrets/git_pat": authToken
env: {
AZURE_DEFAULTS_GROUP: rgName
AZURE_DEFAULTS_LOCATION: stappLocation
AZURE_STATICWEBAPP_NAME: stappName
GIT_URL: remote
GIT_BRANCH: ref
APP_LOCATION: appLocation
BUILD_LOCATION: buildLocation
}
}
// DefaultHostName generated by Azure
defaultHostName: ({
os.#File & {
from: ctr
path: "/defaultHostName"
}
}).contents
}

View File

@@ -0,0 +1,31 @@
package staticwebapp
import (
"alpha.dagger.io/azure"
"alpha.dagger.io/azure/resourcegroup"
"alpha.dagger.io/azure/staticwebapp"
"alpha.dagger.io/random"
"strings"
)
TestConfig: azConfig: azure.#Config & {
}
TestSuffix: random.#String & {
seed: "azrg"
}
TestRG: resourcegroup.#ResourceGroup & {
config: TestConfig.azConfig
rgName: "rg-test-\(TestSuffix.out)"
rgLocation: "eastus2"
}
// rgName is obtained from above TestRG
TestSWA: staticwebapp.#StaticWebApp & {
config: TestRG.config
rgName: "\(strings.Split(TestRG.id, "/")[4])"
stappLocation: "eastus2"
stappName: "stapp-test-\(TestSuffix.out)"
remote: "https://github.com/sujaypillai/todoapp"
}

View File

@@ -0,0 +1,52 @@
package storage
import (
"alpha.dagger.io/azure"
"alpha.dagger.io/os"
"alpha.dagger.io/dagger"
)
// Create a storage account
#StorageAccount: {
// Azure Config
config: azure.#Config
// ResourceGroup name
rgName: string & dagger.#Input
// StorageAccount location
stLocation: string & dagger.#Input
// StorageAccount name
stName: string & dagger.#Input
// StorageAccount Id
id: string & dagger.#Output
// Container image
ctr: os.#Container & {
image: azure.#CLI & {
"config": config
}
always: true
command: """
az storage account create -n "$AZURE_STORAGE_ACCOUNT" -g "$AZURE_DEFAULTS_GROUP" -l "$AZURE_DEFAULTS_LOCATION"
az storage account show -n "$AZURE_STORAGE_ACCOUNT" -g "$AZURE_DEFAULTS_GROUP" --query "id" -o json | jq -r . | tr -d "\n" > /storageAccountId
"""
env: {
AZURE_DEFAULTS_GROUP: rgName
AZURE_DEFAULTS_LOCATION: stLocation
AZURE_STORAGE_ACCOUNT: stName
}
}
// StorageAccount Id
id: ({
os.#File & {
from: ctr
path: "/storageAccountId"
}
}).contents
}

View File

@@ -0,0 +1,28 @@
package storage
import (
"alpha.dagger.io/azure"
"alpha.dagger.io/azure/resourcegroup"
"alpha.dagger.io/azure/storage"
"alpha.dagger.io/random"
)
TestConfig: azureConfig: azure.#Config & {
}
TestSuffix: random.#String & {
seed: "azst"
}
TestRG: resourcegroup.#ResourceGroup & {
config: TestConfig.azureConfig
rgName: "rg-test-\(TestSuffix.out)"
rgLocation: "eastus2"
}
TestStorage: storage.#StorageAccount & {
config: TestConfig.azureConfig
rgName: "rg-test-ahkkzwyoaucw"
stLocation: "eastus2"
stName: "st\(TestSuffix.out)001"
}