diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5305c6b1..84b6677b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [main] + branches: [ main ] pull_request: - branches: [main] + branches: [ main ] jobs: lint: @@ -76,6 +76,14 @@ jobs: with: go-version: 1.16 + - name: Install Dependencies + run: | + # Cue + export CUE_VERSION="$(grep cue ./go.mod | cut -d' ' -f2)" + export CUE_TARBALL="cue_${CUE_VERSION}_linux_amd64.tar.gz" + echo "Installing cue version $CUE_VERSION" + curl -L https://github.com/cuelang/cue/releases/download/${CUE_VERSION}/${CUE_TARBALL} | sudo tar zxf - -C /usr/local/bin + - name: Install Dependencies run: | # SOPS @@ -177,3 +185,73 @@ jobs: with: name: cypress-videos path: website/cypress/videos + doc: + name: Documentation + runs-on: ubuntu-latest + timeout-minutes: 30 + services: + localstack: + image: localstack/localstack:0.12.16 + env: + SERVICES: s3, cloudformation + LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} + ports: + - 4566:4566 + - 4571:4571 + options: >- + --health-cmd "curl -f http://localhost:4566/health" + --health-start-period 5s + --health-timeout 5s + --health-interval 5s + --health-retries 10 + + steps: + - name: Check out + uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v1 + with: + go-version: 1.16 + + - name: Install Dependencies + run: | + # Cue + export CUE_VERSION="$(grep cue ./go.mod | cut -d' ' -f2)" + export CUE_TARBALL="cue_${CUE_VERSION}_linux_amd64.tar.gz" + echo "Installing cue version $CUE_VERSION" + curl -L https://github.com/cuelang/cue/releases/download/${CUE_VERSION}/${CUE_TARBALL} | sudo tar zxf - -C /usr/local/bin + + - name: Run local registry + run: | + docker run -d -p 5000:5000 --name registry registry:2 + + - name: Write kind echo + run: | + echo 'kind: Cluster + apiVersion: kind.x-k8s.io/v1alpha4 + containerdConfigPatches: + - |- + [plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:5000"] + endpoint = ["http://registry:5000"]' > ./kind-config.yaml + cat ./kind-config.yaml + + - name: Setup Kind Kubernetes Cluster + uses: helm/kind-action@v1.2.0 + with: + config: "./kind-config.yaml" + + - name: Connect registry to cluster + run: | + docker network connect kind registry + + - name: Import Dagger private key + env: + DAGGER_AGE_KEY: ${{ secrets.DAGGER_AGE_KEY }} + run: | + mkdir -p ~/.config/dagger + echo "$DAGGER_AGE_KEY" > ~/.config/dagger/keys.txt + + - name: Documentation Test + run: | + make doc-test diff --git a/.gitignore b/.gitignore index 43cb1378..8a6a6c9c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,7 @@ # Test binary, build with `go test -c` *.test -tests/report.xml +**/*/report.xml # Output of the go coverage tool, specifically when used with LiteIDE *.out @@ -26,3 +26,4 @@ tests/report.xml # node_modules tests/node_modules dist/ +docs/learn/tests/node_modules diff --git a/Makefile b/Makefile index a11c410f..5b6de955 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ shellcheck: lint: shellcheck cuelint golint docslint .PHONY: integration -integration: core-integration universe-test +integration: core-integration universe-test doc-test .PHONY: core-integration core-integration: dagger-debug @@ -48,6 +48,11 @@ universe-test: dagger-debug yarn --cwd "./universe" install DAGGER_BINARY="../cmd/dagger/dagger-debug" yarn --cwd "./universe" test +.PHONY: doc-test +doc-test: dagger-debug + yarn --cwd "./docs/learn/tests" install + DAGGER_BINARY="$(shell pwd)/cmd/dagger/dagger-debug" yarn --cwd "./docs/learn/tests" test + .PHONY: install install: dagger go install ./cmd/dagger diff --git a/docs/learn/1004-first-env.md b/docs/learn/1004-first-env.md index 11b31665..c1307338 100644 --- a/docs/learn/1004-first-env.md +++ b/docs/learn/1004-first-env.md @@ -68,7 +68,7 @@ Although not strictly necessary, for an optimal development experience, we recom If you are new to Cue, we recommend keeping the following resources in browser tabs: -The unofficial but excellent [Cuetorials](https://cuetorials.com/overview/foundations/) in a browser tab, to look up Cue concepts as they appear. +- The unofficial but excellent [Cuetorials](https://cuetorials.com/overview/foundations/) in a browser tab, to look up Cue concepts as they appear. - The official [Cue interactive sandbox](https://cuelang.org/play) for easy experimentation. @@ -130,15 +130,7 @@ In Dagger terms, this component has two essential properties: Let's write the corresponding Cue code to a new file in our package: -```cue title="todoapp/multibucket/source.cue" -package multibucket - -import ( - "alpha.dagger.io/dagger" -) - -// Source code of the sample application -src: dagger.#Artifact & dagger.#Input +```cue file=./tests/multibucket/source.cue title="todoapp/cue.mod/multibucket/source.cue" ``` This code defines a component at the key `src` and specifies that it is both an artifact and an input. @@ -147,17 +139,7 @@ This code defines a component at the key `src` and specifies that it is both an The second component of our plan is the Yarn package built from the app source code: -```cue title="todoapp/multibucket/yarn.cue" -package multibucket - -import ( - "alpha.dagger.io/js/yarn" -) - -// Build the source code using Yarn -app: yarn.#Package & { - source: src -} +```cue file=./tests/multibucket/yarn.cue title="todoapp/cue.mod/multibucket/yarn.cue" ``` Let's break it down: @@ -176,17 +158,7 @@ _FIXME_: this section is not yet available because the [Amazon S3 package](https The third component of our plan is the Netlify site to which the app will be deployed: -```cue title="todoapp/multibucket/netlify.cue" -package multibucket - -import ( - "alpha.dagger.io/netlify" -) - -// Netlify site -site: "netlify": netlify.#Site & { - contents: app.build -} +```cue file=./tests/multibucket/netlify.cue title="todoapp/cue.mod/multibucket/netlify.cue" ``` This component is very similar to the previous one: diff --git a/docs/learn/1006-google-cloud-run.md b/docs/learn/1006-google-cloud-run.md index 071e101e..84c2d997 100644 --- a/docs/learn/1006-google-cloud-run.md +++ b/docs/learn/1006-google-cloud-run.md @@ -43,46 +43,7 @@ mkdir gcpcloudrun ### Create a basic plan -```cue title="todoapp/gcpcloudrun/source.cue" -package gcpcloudrun - -import ( - "alpha.dagger.io/dagger" - "alpha.dagger.io/docker" - "alpha.dagger.io/gcp" - "alpha.dagger.io/gcp/cloudrun" - "alpha.dagger.io/gcp/gcr" -) - -// Source code of the sample application -src: dagger.#Artifact & dagger.#Input - -// GCR full image name -imageRef: string & dagger.#Input - -image: docker.#Build & { - source: src -} - -gcpConfig: gcp.#Config - -creds: gcr.#Credentials & { - config: gcpConfig -} - -push: docker.#Push & { - target: imageRef - source: image - auth: { - username: creds.username - secret: creds.secret - } -} - -deploy: cloudrun.#Service & { - config: gcpConfig - image: push.ref -} +```cue file=./tests/gcpcloudrun/source.cue title="todoapp/cue.mod/gcpcloudrun/source.cue" ``` ## Set up the environment diff --git a/docs/learn/1007-kubernetes.md b/docs/learn/1007-kubernetes.md index f30583cd..77460b9c 100644 --- a/docs/learn/1007-kubernetes.md +++ b/docs/learn/1007-kubernetes.md @@ -159,23 +159,7 @@ kubectl delete -f k8s/ Create a file named `todoapp.cue` and add the following configuration to it. -```cue title="todoapp/kube/todoapp.cue" -package main - -import ( - "alpha.dagger.io/dagger" - "alpha.dagger.io/kubernetes" -) - -// input: kubernetes objects directory to deploy to -// set with `dagger input dir manifest ./k8s -e kube` -manifest: dagger.#Artifact & dagger.#Input - -// Deploy the manifest to a kubernetes cluster -todoApp: kubernetes.#Resources & { - "kubeconfig": kubeconfig - source: manifest -} +```cue file=tests/kube-kind/basic/todoapp.cue title="todoapp/kube/todoapp.cue" ``` This defines a `todoApp` variable containing the Kubernetes objects used to create a todoapp deployment. It also @@ -193,15 +177,7 @@ The following `config.cue` defines: - `kubeconfig` a generic value created to embed this string `kubeconfig` value -```cue title="todoapp/kube/config.cue" -package main - -import ( - "alpha.dagger.io/dagger" -) - -// set with `dagger input text kubeconfig -f "$HOME"/.kube/config -e kube` -kubeconfig: string & dagger.#Input +```cue file=tests/kube-kind/config.cue title="todoapp/kube/config.cue" ``` @@ -215,25 +191,7 @@ The below `config.cue` defines: - `gkeConfig`: transform a `gcpConfig` to a readable format for `kubernetes.#Resources.kubeconfig` using `alpha.dagger.io/gcp/gke` -```cue title="todoapp/kube/config.cue" -package main - -import ( - "alpha.dagger.io/gcp" - "alpha.dagger.io/gcp/gke" -) - -// Value created for generic reference of `kubeconfig` in `todoapp.cue` -kubeconfig: gkeConfig.kubeconfig - -// gcpConfig used for Google connection -gcpConfig: gcp.#Config - -// gkeConfig used for deployment -gkeConfig: gke.#KubeConfig & { - // config field references `gkeConfig` value to set in once - config: gcpConfig -} +```cue file=tests/kube-gcp/basic/config.cue title="todoapp/kube/config.cue" ``` @@ -247,25 +205,7 @@ The below `config.cue` defines: - `eksConfig`, transform a `awsConfig` to a readable format for `kubernetes.#Resources.kubeconfig` using `alpha.dagger.io/aws/eks` -```cue title="todoapp/kube/config.cue" -package main - -import ( - "alpha.dagger.io/aws" - "alpha.dagger.io/aws/eks" -) - -// Value created for generic reference of `kubeconfig` in `todoapp.cue` -kubeconfig: eksConfig.kubeconfig - -// awsConfig for Amazon connection -awsConfig: aws.#Config - -// eksConfig used for deployment -eksConfig: eks.#KubeConfig & { - // config field references `gkeConfig` value to set in once - config: awsConfig -} +```cue file=tests/kube-aws/basic/config.cue title="todoapp/kube/config.cue" ``` @@ -458,64 +398,7 @@ Let's see how to deploy an image locally and push it to the local cluster - `remoteImage`, push an image to the registry - `kustomization`, apply kustomization to image -```cue title="todoapp/kube/todoapp.cue" -package main - -import ( - "encoding/yaml" - - "alpha.dagger.io/dagger" - "alpha.dagger.io/docker" - "alpha.dagger.io/kubernetes" - "alpha.dagger.io/kubernetes/kustomize" -) - -// input: source code repository, must contain a Dockerfile -// set with `dagger input dir repository . -e kube` -repository: dagger.#Artifact & dagger.#Input - -// Registry to push images to -registry: string & dagger.#Input -tag: "test-kind" - -// input: kubernetes objects directory to deploy to -// set with `dagger input dir manifest ./k8s -e kube` -manifest: dagger.#Artifact & dagger.#Input - -// Todoapp deployment pipeline -todoApp: { - // Build the image from repositoru artifact - image: docker.#Build & { - source: repository - } - - // Push image to registry - remoteImage: docker.#Push & { - target: "\(registry):\(tag)" - source: image - } - - // Update the image from manifest to use the deployed one - kustomization: kustomize.#Kustomize & { - source: manifest - - // Convert CUE to YAML. - kustomization: yaml.Marshal({ - resources: ["deployment.yaml", "service.yaml"] - - images: [{ - name: "public.ecr.aws/j7f8d3t2/todoapp" - newName: remoteImage.ref - }] - }) - } - - // Deploy the customized manifest to a kubernetes cluster - kubeSrc: kubernetes.#Resources & { - "kubeconfig": kubeconfig - source: kustomization - } -} +```cue file=tests/kube-kind/deployment/todoapp.cue title="todoapp/kube/todoapp.cue" ``` @@ -529,34 +412,9 @@ The two files have to be edited to do so. `kube/config.cue` configuration has following change: -- definition of a new `ecrCreds` value that contains ecr credentials for remote image push to GCR +- definition of a new `gcrCreds` value that contains ecr credentials for remote image push to GCR -```cue title="todoapp/kube/config.cue" -package main - -import ( - "alpha.dagger.io/gcp" - "alpha.dagger.io/gcp/gcr" - "alpha.dagger.io/gcp/gke" -) - -// Value created for generic reference of `kubeconfig` in `todoapp.cue` -kubeconfig: gkeConfig.kubeconfig - -// gcpConfig used for Google connection -gcpConfig: gcp.#Config - -// gkeConfig used for deployment -gkeConfig: gke.#KubeConfig & { - // config field references `gkeConfig` value to set in once - config: gcpConfig -} - -// gcrCreds used for remote image push -gcrCreds: gcr.#Credentials & { - // config field references `gcpConfig` value to set in once - config: gcpConfig -} +```cue file=tests/kube-gcp/deployment/config.cue title="todoapp/kube/config.cue" ``` `kube/todoapp.cue`, on the other hand, faces these changes: @@ -567,68 +425,7 @@ gcrCreds: gcr.#Credentials & { - `remoteImage`, push an image to the registry - `kustomization`, apply kustomization to image -```cue title="todoapp/kube/todoapp.cue" -package main - -import ( - "encoding/yaml" - - "alpha.dagger.io/dagger" - "alpha.dagger.io/docker" - "alpha.dagger.io/kubernetes" - "alpha.dagger.io/kubernetes/kustomize" -) - -// input: source code repository, must contain a Dockerfile -// set with `dagger input dir repository . -e kube` -repository: dagger.#Artifact & dagger.#Input - -// GCR registry to push images to -registry: string & dagger.#Input -tag: "test-gcr" - -// source of Kube config file. -// set with `dagger input dir manifest ./k8s -e kube` -manifest: dagger.#Artifact & dagger.#Input - -// Declarative name -todoApp: { - // Build an image from the project repository - image: docker.#Build & { - source: repository - } - - // Push the image to a remote registry - remoteImage: docker.#Push & { - target: "\(registry):\(tag)" - source: image - auth: { - username: gcrCreds.username - secret: gcrCreds.secret - } - } - - // Update the image of the deployment to the deployed image - kustomization: kustomize.#Kustomize & { - source: manifest - - // Convert CUE to YAML. - kustomization: yaml.Marshal({ - resources: ["deployment.yaml", "service.yaml"] - - images: [{ - name: "public.ecr.aws/j7f8d3t2/todoapp" - newName: remoteImage.ref - }] - }) - } - - // Value created for generic reference of `kubeconfig` in `todoapp.cue` - kubeSrc: kubernetes.#Resources & { - "kubeconfig": kubeconfig - source: kustomization - } -} +```cue file=tests/kube-gcp/deployment/todoapp.cue title="todoapp/kube/todoapp.cue" ``` @@ -643,32 +440,7 @@ The two files have to be edited to do so. - definition of a new `ecrCreds` value that contains ecr credentials for remote image push to ECR -```cue title="todoapp/kube/config.cue" -package main - -import ( - "alpha.dagger.io/aws" - "alpha.dagger.io/aws/eks" - "alpha.dagger.io/aws/ecr" -) - -// Value created for generic reference of `kubeconfig` in `todoapp.cue` -kubeconfig: eksConfig.kubeconfig - -// awsConfig for Amazon connection -awsConfig: aws.#Config - -// eksConfig used for deployment -eksConfig: eks.#KubeConfig & { - // config field references `awsConfig` value to set in once - config: awsConfig -} - -// ecrCreds used for remote image push -ecrCreds: ecr.#Credentials & { - // config field references `awsConfig` value to set in once - config: awsConfig -} +```cue file=tests/kube-aws/deployment/config.cue title="todoapp/kube/config.cue" ``` `kube/todoapp.cue`, on the other hand, faces these changes: @@ -679,67 +451,7 @@ ecrCreds: ecr.#Credentials & { - `remoteImage`, push an image to the registry - `kustomization`, apply kustomization to image -```cue title="todoapp/kube/todoapp.cue" -package main - -import ( - "encoding/yaml" - - "alpha.dagger.io/dagger" - "alpha.dagger.io/docker" - "alpha.dagger.io/kubernetes" - "alpha.dagger.io/kubernetes/kustomize" -) - -// input: source code repository, must contain a Dockerfile -// set with `dagger input dir repository . -e kube` -repository: dagger.#Artifact & dagger.#Input - -// ECR registry to push images to -registry: string & dagger.#Input -tag: "test-ecr" - -// source of Kube config file. -// set with `dagger input dir manifest ./k8s -e kube` -manifest: dagger.#Artifact & dagger.#Input - -todoApp: { - // Build an image from the project repository - image: docker.#Build & { - source: repository - } - - // Push the image to a remote registry - remoteImage: docker.#Push & { - target: "\(registry):\(tag)" - source: image - auth: { - username: ecrCreds.username - secret: ecrCreds.secret - } - } - - // Update the image of the deployment to the deployed image - kustomization: kustomize.#Kustomize & { - source: manifest - - // Convert CUE to YAML. - kustomization: yaml.Marshal({ - resources: ["deployment.yaml", "service.yaml"] - - images: [{ - name: "public.ecr.aws/j7f8d3t2/todoapp" - newName: remoteImage.ref - }] - }) - } - - // Value created for generic reference of `kubeconfig` in `todoapp.cue` - kubeSrc: kubernetes.#Resources & { - "kubeconfig": kubeconfig - source: kustomization - } -} +```cue file=tests/kube-aws/deployment/todoapp.cue title="todoapp/kube/todoapp.cue" ``` @@ -833,96 +545,17 @@ of the language features. ### Convert Kubernetes objects to CUE -First, let's create re-usable definitions for the `deployment` and the `service` to remove a lot of boilerplate -and repetition. +First, let's create re-usable definitions for the `deployment` and the `service` to remove a lot of boilerplate and +repetition. Let's define a re-usable `#Deployment` definition in `kube/deployment.cue`. -```cue title="todoapp/kube/deployment.cue" -package main - -// Deployment template containing all the common boilerplate shared by -// deployments of this application. -#Deployment: { - // Name of the deployment. This will be used to label resources automatically - // and generate selectors. - name: string - - // Container image. - image: string - - // 80 is the default port. - port: *80 | int - - // 1 is the default, but we allow any number. - replicas: *1 | int - - // Deployment manifest. Uses the name, image, port and replicas above to - // generate the resource manifest. - manifest: { - apiVersion: "apps/v1" - kind: "Deployment" - metadata: { - "name": name - labels: app: name - } - spec: { - "replicas": replicas - selector: matchLabels: app: name - template: { - metadata: labels: app: name - spec: containers: [{ - "name": name - "image": image - ports: [{ - containerPort: port - }] - }] - } - } - } -} +```cue file=tests/kube-kind/cue-manifest/deployment.cue title="todoapp/kube/deployment.cue" ``` Indeed, let's also define a re-usable `#Service` definition in `kube/service.cue`. -```cue title="todoapp/kube/service.cue" -package main - -// Service template containing all the common boilerplate shared by -// services of this application. -#Service: { - // Name of the service. This will be used to label resources automatically - // and generate selector. - name: string - - // NodePort is the default service type. - type: *"NodePort" | "LoadBalancer" | "ClusterIP" | "ExternalName" - - // Ports where the service should listen - ports: [string]: number - - // Service manifest. Uses the name, type and ports above to - // generate the resource manifest. - manifest: { - apiVersion: "v1" - kind: "Service" - metadata: { - "name": "\(name)-service" - labels: app: name - } - spec: { - "type": type - "ports": [ - for k, v in ports { - "name": k - port: v - }, - ] - selector: app: name - } - } -} +```cue file=tests/kube-kind/cue-manifest/service.cue title="todoapp/kube/service.cue" ``` ### Generate Kubernetes manifest @@ -932,36 +565,7 @@ without having boilerplate nor repetition. Create a new definition named `#AppManifest` that will generate the YAML in `kube/manifest.cue`. -```cue title="todoapp/kube/manifest.cue" -package main - -import ( - "encoding/yaml" -) - -// Define and generate kubernetes deployment to deploy to kubernetes cluster -#AppManifest: { - // Name of the application - name: string - - // Image to deploy to - image: string - - // Define a kubernetes deployment object - deployment: #Deployment & { - "name": name - "image": image - } - - // Define a kubernetes service object - service: #Service & { - "name": name - ports: "http": deployment.port - } - - // Merge definitions and convert them back from CUE to YAML - manifest: yaml.MarshalStream([deployment.manifest, service.manifest]) -} +```cue file=tests/kube-kind/cue-manifest/manifest.cue title="todoapp/kube/manifest.cue" ``` ### Update manifest @@ -973,7 +577,8 @@ You can now remove the `manifest` input in `kube/todoapp.cue` and instead use th - removal of unused imported `encoding/yaml` and `kustomize` packages. - removal of `manifest` input that is doesn't need anymore. - removal of `kustomization` to replace it with `#AppManifest` definition. -- Update `kubeSrc` to use `manifest` field instead of `source` because we don't send Kubernetes manifest of `dagger.#Artifact` type anymore. +- Update `kubeSrc` to use `manifest` field instead of `source` because we don't send Kubernetes manifest + of `dagger.#Artifact` type anymore. -```cue title="todoapp/kube/todoapp.cue" -package main - -import ( - "alpha.dagger.io/dagger" - "alpha.dagger.io/docker" - "alpha.dagger.io/kubernetes" -) - -// input: source code repository, must contain a Dockerfile -// set with `dagger input dir repository . -e kube` -repository: dagger.#Artifact & dagger.#Input - -// Registry to push images to -registry: string & dagger.#Input -tag: "test-kind" - -// Todoapp deployment pipeline -todoApp: { - // Build the image from repositoru artifact - image: docker.#Build & { - source: repository - } - - // Push image to registry - remoteImage: docker.#Push & { - target: "\(registry):\(tag)" - source: image - } - - // Generate deployment manifest - deployment: #AppManifest & { - name: "todoapp" - image: remoteImage.ref - } - - // Deploy the customized manifest to a kubernetes cluster - kubeSrc: kubernetes.#Resources & { - "kubeconfig": kubeconfig - manifest: deployment.manifest - } -} +```cue file=tests/kube-kind/cue-manifest/todoapp.cue title="todoapp/kube/todoapp.cue" ``` -```cue title="todoapp/kube/todoapp.cue" -package main - -import ( - "alpha.dagger.io/dagger" - "alpha.dagger.io/docker" - "alpha.dagger.io/kubernetes" -) - -// input: source code repository, must contain a Dockerfile -// set with `dagger input dir repository . -e kube` -repository: dagger.#Artifact & dagger.#Input - -// GCR registry to push images to -registry: string & dagger.#Input -tag: "test-gcr" - -// Todoapp deployment pipeline -todoApp: { - // Build the image from repositoru artifact - image: docker.#Build & { - source: repository - } - - // Push image to registry - remoteImage: docker.#Push & { - target: "\(registry):\(tag)" - source: image - auth: { - username: gcrCreds.username - secret: gcrCreds.secret - } - } - - // Generate deployment manifest - deployment: #AppManifest & { - name: "todoapp" - image: remoteImage.ref - } - - // Deploy the customized manifest to a kubernetes cluster - kubeSrc: kubernetes.#Resources & { - "kubeconfig": kubeconfig - manifest: deployment.manifest - } -} +```cue file=tests/kube-gcp/cue-manifest/todoapp.cue title="todoapp/kube/todoapp.cue" ``` -```cue title="todoapp/kube/todoapp.cue" -package main - -import ( - "alpha.dagger.io/dagger" - "alpha.dagger.io/docker" - "alpha.dagger.io/kubernetes" -) - -// input: source code repository, must contain a Dockerfile -// set with `dagger input dir repository . -e kube` -repository: dagger.#Artifact & dagger.#Input - -// ECR registry to push images to -registry: string & dagger.#Input -tag: "test-ecr" - -// Todoapp deployment pipeline -todoApp: { - // Build the image from repositoru artifact - image: docker.#Build & { - source: repository - } - - // Push image to registry - remoteImage: docker.#Push & { - target: "\(registry):\(tag)" - source: image - auth: { - username: ecrCreds.username - secret: ecrCreds.secret - } - } - - // Generate deployment manifest - deployment: #AppManifest & { - name: "todoapp" - image: remoteImage.ref - } - - // Deploy the customized manifest to a kubernetes cluster - kubeSrc: kubernetes.#Resources & { - "kubeconfig": kubeconfig - manifest: deployment.manifest - } -} +```cue file=tests/kube-aws/cue-manifest/todoapp.cue title="todoapp/kube/todoapp.cue" ``` diff --git a/docs/learn/1008-aws-cloudformation.md b/docs/learn/1008-aws-cloudformation.md index 63ef450e..7884bcb4 100644 --- a/docs/learn/1008-aws-cloudformation.md +++ b/docs/learn/1008-aws-cloudformation.md @@ -66,68 +66,7 @@ The idea here is to follow best practices in [S3 buckets](https://docs.aws.amazo Create a file named `template.cue` and add the following configuration to it. -```cue title="todoapp/cloudformation/template.cue" -package cloudformation - -// inlined s3 cloudformation template as a string -template: """ - { - "AWSTemplateFormatVersion": "2010-09-09", - "Resources": { - "S3Bucket": { - "Type": "AWS::S3::Bucket", - "Properties": { - "AccessControl": "PublicRead", - "WebsiteConfiguration": { - "IndexDocument": "index.html", - "ErrorDocument": "error.html" - } - }, - "DeletionPolicy": "Retain" - }, - "BucketPolicy": { - "Type": "AWS::S3::BucketPolicy", - "Properties": { - "PolicyDocument": { - "Id": "MyPolicy", - "Version": "2012-10-17", - "Statement": [ - { - "Sid": "PublicReadForGetBucketObjects", - "Effect": "Allow", - "Principal": "*", - "Action": "s3:GetObject", - "Resource": { - "Fn::Join": [ - "", - [ - "arn:aws:s3:::", - { - "Ref": "S3Bucket" - }, - "/*" - ] - ] - } - } - ] - }, - "Bucket": { - "Ref": "S3Bucket" - } - } - } - }, - "Outputs": { - "Name": { - "Value": { - "Fn::GetAtt": ["S3Bucket", "Arn"] - }, - "Description": "Name S3 Bucket" - } - } - } -""" +```cue file=./tests/cloudformation/template.cue title="todoapp/cloudformation/template.cue" ``` ##### 2. Cloudformation relay @@ -164,15 +103,7 @@ The config values are all part of the `aws` relay. Regarding this package, as yo Let's implement the first step, use the `aws.#Config` relay, and request its first inputs: the region to deploy and the AWS credentials. -```cue title="todoapp/cloudformation/source.cue" -package cloudformation - -import ( - "alpha.dagger.io/aws" -) - -// AWS account: credentials and region -awsConfig: aws.#Config +```cue file=./tests/cloudformation/source-begin.cue title="todoapp/cloudformation/source.cue" ``` This defines: @@ -214,33 +145,7 @@ dagger up -e cloudformation # Try to run the plan. As expected, we encounter a f Now that we have the `config` definition properly configured, let's modify the Cloudformation one: -```cue title="todoapp/cloudformation/source.cue" -package cloudformation - -import ( - "alpha.dagger.io/aws" - "alpha.dagger.io/dagger" - "alpha.dagger.io/random" - "alpha.dagger.io/aws/cloudformation" -) - -// AWS account: credentials and region -awsConfig: aws.#Config - -// Create a random suffix -suffix: random.#String & { - seed: "" -} - -// Query the Cloudformation stackname, or create one with a random suffix to keep unicity -cfnStackName: *"stack-\(suffix.out)" | string & dagger.#Input - -// AWS Cloudformation stdlib -cfnStack: cloudformation.#Stack & { - config: awsConfig - stackName: cfnStackName - source: template -} +```cue file=./tests/cloudformation/source-end.cue title="todoapp/cloudformation/source.cue" ``` This defines: @@ -359,35 +264,9 @@ We will create a new `convert.cue` file to process the conversion import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; - - - -```cue title="todoapp/cloudformation/convert.cue" -package cloudformation -import "encoding/json" - -s3Template: json.Unmarshal(template) +```cue file=./tests/cloudformation/template/convert.cue title="todoapp/cloudformation/convert.cue" ``` - - - -```cue title="todoapp/cloudformation/convert.cue" -package cloudformation -import "encoding/yaml" - -s3Template: yaml.Unmarshal(template) -``` - - - - This defines: - `s3Template`: contains the unmarshalled template. @@ -428,74 +307,7 @@ rm cloudformation/convert.cue Open `cloudformation/template.cue` and append below elements with copied Cue definition of the JSON: -```cue title="todoapp/cloudformation/template.cue" -// Add this line, to make it part to the cloudformation template -package cloudformation -import "encoding/json" - -// Wrap exported Cue in previous point inside the `s3` value -s3: { - "AWSTemplateFormatVersion": "2010-09-09", - "Outputs": { - "Name": { - "Description": "Name S3 Bucket", - "Value": { - "Fn::GetAtt": [ - "S3Bucket", - "Arn" - ] - } - } - }, - "Resources": { - "BucketPolicy": { - "Properties": { - "Bucket": { - "Ref": "S3Bucket" - }, - "PolicyDocument": { - "Id": "MyPolicy", - "Statement": [ - { - "Action": "s3:GetObject", - "Effect": "Allow", - "Principal": "*", - "Resource": { - "Fn::Join": [ - "", - [ - "arn:aws:s3:::", - { - "Ref": "S3Bucket" - }, - "/*" - ] - ] - }, - "Sid": "PublicReadForGetBucketObjects" - } - ], - "Version": "2012-10-17" - } - }, - "Type": "AWS::S3::BucketPolicy" - }, - "S3Bucket": { - "DeletionPolicy": "Retain", - "Properties": { - "AccessControl": "PublicRead", - "WebsiteConfiguration": { - "ErrorDocument": "error.html", - "IndexDocument": "index.html" - } - }, - "Type": "AWS::S3::Bucket" - } - } -} - -// Template contains the marshalled value of the s3 template -template: json.Marshal(s3) +```cue file=./tests/cloudformation/template/template-begin.cue title="todoapp/cloudformation/template.cue" ``` We're using the built-in `json.Marshal` function to convert CUE back to JSON, so Cloudformation still receives the same template. @@ -510,104 +322,12 @@ Now that the template is defined in CUE, we can use the language to add more fle Let's define a re-usable `#Deployment` definition in `todoapp/cloudformation/deployment.cue`: -```cue title="todoapp/cloudformation/deployment.cue" -package cloudformation - -#Deployment: { - - // Bucket's output description - description: string - - // index file - indexDocument: *"index.html" | string - - // error file - errorDocument: *"error.html" | string - - // Bucket policy version - version: *"2012-10-17" | string - - // Retain as default deletion policy. Delete is also accepted but requires the s3 bucket to be empty - deletionPolicy: *"Retain" | "Delete" - - // Canned access control list (ACL) that grants predefined permissions to the bucket - accessControl: *"PublicRead" | "Private" | "PublicReadWrite" | "AuthenticatedRead" | "LogDeliveryWrite" | "BucketOwnerRead" | "BucketOwnerFullControl" | "AwsExecRead" - - // Modified copy of s3 value in `todoapp/cloudformation/template.cue` - template: { - "AWSTemplateFormatVersion": "2010-09-09", - "Outputs": { - "Name": { - "Description": description, - "Value": { - "Fn::GetAtt": [ - "S3Bucket", - "Arn" - ] - } - } - }, - "Resources": { - "BucketPolicy": { - "Properties": { - "Bucket": { - "Ref": "S3Bucket" - }, - "PolicyDocument": { - "Id": "MyPolicy", - "Statement": [ - { - "Action": "s3:GetObject", - "Effect": "Allow", - "Principal": "*", - "Resource": { - "Fn::Join": [ - "", - [ - "arn:aws:s3:::", - { - "Ref": "S3Bucket" - }, - "/*" - ] - ] - }, - "Sid": "PublicReadForGetBucketObjects" - } - ], - "Version": version - } - }, - "Type": "AWS::S3::BucketPolicy" - }, - "S3Bucket": { - "DeletionPolicy": deletionPolicy, - "Properties": { - "AccessControl": "PublicRead", - "WebsiteConfiguration": { - "ErrorDocument": errorDocument, - "IndexDocument": indexDocument - } - }, - "Type": "AWS::S3::Bucket" - } - } - } -} +```cue file=./tests/cloudformation/template/deployment.cue title="todoapp/cloudformation/deployment.cue" ``` `template.cue` can be rewritten as follows: -```cue title="todoapp/cloudformation/template.cue" -package cloudformation -import "encoding/json" - -s3: #Deployment & { - description: "Name S3 Bucket" -} - -// Template contains the marshalled value of the s3 template -template: json.Marshal(s3.template) +```cue file=./tests/cloudformation/template/template-end.cue title="todoapp/cloudformation/template.cue" ``` Verify template @@ -637,10 +357,9 @@ dagger query template -f text -e cloudformation # "Value": { ``` -You need to move back the `source.cue` for Dagger to instanciate a bucket: +Reimplement `source.cue`: -```shell -mv ~/tmp/source.cue cloudformation/source.cue +```cue file=./tests/cloudformation/source-end.cue title="todoapp/cloudformation/source.cue" ``` And we can now deploy it: diff --git a/docs/learn/1010-dev-cue-package.md b/docs/learn/1010-dev-cue-package.md index 86729bf9..17d8dee5 100644 --- a/docs/learn/1010-dev-cue-package.md +++ b/docs/learn/1010-dev-cue-package.md @@ -4,10 +4,9 @@ slug: /1010/dev-cue-package/ # Develop a new CUE package for Dagger -This tutorial illustrates how to create new packages, manually distribute them among your applications and contribute to -the Dagger stdlib packages. +This tutorial illustrates how to create new packages, manually distribute them among your applications and contribute to the Dagger stdlib packages. -## Creating your own package +## Creating your package ### Initializing workspace @@ -24,7 +23,7 @@ As described in the previous tutorials, initialize your Dagger workspace: dagger init ``` -That will create 2 directories: `.dagger` and `cue.mod` where our package will reside: +That will create two directories: `.dagger` and `cue.mod`, where our package will reside: ```shell . @@ -38,8 +37,8 @@ That will create 2 directories: `.dagger` and `cue.mod` where our package will r ### Writing the package -Now that you've initialized your workspace it's time to write a simple package. Package name usually starts with a -domain name (as in Go) followed with a descriptive name. In this example we reuse the Cloud Run example and create a +Now that you've initialized your workspace, it's time to write a simple package. Package name usually starts with a +domain name (as in Go) followed by a descriptive name. In this example, we reuse the Cloud Run example and create a package from it. ```shell @@ -52,69 +51,15 @@ Let's write the package logic. It is basically what we've seen in the 106-cloudr touch cue.mod/pkg/github.com/tjovicic/gcpcloudrun/source.cue ``` -```cue title="cue.mod/pkg/github.com/tjovicic/gcpcloudrun/source.cue" -package gcpcloudrun - -import ( - "alpha.dagger.io/dagger" - "alpha.dagger.io/docker" - "alpha.dagger.io/gcp" - "alpha.dagger.io/gcp/cloudrun" - "alpha.dagger.io/gcp/gcr" -) - -#Run: { - // Source code of the sample application - src: dagger.#Artifact & dagger.#Input - - // GCR full image name - imageRef: string & dagger.#Input - - image: docker.#Build & { - source: src - } - - gcpConfig: gcp.#Config - - creds: gcr.#Credentials & { - config: gcpConfig - } - - push: docker.#Push & { - target: imageRef - source: image - auth: { - username: creds.username - secret: creds.secret - } - } - - deploy: cloudrun.#Service & { - config: gcpConfig - image: push.ref - } -} +```cue file=./tests/dev-cue-package/source.cue title="cue.mod/pkg/github.com/tjovicic/gcpcloudrun/source.cue" ``` ### Running the package -Now that you've successfully created a package, let's run it in a new environment. Create a new test package using +Now that you've successfully created a package let's run it in a new environment. Create a new test package using our reusable `gcpcloudrun`: -```shell -mkdir test - -cat > test/source.cue << EOF -package test - -import ( - "github.com/tjovicic/gcpcloudrun" -) - -run: gcpcloudrun.#Run -EOF - -dagger new staging -p ./test +```cue file=./tests/dev-cue-package/script.sh#L3-L16 ``` Run it: @@ -138,7 +83,7 @@ You should see a familiar output: ## Manually distributing packages You've probably guessed this package isn't tied to just your workspace. You can easily copy/paste it into any number -of different workspaces and use it as we've showed above. +of different workspaces and use it as we've shown above. ```shell mkdir -p /my-new-workspace/cue.mod/pkg/github.com/tjovicic/gcpcloudrun @@ -147,7 +92,7 @@ cp ./cue.mod/pkg/github.com/tjovicic/gcpcloudrun/source.cue /new-workspace/cue.m ## Contributing to Dagger stdlib -Our [stdlib](https://github.com/dagger/dagger/tree/main/stdlib) has many useful packages that you can use. +Our [stdlib](https://github.com/dagger/dagger/tree/main/stdlib) has many valuable packages that you can use. You've probably seen it when you've initialized your workspace: ```shell @@ -160,6 +105,5 @@ You've probably seen it when you've initialized your workspace: │ └── usr ``` -We are still a small community and are constantly looking for new contributors that will work with us improve this -amazing project. If you feel like we are missing a package or want to improve an existing one, please start with our +We are still a small community and are constantly looking for new contributors that will work with us to improve this fantastic project. If you feel like we are missing a package or want to improve an existing one, please start with our [contributing docs](https://github.com/dagger/dagger/blob/main/CONTRIBUTING.md) and open a PR. diff --git a/docs/learn/tests/.dagger/env/cloudformation/.gitignore b/docs/learn/tests/.dagger/env/cloudformation/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/docs/learn/tests/.dagger/env/cloudformation/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/docs/learn/tests/.dagger/env/cloudformation/values.yaml b/docs/learn/tests/.dagger/env/cloudformation/values.yaml new file mode 100644 index 00000000..964732d0 --- /dev/null +++ b/docs/learn/tests/.dagger/env/cloudformation/values.yaml @@ -0,0 +1,34 @@ +plan: + package: ./cloudformation +name: cloudformation +inputs: + awsConfig.accessKey: + secret: ENC[AES256_GCM,data:HaGzSQ==,iv:FzsuSq7ZKttWs0WDC0q+vT/hxUx+WcQ4iy7vnV+Q8Dg=,tag:Oy9Xxq+4LMVkXkF/3ZjjsA==,type:str] + awsConfig.localMode: + bool: "true" + awsConfig.region: + text: us-east-2 + awsConfig.secretKey: + secret: ENC[AES256_GCM,data:aHDXVQ==,iv:ZEA4JLLedUvITocXE5G4Ar6pDNilyvgdvEYsMy/LVIk=,tag:BALivFcV0xBQD//qvo0aUw==,type:str] + cfnStack.onFailure: + text: DELETE +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB0TW4xNVMzQkZueGY1NC91 + WUplK09CRXpPSGMyTGhZYjZubDI1Sk96YVRFClJhVlNGT2VMMEtjeTcxbThaMHNq + MTgwdlFObTc3VVYxU3FFZ1lpMDAxVWcKLS0tIFJMQ2F6bWo4OEY2VnZoajJMMDVq + Lzd0bU1qMXF0dzIzTG05cmlzZURxUncKp2wNXD/HKXgGv16pM/yvaYfWL5lsQyWo + CDsT4rHHMZ21XtS9W+7oL9IqMMmDUQf6RZgDgoqLVmTjdBeA8yB2yg== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-09-01T09:50:18Z" + mac: ENC[AES256_GCM,data:UsQxbxNq5wTpXIcw2V/LAQxiavwVcJxACSOGO/AWWrpamemOFqrjwHXQ0CfXGTEq16Vw/YnE3W+ivfxhlPQunkzUsxpvAsKexmx1/uDf04cmGQQFHownV8VO/YmKFmo5UKa6V2cEhDXT040iJncRwp8rrJ2nbRBDKd36RBWtIO0=,iv:QEF3brbSZsDAPyTfPRhyv440EtVKlDq1m0bFCBU0Aj8=,tag:RRCQciN3ho7ChAQ5HhTgIA==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/docs/learn/tests/.dagger/env/gcpcloudrun/.gitignore b/docs/learn/tests/.dagger/env/gcpcloudrun/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/docs/learn/tests/.dagger/env/gcpcloudrun/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/docs/learn/tests/.dagger/env/gcpcloudrun/values.yaml b/docs/learn/tests/.dagger/env/gcpcloudrun/values.yaml new file mode 100644 index 00000000..7f8c0777 --- /dev/null +++ b/docs/learn/tests/.dagger/env/gcpcloudrun/values.yaml @@ -0,0 +1,34 @@ +plan: + package: ./gcpcloudrun +name: gcpcloudrun +inputs: + deploy.name: + text: test-cloudrun-doc + gcpConfig.project: + text: dagger-ci + gcpConfig.region: + text: us-west2 + gcpConfig.serviceKey: + secret: ENC[AES256_GCM,data:Uxivg7fNTD6LrnTEKYmN7RkGuGIp2VyUqEVcnCnQjGzPdKLOd9ExpB/KoA6O6Vut2Mo/oG2+Dz0J/nhR5zH35bdsfDaNHs84xqrDDBW5MkILvEHS30O24lSS75CKJljhWpEM2D+LqHCegPwrMxunHTIpZXMF78A0oEBXJSbqtpMIJY/R8rMRMcZ8jAIOLn+JMbJrcBP8SiYow478G9B/Rd5lFjDQyPp5y5FBc4/xdgDYccJLLufZsuC1ABJjpFcovpF6wXwby0hY08mY6cyynIisf8Qhvyxu2srNW6UYTf9kSmgCw+exPo20i1kYNu/WhgsLIr30k5axOoRaMbBKYFzw/+SeeedNIlVbmykYT5xEllR1MGFea9cg1H6DwINQfL/CSJ6Ai7Uj5LyErhh9ZoYinUzklFQYWh52oOqIO+nCuKCrKpkLK2wY8W1WeK95IDMyLdvrkGcprQcCFaaBLs/HthWPXWwxaXEaRycTG3tqV+AFKuyN9chFLBVEVX6gUbexovGpK78oPhTVcJlDFMHEkve06HvbeV5T8Ee0Qpbqgzqx+wjbvSbYPumd+hd7OLHNMIOgfDp+UXPk1DwpXuRMBn0l4Pp9hoMzjZ8MCAU1aEismctWKbNj8OeqOexn1Rhkrx66+MLCRgg27Lpqsi2u1yFXtOxO0oHNm8+H7CwUFXbYERDnwG98mR7GUeprgbStMTI9VhhoKOZvzXRoHK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mxz+7Ya+AO8Bl84GNnhSzZSnFDfKNbXlZESGH4Obt/aw7Zm29b3l7vpf+6ewjxqQNcwO34rFWQTjF7jD08eU0psT7+OelDHjGYmAPQ6ZtL9SjmBYRUenyf8skGyg4Qjz5mZcuyp7Wkf+yLDqgTmCjabdKJnOE3W8yFz0eUE0FB+XoGG8qH48sQIfctBp2npNeHAUX/CcfGg=,iv:S4nRrhMHlBEq58i0WJS7CzFQELlCExSgA0NxTAP6ckw=,tag:Jt6C/CSNFcZAb1oqQP7h0A==,type:str] + imageRef: + text: gcr.io/dagger-ci/test-cloudrun-doc +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBaTkF6bUFZVXZmQ1ZlV1cx + dDVEUnZiRVBOanlNb1lHVU9BdDVjV01QeDNvCjZmV1ZKckE2eVpYS0JHU0l4V0VW + NDdpVHloQjRWM01Kak81Z1dKZnB2UnMKLS0tIE1rZmo5YkFCUjZ5VVJXcmt0YlU1 + bnhOalppZXdFbFArTndlWnU1TUZDOFkKY4irnpH33+GagucvGkVcEw1KKCJivlCW + rpLd+7EE5bXheiHFphtXTtkUIDCkbC4nTAJ1/37iEKrWsRRFv/CL/g== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-08-13T00:57:43Z" + mac: ENC[AES256_GCM,data:2Pk+6XFyPayexXsUFbDIXG/m6O7WkttraML4D0Y74XKsIjoq8gqNSAJrRmF+brw58j4F2h28PScp8t068byA97QIaWG8Q201vCJ6bpgMcZ4OEXRTLMuoZtpDLa9AoOT/rBaSIu7G5uA4oivVkfed90Nuq5+TGBSp/+me81679us=,iv:gUMpTjR0TwFonLed1fdegaRXtM4NghdZxVjGPJRdLSM=,tag:5SW7uAabLrrNx4h2Tf+9Ww==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/docs/learn/tests/.dagger/env/kube-aws-basic/.gitignore b/docs/learn/tests/.dagger/env/kube-aws-basic/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-aws-basic/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/docs/learn/tests/.dagger/env/kube-aws-basic/values.yaml b/docs/learn/tests/.dagger/env/kube-aws-basic/values.yaml new file mode 100644 index 00000000..ba31f0f1 --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-aws-basic/values.yaml @@ -0,0 +1,32 @@ +plan: + package: ./kube-aws/basic/test +name: kube-aws-basic +inputs: + awsConfig.accessKey: + secret: ENC[AES256_GCM,data:aUxhaAdN44fGz2kKHIl3mdx1vIk=,iv:jgTqZiAwxAtzSjD+IOgjm2rxz43dqtRTcIEuKL3jUDo=,tag:SNU6auwJ/WcXsCc/mrc8sg==,type:str] + awsConfig.region: + text: us-east-2 + awsConfig.secretKey: + secret: ENC[AES256_GCM,data:MAZ/xqZc6kuFO/7EA+degCQ7W7VaJXqseq1+etNSvVNVa+oiPNSnaw==,iv:yGyCKY8S6rwk2EQ7ba3BqirnNyfCtKX+z8EBfLx0WLY=,tag:pOqco/DzRa+lY4LNYmuwYw==,type:str] + eksConfig.clusterName: + text: dagger-example-eks-cluster +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBJZmFKRXhBZmQveFcvcEVH + UmhRS2g0WEdFNFFkZXlLaTZiUHlXSy9IcXdrCmNsTG1pTFVrSDh2NmlpeU1Xa0ZL + aWFMdU1HNytDWUlMK05RMlpIdmtOTDAKLS0tIGpYbUZ6UnBGYzR2SmlOZnE0cWtF + M2loUUEvOGJaRmltTTFmdWduaFMvTkUKtBy9ogOnVqqnoV8A4EBU6j2XPljp9jEz + 25UHK3ecw2SZvKG1u0UcVL0E2KAwUTPzoPJrzRaRKXkSPI8ZXn+OGg== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-08-16T13:31:31Z" + mac: ENC[AES256_GCM,data:9G4o5dpnI0FVvNPz4MbyeNMmop3Umuf5xDrm/JDqfvaFRS2DNVABkczu53y7oPcnlwVWzxdF0Jrul7AizWNCKmw8/NAsPaK9w/6Rff8HnZ2NjoM9rAux8pB5n1GLBjXCMsKcmh1LVmUjzh6WvQSBiCSzzKusdy1UxziP8/ntQJA=,iv:auWG3QOv/ZHMhqAcrdSlZCPmxB7CgrY5IGZFIATDje8=,tag:AL2nHsEVZO/5gO7oKPHpRg==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/docs/learn/tests/.dagger/env/kube-aws-cue-manifest/.gitignore b/docs/learn/tests/.dagger/env/kube-aws-cue-manifest/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-aws-cue-manifest/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/docs/learn/tests/.dagger/env/kube-aws-cue-manifest/values.yaml b/docs/learn/tests/.dagger/env/kube-aws-cue-manifest/values.yaml new file mode 100644 index 00000000..0c73e6d2 --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-aws-cue-manifest/values.yaml @@ -0,0 +1,32 @@ +plan: + package: ./kube-aws/cue-manifest/test +name: kube-aws-cue-manifest +inputs: + awsConfig.accessKey: + secret: ENC[AES256_GCM,data:8R6jJAqkACa/ydy52etCUA+7cWg=,iv:74nd15ckbDG3dTWL8fCMU0FGrCuBqjgIbYWq+h/UBKQ=,tag:zwZruKi+4zI2tS2F2wJ8NQ==,type:str] + awsConfig.region: + text: us-east-2 + awsConfig.secretKey: + secret: ENC[AES256_GCM,data:8FNwXL/yDFfPR9YUqKanI6CpDMl0/Ww8Pmgy4ol1n4KDpBRJAsOrZA==,iv:Y6ak40j4yXnpa8BY3BfALmlcD16DrkjcAr2hiM7cots=,tag:69qocIvAajjdQUpl1M1jXw==,type:str] + eksConfig.clusterName: + text: dagger-example-eks-cluster +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBKTXl1TDJ3cituU3NicnFR + Tm0wTjducEdPL0FyWHBqcmEwV01aUmNsc0RBCjlNNGIxOTZBaElMRFZ1bjh4dWc1 + REJqcy9UMkVBVnFDOHZPYkt3S1NYSU0KLS0tIGFwZVlLMGNINmZzdURDbnY1RStI + S25tM1I0ZWp1MndzNFNhcHRiQUdpME0K91dMEF9zxHjAtMEryPKiM+hMJ5OiKGPK + aWSQVu06LLBFW5txr+U55WlCGPL484xjw1/Axd3ADq0I9AjnuB3aAQ== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-08-16T21:24:58Z" + mac: ENC[AES256_GCM,data:rVdRHU252Dsp4YTofv3v3L5k/W0d09LEENHCEFrjSnTOuibIBWi/7nVADlBBx8PEfhofHTHIEtnIg6dtVaOlIBAd9Co/wljoaU5mVGNdWuQOpN7ttGlG9BHXDR96+Gvp0hT0lY9hK3LKPBcxzzXizFGiaPGqkaPfj8Sxg42eqMA=,iv:76wENP19U76rW24A0QNLue2cZnWosMieveUqHyLFSpo=,tag:pAvNkVcFYIed3Q/ldMcYyg==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/docs/learn/tests/.dagger/env/kube-aws-deployment/.gitignore b/docs/learn/tests/.dagger/env/kube-aws-deployment/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-aws-deployment/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/docs/learn/tests/.dagger/env/kube-aws-deployment/values.yaml b/docs/learn/tests/.dagger/env/kube-aws-deployment/values.yaml new file mode 100644 index 00000000..d0770d33 --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-aws-deployment/values.yaml @@ -0,0 +1,32 @@ +plan: + package: ./kube-aws/deployment/test +name: kube-aws-deployment +inputs: + awsConfig.accessKey: + secret: ENC[AES256_GCM,data:I+FBavqrb2l1jNTLQ9P8x/UnYds=,iv:P5YfvxSbJ1wjPHqZDKOwf2R6AWw1E08C8jLPgjyxvR4=,tag:E6zC01+AkJS+AC1GFTdJGg==,type:str] + awsConfig.region: + text: us-east-2 + awsConfig.secretKey: + secret: ENC[AES256_GCM,data:O8g4xk+xum+gw0mN7H0PYCpmX7FmdgslB8dVY4RWRvUGtHAp5AT/Jw==,iv:LmdJhlL6t7nihr7xDRRPLkd+nWMT9DbNs9pFF1+KazM=,tag:SWlmHyg4/Czn9ygUjv01yg==,type:str] + eksConfig.clusterName: + text: dagger-example-eks-cluster +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBsU0N2bmpTZjh4TjBwRDNP + OG5oM29zZmlhdkV0cWhhbVJZaEdod2hPZTJBCnhoYW9wTnI5ajZSaVcxdVNPSGNT + Q2VvWXZKU0xoZmk4QXJVL011K2t0dU0KLS0tIDVSV001dnhEYkZPSXl5ZFFCb3dC + a2VtRXR0NVZaTWRQSUVWTFdEWUdtazgKhbfhOHL1tdpMiUNgZYUuXo2A8ly54WuE + FJAIoRTFV6Ls5rlW2oI9Ocw+8MdUr/Lbzqtm9ihPEXveOHYE/oZUDA== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-08-16T13:55:15Z" + mac: ENC[AES256_GCM,data:Jlpb72VuYUKvFuCKJRjuNMVxVNCA81EosFpJhheluYcbrO022MMq3rbGdaMRim96N8i0Ux1gMVM/bHumRvJ963DF0i2PGurfaV0QnJiEnu9hBYmNmeL0MV3Qx+ds0+RuoM6gyMgLU4rU/hUZBfVIJqdsvZ5KAUkyQnzgyeQ9ZII=,iv:Jq/ksjU0RKeZnoJruaBkQCR+L1JDRuCTCxf8sNAKVnQ=,tag:RxSXxeCOMIYjdiQXVgaG0g==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/docs/learn/tests/.dagger/env/kube-gcp-basic/.gitignore b/docs/learn/tests/.dagger/env/kube-gcp-basic/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-gcp-basic/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/docs/learn/tests/.dagger/env/kube-gcp-basic/values.yaml b/docs/learn/tests/.dagger/env/kube-gcp-basic/values.yaml new file mode 100644 index 00000000..8ba6f9c3 --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-gcp-basic/values.yaml @@ -0,0 +1,32 @@ +plan: + package: ./kube-gcp/basic/test +name: kube-gcp-basic +inputs: + gcpConfig.project: + text: dagger-ci + gcpConfig.region: + text: us-west2-a + gcpConfig.serviceKey: + secret: ENC[AES256_GCM,data:kwplJvCrAGhmGckG0ZBVXb+C2T9LFN+Nxd7EbFJIEOUtkslxTC5CungmJBSM57lQ7ATQZOzSwxt3tHffqinCPMoOsZEfqeOptp3K9bgBuOm5VW89U/dpIES3CEueGOZemlgj30QrDBcOwdRGFU5BySs4KLNK5jT+CTgY5T26jbX3amPTQvxye/YLKXND8PrdFCzAuMRygR4E5vqsE2Xs6efwyivT6GAulA6Ny6BfhZQlPplOsPP5f53B8yLU8CfuE6TLhafyY+jyatL3a8qGrRPuv6WGbQO0flP4KtYvnzbY09by4ysK7+9Nd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75OPoz4AN97FkhTQQll7f0gadU7pbZ/2bSCHxQYmuM9P9f7IQgsW0/UQidN0506b4RbN2bYmpF1wzzStAC2HpQuDVQMkqql82AT3OfkSXashrQUOw1ZAw7L8YdWSNjuIFiq3obMEf6579sajkP0cbl6EW0PkSrJCViXYZDdzohdXy6x/lfolaOjw6qjM76iIdnV40nz/tbBIG/fE83sMbbzbZcI6MhKxcctHXMYFn2NlNkBVZx8Q892SoHg9a+KERML/QVwABae7iGarV29dyoBv+F4mNStbE/hTDzyZw4sCoGMitimgZxxPgOkJZE8jX8i1rVEiuVj12ZdfX70Q3aH4REcsnEZU0v72RoazG2iihn0enig8OfNKNPIU4XszvYgVLj/P5Tgk+heTkyERdIfJZ4ghj7IR/KDQQRRHcXyxAIfAmqrqG5f3bQwfw9W0IhXknnP4Efx2wOO5R9VCLoXVjligmf9NMFLcMJMBEJ3fzmt0tQOS2z3B8vxHWT23gvnbb6eA1Tx5G129/0lNQ7pMEB1Uhfqt530lMpcOGZLd/s8A93EQoY3sJOM7dsvrhuNaZhJn5k2wKtp3LaIuJGc4gQBA5yclSUC9oizbiwQQzvi6iWxyLUR1ZIRh,iv:xPtOE22z61A6E3bIleBM3HJARFzTzz629K3mLiLkuuo=,tag:x+hbPzn8aowSL4o3WpHDLw==,type:str] + gkeConfig.clusterName: + text: test-cluster +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBlbzlrT3FBd0dmNjJROHE4 + cGFtdzdmWm00Z2d3N3RpOXp3dloyU014M1FFCml6dU1BclFxU2ZhSmdUZ0lBNEUx + TlA2UjR3dmpxZXAySTNDdmozVldxSXMKLS0tIGZNclEvQlhuL0VuL0x0SEZqMDZR + cTFrdThhbHUxSG53c0hwT2VvRE1qL1UKD4aR1Cb9+wQthHtPpj/aFh+tLsW1xWNH + ijbpYjLg6PpFwJmuuWrDylP6Mfv9Zyg35utzR5ECE0W1M9oLU3aLjg== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-08-16T21:50:36Z" + mac: ENC[AES256_GCM,data:k0tYmkhSiMYKg9NZSTHoDx0bOtwAa4FS3vpg6/5O2oQ35xs//iCEIgvPrwdO0E+dwT8t4dyorC6WEBxNuhrs0HdIEPF6i5qqLgPOXQmZYuss8ueroEggEFbtakyLuZ8bNFLF5ym2Sr0pBJiWfJkexMS/d96m1ouV2c8Wq2sNkig=,iv:SCUwU5rR4/C5oZJg/rkkyx+2/tmWbjDZ/SsbalPxjbU=,tag:nXNnByQBXhPZXlqpfjjzFQ==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/docs/learn/tests/.dagger/env/kube-gcp-cue-manifest/.gitignore b/docs/learn/tests/.dagger/env/kube-gcp-cue-manifest/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-gcp-cue-manifest/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/docs/learn/tests/.dagger/env/kube-gcp-cue-manifest/values.yaml b/docs/learn/tests/.dagger/env/kube-gcp-cue-manifest/values.yaml new file mode 100644 index 00000000..de7748c9 --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-gcp-cue-manifest/values.yaml @@ -0,0 +1,32 @@ +plan: + package: ./kube-gcp/cue-manifest/test +name: kube-gcp-cue-manifest +inputs: + gcpConfig.project: + text: dagger-ci + gcpConfig.region: + text: us-west2-a + gcpConfig.serviceKey: + secret: ENC[AES256_GCM,data:WlC5J7rNdHlI6hlskgCzuApBU0fvHmibFh9xJ604KbC2b3Mf/Daf2PtxvfEbdfoJXWJZBb7xYgH7LJOEfhmrkKyK5Qp9xr6I05AuO0H76pLnYTLcWru9AoM9ekYm6TW7r94OONueyOrEumZr59qdaQSr3uMx2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F0dydp2zwQp3UblszWU20pnTsypq0B5pflYpHGYY7g2RAblTnrhq9TJiXGttgDqOCOpGqM/CtGQgofaYKJPrjhpxGeAFbV/+HkFpEY4UwJrHSKu9Hrv6flK36Wzi1n3xnXwQzsvbez1A2VRjIAkd3xwmo+pmBBiAnxiaq1P7WLEmyvPR5UwMW2uzQ8aw0v7OTmcY0AbZZOTiMY0MRh+LCiMJvUsOv3FKfgvdxCaGFpApkQAHqHbMVZa6X8mk8MTAUGMMJ+/Ir8uW3EBtDjqU2RzH7w6D6SjnMOZJ1nqpGDG3YWU/wtPQqG0/TiIGuwNDkKfTD6wZrgDjb+bGvQWi9H6maiaUg9H8O/qwhQqsiFRIgSnOX1nm/p2/wj16raH7NjQIG4UHfox96fNBzzp6xGyyJXfgymIOWge/a3VhfXB5/kb/iFTcw8uTaHu+rmAelSUUgimQ86Ybdfzs7lsPAIQgGJOQJ1KgyQ8wxF8QP8cYqu10EiTGi/JGx7z8WeLavx542X4xVezPenqVOqQlcpF6M8LR2R2p8zptjX1qsftjPNZyRx9YvI2MsGVW9ifB1hs4bs56dTKNYX3itgVM9T/q9B5pbNY3eMf2KpYT8AtfkJgtJNttNNUkLUjcoTxnU0d2u+1e0I7r12aRFcIKHvGDMt5dDyN8b2/8rhg42i/A/WaXGNIecljNBsVK/wS0Hv56roCyiTBg4ZoCzTA1sCPLR9V9T2AId8QZv2yMPlKVzSH7rrEMGoSc+BWuec98B1QrIBdC6ICnoin,iv:uGLdGFprxBx2JX4GXdJlwiikOxarEX3zzJnuiF3jtV8=,tag:aZIAWTfjgDBCAKDDGXVHZw==,type:str] + gkeConfig.clusterName: + text: test-cluster +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA2TWhqdVQ4Si9CQU5mRmQy + SEpCM0l6UGsydkM1SlFIREZmSTh5YmtuT1cwClN5eUJlNGkyS29jYmlEMWhYTDZK + NzdLeitIL0Erdm1IVHAxSitQWWRDOG8KLS0tIGNFa1JEclJNWEQ2SHVlbW5lY3kw + enc0b29RU2xKMWFoWFVqcnJ4S3NOKzQK6coqwcUNfO/D3OFcEnVHqjZTUFv9zJPr + OT4sQCfYA4tJWL6Xm8aDiWKr91GqURo4aTpZnwzlWIrIrTTs25IQig== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-08-16T22:09:04Z" + mac: ENC[AES256_GCM,data:kXzvMaEEy9vJneQU9FlRGBzwP73aJhhyIu/axCu36ee84pYuHYEXkJB6Irh/1kYyDDwj+m3k3ySszlkQfa5+Lhy7U+sKb7KFJKmy2rYJekBIjTnYyPNeM1M0mG52pKwbUTElZ9Wo3z4vDkSrjfYxsgYM2cSvEKgoiC4M5VhzXjM=,iv:WNar5O7/+Vwh0+S8tcTKNbloUUpB+79QJEyrVJVeGsc=,tag:iAwTMUidHmTv+TNJxt0BBg==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/docs/learn/tests/.dagger/env/kube-gcp-deployment/.gitignore b/docs/learn/tests/.dagger/env/kube-gcp-deployment/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-gcp-deployment/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/docs/learn/tests/.dagger/env/kube-gcp-deployment/values.yaml b/docs/learn/tests/.dagger/env/kube-gcp-deployment/values.yaml new file mode 100644 index 00000000..0c28e5c3 --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-gcp-deployment/values.yaml @@ -0,0 +1,32 @@ +plan: + package: ./kube-gcp/deployment/test +name: kube-gcp-deployment +inputs: + gcpConfig.project: + text: dagger-ci + gcpConfig.region: + text: us-west2-a + gcpConfig.serviceKey: + secret: ENC[AES256_GCM,data:Xbs0AHj7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hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSB6d2M5VGZ1Tjhhai90OVBE + K3B1b2ZETldIbjhnbXl2Q1FSU2ROYVUzY1FvCnVyYmtOOGZ0T3ZmTmJRcXZxYjho + SzZGWUlMdXZVVXg1STZJeStudjRQazAKLS0tIFdPeDc0SUU4bk5XdVJXcGRCb2c1 + Ni8vY1dCV3UzVkcxWE1CdTVsclVnTVUK1fH9kbr2H75zTCjvTTYr8jN8bF0YrQ9f + ZiSDkc+kgj/WrwFyXX6nbF3eU5wM0EYsD2dVqrrSWKUKz4egrRpS6Q== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-08-16T22:01:37Z" + mac: ENC[AES256_GCM,data:Izl+ILzP05dVZ5LcW1NcYyxl/jY+MWurMc277GSy/lrpBlKNJe5pSP0u1b0Ib1g4SX2p/gkXMtUp2gTCM/f6rgpN9prPLJMr/MREj/VVwPuDiLZzr5aPNYHJ19lDMkO5QvFXM6KDVixEs1HUHm/wSSIfO8h/Gk32S6Hp4mjq5+o=,iv:n6p4dXIE4GJ82ty0/XH11H+i44FA/DE1zRsw/fmUJFk=,tag:KWdZNRDh5kutW9tGoc5sJg==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/docs/learn/tests/.dagger/env/kube-kind-basic/.gitignore b/docs/learn/tests/.dagger/env/kube-kind-basic/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-kind-basic/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/docs/learn/tests/.dagger/env/kube-kind-basic/values.yaml b/docs/learn/tests/.dagger/env/kube-kind-basic/values.yaml new file mode 100644 index 00000000..11457850 --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-kind-basic/values.yaml @@ -0,0 +1,23 @@ +plan: + package: ./kube-kind/basic +name: kube-kind-basic +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSAwZ3FnR0NRay9TM1FaZXhT + T2hvQ1ZDRkNLMHpMMnh6a3QrZUpRcHhkQVVBCm5NWXdRZXVPVWhEQXdwSnQwQkZ3 + NE1wL3VyNjlVbmdqM2t2MDc1ZHVNd2sKLS0tIEZNUUtnUFVBOTEyMGVWbXgycHo4 + Z0RqSGxzN3pyc1RLcGN5b29GbHpkbWsKhNI37Ws2sWSW2ZKZSSFH5a2LD9meOQrH + MM2Xd0+Kh4OwYIfMXmCU1CmNRP/W1MUf6Eq/21uM3fDU8GDbpOV/pA== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-08-13T12:56:16Z" + mac: ENC[AES256_GCM,data:ODBv7782ofOQzVtETFu9wdMdmK/22jl1CqPzTqdOu6oZFWklbQ4grJ3N1cemE2Ud1Awb/x41QgpSuvVHaO2dHkVEF1FmlVDIqhqm6BNQlDg81RFuvs86FP60cW8rfr4K2dhCnQ1mRKGdTLsNUjUqBd3uwPDu5f49o3Ai/EpOg0A=,iv:1UdjtEKhKyFEnkjUOPAYlyIp8xYieDBIXKGxmxcYUbs=,tag:e6YcVmSVdsfLLMOPQXrN8A==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/docs/learn/tests/.dagger/env/kube-kind-cue-manifest/.gitignore b/docs/learn/tests/.dagger/env/kube-kind-cue-manifest/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-kind-cue-manifest/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/docs/learn/tests/.dagger/env/kube-kind-cue-manifest/values.yaml b/docs/learn/tests/.dagger/env/kube-kind-cue-manifest/values.yaml new file mode 100644 index 00000000..db84bd57 --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-kind-cue-manifest/values.yaml @@ -0,0 +1,26 @@ +plan: + package: ./kube-kind/cue-manifest +name: kube-kind-cue-manifest +inputs: + registry: + text: localhost:5000/kind +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA0cks5RUFvcGZseFZUYkVT + azFieWVQZEhORFFFLysvVkJJMUZlZ3FxVFZVClRZSHNiMC91RGtWUjVDOEJlTisz + WjdmVW5Rc0wrbjYyZlNkMVE2Wkg5SzAKLS0tIFFmZFdSUFViR2tYTG9UMHYwNzNL + WkdkcFZvM2NtRUhtVzhxUWRZT1FCUEUKzUdfMTXsr2sdrG5B9qvdGrSMuvvJG2qB + eZWf3QbQBIk9OWcU14E1j+xUrR+tME7ABA2UD3/VpLxSEUI2Cp2VpA== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-08-13T17:07:17Z" + mac: ENC[AES256_GCM,data:E00oUv3prQDGBxTysz71/lu0Y0uYPI7L6gRSz3uMmXsl2y/HPxt7F29vOuxj8BwkBiwFzq7aV3ql7S+EKLAFgCiN81PCAE51ObBceoZmAJNyTCRUzG+o8fIjCsIGfdMSOpoCvVIwQuB0YytICN0+zA/75JNzGvPAgStB7ZI9TPM=,iv:vN944S2hd1Is3UByevNXNB1oUmvMvx0f4LgxkId6vjI=,tag:aYbNEuz1Xs3Lpfjhb91BBA==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/docs/learn/tests/.dagger/env/kube-kind-deployment/.gitignore b/docs/learn/tests/.dagger/env/kube-kind-deployment/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-kind-deployment/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/docs/learn/tests/.dagger/env/kube-kind-deployment/values.yaml b/docs/learn/tests/.dagger/env/kube-kind-deployment/values.yaml new file mode 100644 index 00000000..c078173c --- /dev/null +++ b/docs/learn/tests/.dagger/env/kube-kind-deployment/values.yaml @@ -0,0 +1,26 @@ +plan: + package: ./kube-kind/deployment +name: kube-kind-deployment +inputs: + registry: + text: localhost:5000/kind +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBxRlpLcVVoTnVLUkVOMlpN + eXRzdkgvNjNGYWNzaVBBNUJEZFdnbXhMTzI0CjlsNGVDcHlHTDk3VU1ycEVvVmti + SmlGVDFZUTlKWm9OVWdwK1Q4ZmZXZDgKLS0tIDRNRW4razlkbnFMdDV1UU52aHdT + d1pSR1VtUU12VmlDTEdyazgwdkdwQkkK6NZclDyaf5YwBWAbL6VmJWzCNT+cFXsU + gM9y8Bo/VXHx2uR5ceLVtAGvTl4XuIGTqBEqpIelTJAD3TUj2C2upg== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-08-13T16:37:05Z" + mac: ENC[AES256_GCM,data:qO6rbMUVpVs5dwmZm7nHSsGPysJXcIkvpRMeEhihUXGcZ6IeVX2dmuwOXMTQWtJ6HwhM+wdYyj5IIlujYARC+FYj3ldrYlCs/kPzfcDkJm1K9PXcKKTm5wV7v0hcTvmwe9ju5VSNWtLvXNsE8+u8hz9Wnnz4e0QQCvNQmUHJrNo=,iv:+JuEpyBRXZ4xb4KQ15p8OK7QPqB4iYtgSyPDxK9949w=,tag:9m27tAGWjxr87DzEzP5vmQ==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/docs/learn/tests/.dagger/env/multibucket/.gitignore b/docs/learn/tests/.dagger/env/multibucket/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/docs/learn/tests/.dagger/env/multibucket/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/docs/learn/tests/.dagger/env/multibucket/values.yaml b/docs/learn/tests/.dagger/env/multibucket/values.yaml new file mode 100644 index 00000000..1fafe75a --- /dev/null +++ b/docs/learn/tests/.dagger/env/multibucket/values.yaml @@ -0,0 +1,28 @@ +plan: + package: ./multibucket +name: multibucket +inputs: + site.netlify.account.token: + secret: ENC[AES256_GCM,data:e5cILcdqbaFdz6ZMM4sNYrChQS+VSMJTZA9cJ0kPvNEDlQj2n7ldlBeO9A==,iv:4SlRRlXyJ8/9ewAPXJ9KdhdVo4FrvVeRwSip2FfMTIM=,tag:JdxkVTR6SOLgzHUWtoSjyw==,type:str] + site.netlify.name: + text: dagger-test-doc-102 +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBOVFI4NU40NXF1Um4vR1No + MTByOC9HVWJYUCtzYUc4WGh2UG1EQnJCSm5FCnFrZ1BaMEZJLzBIRUVTUUdhWWRv + N2xRYTR4NlhwclBYME9ZZ3JQejJoUFkKLS0tIDEwa0dXbVhzRWMrMFc3U0FtaEdr + RERQRVp2VjR3K0VwQlZRWEJrQUNpNkUK78CsKmOJp1kKUcytprs0SKLLuo0YDucp + oLuxQQd0X3/8x2c/YfJ3R15e1EQDC73HjSXDbhlgOScR9bxGVqn36A== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-08-12T23:19:07Z" + mac: ENC[AES256_GCM,data:9jc3lwlbsJ6CdiSBF4ALNiv/zD7Rv5ZodftuEQpZuJVEpjJCKSq3C7LNyJKxV7fTg/tZ+RDx/q+x0xN9reRRrmvUCsbmLRL2h20rrfsVj3npCSkRiQFcmoHd6ULjf/kbkgUanLt8YmncDzJqNTQfafCxTo1RY3+U2WH/QSIIebQ=,iv:dcXQsq5de6LElOoqvGfs7nmHELkoTs0jddeY3vf4fJg=,tag:j0Eeu5NrNyhBYUzMwarj+w==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/docs/learn/tests/cloudformation/deletion.cue b/docs/learn/tests/cloudformation/deletion.cue new file mode 100644 index 00000000..ed57a23a --- /dev/null +++ b/docs/learn/tests/cloudformation/deletion.cue @@ -0,0 +1,24 @@ +package main + +import ( + "alpha.dagger.io/os" + "alpha.dagger.io/aws" + "alpha.dagger.io/dagger" +) + +// Remove Cloudformation Stack +stackRemoval: { + // Cloudformation Stackname + stackName: string & dagger.#Input + + ctr: os.#Container & { + image: aws.#CLI & { + config: awsConfig + } + always: true + env: STACK_NAME: stackName + command: """ + aws cloudformation delete-stack --stack-name $STACK_NAME + """ + } +} diff --git a/docs/learn/tests/cloudformation/source-begin.cue b/docs/learn/tests/cloudformation/source-begin.cue new file mode 100644 index 00000000..7cede99c --- /dev/null +++ b/docs/learn/tests/cloudformation/source-begin.cue @@ -0,0 +1,8 @@ +package main + +import ( + "alpha.dagger.io/aws" +) + +// AWS account: credentials and region +awsConfig: aws.#Config diff --git a/docs/learn/tests/cloudformation/source-end.cue b/docs/learn/tests/cloudformation/source-end.cue new file mode 100644 index 00000000..769331d5 --- /dev/null +++ b/docs/learn/tests/cloudformation/source-end.cue @@ -0,0 +1,26 @@ +package main + +import ( + "alpha.dagger.io/aws" + "alpha.dagger.io/dagger" + "alpha.dagger.io/random" + "alpha.dagger.io/aws/cloudformation" +) + +// AWS account: credentials and region +awsConfig: aws.#Config + +// Create a random suffix +suffix: random.#String & { + seed: "" +} + +// Query the Cloudformation stackname, or create one with a random suffix to keep unicity +cfnStackName: *"stack-\(suffix.out)" | string & dagger.#Input + +// AWS Cloudformation stdlib +cfnStack: cloudformation.#Stack & { + config: awsConfig + stackName: cfnStackName + source: template +} diff --git a/docs/learn/tests/cloudformation/template.cue b/docs/learn/tests/cloudformation/template.cue new file mode 100644 index 00000000..827ab6c0 --- /dev/null +++ b/docs/learn/tests/cloudformation/template.cue @@ -0,0 +1,61 @@ +package main + +// inlined s3 cloudformation template as a string +template: """ + { + "AWSTemplateFormatVersion": "2010-09-09", + "Resources": { + "S3Bucket": { + "Type": "AWS::S3::Bucket", + "Properties": { + "AccessControl": "PublicRead", + "WebsiteConfiguration": { + "IndexDocument": "index.html", + "ErrorDocument": "error.html" + } + }, + "DeletionPolicy": "Retain" + }, + "BucketPolicy": { + "Type": "AWS::S3::BucketPolicy", + "Properties": { + "PolicyDocument": { + "Id": "MyPolicy", + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "PublicReadForGetBucketObjects", + "Effect": "Allow", + "Principal": "*", + "Action": "s3:GetObject", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:aws:s3:::", + { + "Ref": "S3Bucket" + }, + "/*" + ] + ] + } + } + ] + }, + "Bucket": { + "Ref": "S3Bucket" + } + } + } + }, + "Outputs": { + "Name": { + "Value": { + "Fn::GetAtt": ["S3Bucket", "Arn"] + }, + "Description": "Name S3 Bucket" + } + } + } + """ diff --git a/docs/learn/tests/cloudformation/template/convert.cue b/docs/learn/tests/cloudformation/template/convert.cue new file mode 100644 index 00000000..a08c9210 --- /dev/null +++ b/docs/learn/tests/cloudformation/template/convert.cue @@ -0,0 +1,5 @@ +package main + +import "encoding/json" + +s3Template: json.Unmarshal(template) diff --git a/docs/learn/tests/cloudformation/template/deployment.cue b/docs/learn/tests/cloudformation/template/deployment.cue new file mode 100644 index 00000000..be7ea2c9 --- /dev/null +++ b/docs/learn/tests/cloudformation/template/deployment.cue @@ -0,0 +1,75 @@ +package main + +#Deployment: { + + // Bucket's output description + description: string + + // index file + indexDocument: *"index.html" | string + + // error file + errorDocument: *"error.html" | string + + // Bucket policy version + version: *"2012-10-17" | string + + // Retain as default deletion policy. Delete is also accepted but requires the s3 bucket to be empty + deletionPolicy: *"Retain" | "Delete" + + // Canned access control list (ACL) that grants predefined permissions to the bucket + accessControl: *"PublicRead" | "Private" | "PublicReadWrite" | "AuthenticatedRead" | "LogDeliveryWrite" | "BucketOwnerRead" | "BucketOwnerFullControl" | "AwsExecRead" + + // Modified copy of s3 value in `todoapp/cloudformation/template.cue` + template: { + AWSTemplateFormatVersion: "2010-09-09" + Outputs: Name: { + Description: description + Value: "Fn::GetAtt": [ + "S3Bucket", + "Arn", + ] + } + Resources: { + BucketPolicy: { + Properties: { + Bucket: Ref: "S3Bucket" + PolicyDocument: { + Id: "MyPolicy" + Statement: [ + { + Action: "s3:GetObject" + Effect: "Allow" + Principal: "*" + Resource: "Fn::Join": [ + "", + [ + "arn:aws:s3:::", + { + Ref: "S3Bucket" + }, + "/*", + ], + ] + Sid: "PublicReadForGetBucketObjects" + }, + ] + Version: version + } + } + Type: "AWS::S3::BucketPolicy" + } + S3Bucket: { + DeletionPolicy: deletionPolicy + Properties: { + AccessControl: "PublicRead" + WebsiteConfiguration: { + ErrorDocument: errorDocument + IndexDocument: indexDocument + } + } + Type: "AWS::S3::Bucket" + } + } + } +} diff --git a/docs/learn/tests/cloudformation/template/template-begin.cue b/docs/learn/tests/cloudformation/template/template-begin.cue new file mode 100644 index 00000000..490ac179 --- /dev/null +++ b/docs/learn/tests/cloudformation/template/template-begin.cue @@ -0,0 +1,60 @@ +// Add this line, to make it part to the cloudformation template +package main + +import "encoding/json" + +// Wrap exported Cue in previous point inside the `s3` value +s3: { + AWSTemplateFormatVersion: "2010-09-09" + Outputs: Name: { + Description: "Name S3 Bucket" + Value: "Fn::GetAtt": [ + "S3Bucket", + "Arn", + ] + } + Resources: { + BucketPolicy: { + Properties: { + Bucket: Ref: "S3Bucket" + PolicyDocument: { + Id: "MyPolicy" + Statement: [ + { + Action: "s3:GetObject" + Effect: "Allow" + Principal: "*" + Resource: "Fn::Join": [ + "", + [ + "arn:aws:s3:::", + { + Ref: "S3Bucket" + }, + "/*", + ], + ] + Sid: "PublicReadForGetBucketObjects" + }, + ] + Version: "2012-10-17" + } + } + Type: "AWS::S3::BucketPolicy" + } + S3Bucket: { + DeletionPolicy: "Retain" + Properties: { + AccessControl: "PublicRead" + WebsiteConfiguration: { + ErrorDocument: "error.html" + IndexDocument: "index.html" + } + } + Type: "AWS::S3::Bucket" + } + } +} + +// Template contains the marshalled value of the s3 template +template: json.Marshal(s3) diff --git a/docs/learn/tests/cloudformation/template/template-end.cue b/docs/learn/tests/cloudformation/template/template-end.cue new file mode 100644 index 00000000..c59fa5a4 --- /dev/null +++ b/docs/learn/tests/cloudformation/template/template-end.cue @@ -0,0 +1,10 @@ +package main + +import "encoding/json" + +s3: #Deployment & { + description: "Name S3 Bucket" +} + +// Template contains the marshalled value of the s3 template +template: json.Marshal(s3.template) diff --git a/docs/learn/tests/cue.mod/module.cue b/docs/learn/tests/cue.mod/module.cue new file mode 100644 index 00000000..f8af9cef --- /dev/null +++ b/docs/learn/tests/cue.mod/module.cue @@ -0,0 +1 @@ +module: "" diff --git a/docs/learn/tests/cue.mod/pkg/.gitignore b/docs/learn/tests/cue.mod/pkg/.gitignore new file mode 100644 index 00000000..a572e9ee --- /dev/null +++ b/docs/learn/tests/cue.mod/pkg/.gitignore @@ -0,0 +1,2 @@ +# dagger universe +alpha.dagger.io diff --git a/docs/learn/tests/dev-cue-package/script.sh b/docs/learn/tests/dev-cue-package/script.sh new file mode 100644 index 00000000..03aae599 --- /dev/null +++ b/docs/learn/tests/dev-cue-package/script.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +mkdir -p test + +cat > test/source.cue << EOF +package test + +import ( + "github.com/tjovicic/gcpcloudrun" +) + +run: gcpcloudrun.#Run +EOF + +dagger new staging -p ./test diff --git a/docs/learn/tests/dev-cue-package/source.cue b/docs/learn/tests/dev-cue-package/source.cue new file mode 100644 index 00000000..fdac138f --- /dev/null +++ b/docs/learn/tests/dev-cue-package/source.cue @@ -0,0 +1,41 @@ +package gcpcloudrun + +import ( + "alpha.dagger.io/dagger" + "alpha.dagger.io/docker" + "alpha.dagger.io/gcp" + "alpha.dagger.io/gcp/cloudrun" + "alpha.dagger.io/gcp/gcr" +) + +#Run: { + // Source code of the sample application + src: dagger.#Artifact & dagger.#Input + + // GCR full image name + imageRef: string & dagger.#Input + + image: docker.#Build & { + source: src + } + + gcpConfig: gcp.#Config + + creds: gcr.#Credentials & { + config: gcpConfig + } + + push: docker.#Push & { + target: imageRef + source: image + auth: { + username: creds.username + secret: creds.secret + } + } + + deploy: cloudrun.#Service & { + config: gcpConfig + image: push.ref + } +} diff --git a/docs/learn/tests/doc.bats b/docs/learn/tests/doc.bats new file mode 100644 index 00000000..519e6a81 --- /dev/null +++ b/docs/learn/tests/doc.bats @@ -0,0 +1,282 @@ +## Doc commands are being extracted from this file and helpers. +## Indentation is important, please append at the end + +setup() { + load 'helpers' + + common_setup +} + +# Test 1003-get-started +@test "doc-1003-get-started" { + setup_example_sandbox + + # Set examples private key + "$DAGGER_SANDBOX"/import-tutorial-key.sh + + # Collect url + dagger -w "$DAGGER_SANDBOX" up + url=$(dagger -w "$DAGGER_SANDBOX" query -f text url) + + # More commands + dagger -w "$DAGGER_SANDBOX" list + ls -l "$DAGGER_SANDBOX"/s3 + dagger -w "$DAGGER_SANDBOX" input list + + # Check output + run curl "$url" + assert_output --partial "My Todo app" +} + +@test "doc-1004-first-env" { + setup_example_sandbox + + # Follow tutorial + mkdir -p "$DAGGER_SANDBOX"/multibucket + cp "$DAGGER_WORKSPACE"/multibucket/source.cue "$DAGGER_SANDBOX"/multibucket + cp "$DAGGER_WORKSPACE"/multibucket/yarn.cue "$DAGGER_SANDBOX"/multibucket + cp "$DAGGER_WORKSPACE"/multibucket/netlify.cue "$DAGGER_SANDBOX"/multibucket + + dagger -w "$DAGGER_SANDBOX" doc alpha.dagger.io/netlify + dagger -w "$DAGGER_SANDBOX" doc alpha.dagger.io/js/yarn + + # Initialize new env + dagger -w "$DAGGER_SANDBOX" new 'multibucket' -p "$DAGGER_SANDBOX"/multibucket + + # Copy corresponding env + cp -r "$DAGGER_WORKSPACE"/.dagger/env/multibucket "$DAGGER_SANDBOX"/.dagger/env/ + + # Add missing src input + dagger -w "$DAGGER_SANDBOX" -e multibucket input dir src "$DAGGER_SANDBOX" + + # Run test + dagger -w "$DAGGER_SANDBOX" -e multibucket up + url=$(dagger -w "$DAGGER_SANDBOX" -e multibucket query -f text site.netlify.deployUrl) + + # Check output + run curl "$url" + assert_output --partial "./static/css/main.9149988f.chunk.css" +} + +@test "doc-1006-google-cloud-run" { + setup_example_sandbox + + # Follow tutorial + mkdir -p "$DAGGER_SANDBOX"/gcpcloudrun + cp "$DAGGER_WORKSPACE"/gcpcloudrun/source.cue "$DAGGER_SANDBOX"/gcpcloudrun + + # Initialize new env + dagger -w "$DAGGER_SANDBOX" new 'gcpcloudrun' -p "$DAGGER_SANDBOX"/gcpcloudrun + + # Copy corresponding env + cp -r "$DAGGER_WORKSPACE"/.dagger/env/gcpcloudrun "$DAGGER_SANDBOX"/.dagger/env/ + + # Add missing src input + dagger -w "$DAGGER_SANDBOX" -e gcpcloudrun input dir src "$DAGGER_SANDBOX" + + # Run test + run dagger -w "$DAGGER_SANDBOX" -e gcpcloudrun up + assert_success +} + +@test "doc-1007-kube-kind" { + skip_unless_local_kube + + #################### BASIC #################### + # Copy deployment to sandbox + copy_to_sandbox kube-kind-basic kube-kind + + # Add kubeconfig + dagger -w "$DAGGER_SANDBOX" -e kube-kind-basic input text kubeconfig -f "$HOME"/.kube/config + + # Up deployment + dagger -w "$DAGGER_SANDBOX" -e kube-kind-basic up + + # Check deployment + kubectl describe deployment todoapp | grep 'True' + + # Clean + kubectl delete deployments --all + kubectl delete services --all + + #################### DEPLOYMENT #################### + # Copy deployment to sandbox + copy_to_sandbox kube-kind-deployment kube-kind + + # Add kubeconfig + dagger -w "$DAGGER_SANDBOX" -e kube-kind-deployment input text kubeconfig -f "$HOME"/.kube/config + + # Up deployment + dagger -w "$DAGGER_SANDBOX" -e kube-kind-deployment up + + # Check deployment + kubectl describe deployment todoapp | grep 'True' + + # Clean + kubectl delete deployments --all + kubectl delete services --all + + #################### CUE MANIFEST #################### + # Copy deployment to sandbox + copy_to_sandbox kube-kind-cue-manifest kube-kind + + # Add kubeconfig + dagger -w "$DAGGER_SANDBOX" -e kube-kind-cue-manifest input text kubeconfig -f "$HOME"/.kube/config + + # Up deployment + dagger -w "$DAGGER_SANDBOX" -e kube-kind-cue-manifest up + + # Check deployment + kubectl describe deployment todoapp | grep 'True' + + # Clean + kubectl delete deployments --all + kubectl delete services --all +} + +@test "doc-1007-kube-aws" { + #################### BASIC #################### + # Copy deployment to sandbox + copy_to_sandbox kube-aws-basic kube-aws + + # Up deployment + dagger -w "$DAGGER_SANDBOX" -e kube-aws-basic up + + #################### DEPLOYMENT #################### + # Copy deployment to sandbox + copy_to_sandbox kube-aws-deployment kube-aws + + # Up deployment + dagger -w "$DAGGER_SANDBOX" -e kube-aws-deployment up + #################### CUE MANIFEST #################### + # Copy deployment to sandbox + copy_to_sandbox kube-aws-cue-manifest kube-aws + + # Up deployment + dagger -w "$DAGGER_SANDBOX" -e kube-aws-cue-manifest up +} + +@test "doc-1007-kube-gcp" { + #################### BASIC #################### + # Copy deployment to sandbox + copy_to_sandbox kube-gcp-basic kube-gcp + + # Up deployment + dagger -w "$DAGGER_SANDBOX" -e kube-gcp-basic up + + #################### DEPLOYMENT #################### + # Copy deployment to sandbox + copy_to_sandbox kube-gcp-deployment kube-gcp + + # Up deployment + dagger -w "$DAGGER_SANDBOX" -e kube-gcp-deployment up + #################### CUE MANIFEST #################### + # Copy deployment to sandbox + copy_to_sandbox kube-gcp-cue-manifest kube-gcp + + # Up deployment + dagger -w "$DAGGER_SANDBOX" -e kube-gcp-cue-manifest up +} + +@test "doc-1008-aws-cloudformation" { + skip_unless_local_localstack + setup_example_sandbox + + ### Create a basic plan + ## Construct + mkdir -p "$DAGGER_SANDBOX"/cloudformation + cp "$DAGGER_WORKSPACE"/cloudformation/template.cue "$DAGGER_SANDBOX"/cloudformation + + # Cloudformation relay + dagger -w "$DAGGER_SANDBOX" doc alpha.dagger.io/aws/cloudformation + cp "$DAGGER_WORKSPACE"/cloudformation/source-begin.cue "$DAGGER_SANDBOX"/cloudformation/source.cue + + # Initialize new env + dagger -w "$DAGGER_SANDBOX" new 'cloudformation' -p "$DAGGER_SANDBOX"/cloudformation + + # Finish template setup + cp "$DAGGER_WORKSPACE"/cloudformation/source-end.cue "$DAGGER_SANDBOX"/cloudformation/source.cue + + # Copy corresponding env + cp -r "$DAGGER_WORKSPACE"/.dagger/env/cloudformation "$DAGGER_SANDBOX"/.dagger/env/ + + # Run test + dagger -w "$DAGGER_SANDBOX" -e cloudformation up + stackName=$(dagger -w "$DAGGER_SANDBOX" -e cloudformation query cfnStackName -f text) + + ## Cleanup + # Place back empty source + cp "$DAGGER_WORKSPACE"/cloudformation/source-begin.cue "$DAGGER_SANDBOX"/cloudformation/source.cue + cp "$DAGGER_WORKSPACE"/cloudformation/deletion.cue "$DAGGER_SANDBOX"/cloudformation/deletion.cue + # Prepare and run cloudformation cleanup + dagger -w "$DAGGER_SANDBOX" -e cloudformation input text stackRemoval.stackName "$stackName" + dagger -w "$DAGGER_SANDBOX" -e cloudformation up + + ### Template part + ## Create convert.cue + cp "$DAGGER_WORKSPACE"/cloudformation/template/convert.cue "$DAGGER_SANDBOX"/cloudformation/convert.cue + rm "$DAGGER_SANDBOX"/cloudformation/source.cue "$DAGGER_SANDBOX"/cloudformation/deletion.cue + + ## Retrieve Unmarshalled JSON + dagger -w "$DAGGER_SANDBOX" query -e cloudformation s3Template + + ## Remove convert.cue + rm "$DAGGER_SANDBOX"/cloudformation/convert.cue + + ## Store the output + cp "$DAGGER_WORKSPACE"/cloudformation/template/template-begin.cue "$DAGGER_SANDBOX"/cloudformation/template.cue + + # Inspect conf + dagger -w "$DAGGER_SANDBOX" query -e cloudformation template -f text + + cp "$DAGGER_WORKSPACE"/cloudformation/template/deployment.cue "$DAGGER_SANDBOX"/cloudformation/deployment.cue + cp "$DAGGER_WORKSPACE"/cloudformation/template/template-end.cue "$DAGGER_SANDBOX"/cloudformation/template.cue + cp "$DAGGER_WORKSPACE"/cloudformation/source-end.cue "$DAGGER_SANDBOX"/cloudformation/source.cue + + # Deploy again + dagger -w "$DAGGER_SANDBOX" -e cloudformation query template -f text + dagger -w "$DAGGER_SANDBOX" -e cloudformation up + dagger -w "$DAGGER_SANDBOX" -e cloudformation output list + + ## Cleanup again + stackName=$(dagger -w "$DAGGER_SANDBOX" -e cloudformation query cfnStackName -f text) + rm -rf "$DAGGER_SANDBOX"/cloudformation/* + + # Place back empty source + cp "$DAGGER_WORKSPACE"/cloudformation/source-begin.cue "$DAGGER_SANDBOX"/cloudformation/source.cue + cp "$DAGGER_WORKSPACE"/cloudformation/deletion.cue "$DAGGER_SANDBOX"/cloudformation/deletion.cue + + # Prepare and run cloudformation cleanup + dagger -w "$DAGGER_SANDBOX" -e cloudformation input text stackRemoval.stackName "$stackName" + dagger -w "$DAGGER_SANDBOX" -e cloudformation up +} + +@test "doc-1010-dev-cue-package" { + # Initializing workspace + mkdir -p "$DAGGER_SANDBOX"/workspace + + # Writing package + # dagger init # The sandbox is already init + mkdir -p "$DAGGER_SANDBOX"/cue.mod/pkg/github.com/tjovicic/gcpcloudrun + cp "$DAGGER_WORKSPACE"/dev-cue-package/source.cue "$DAGGER_SANDBOX"/cue.mod/pkg/github.com/tjovicic/gcpcloudrun/source.cue + cp "$DAGGER_WORKSPACE"/dev-cue-package/script.sh "$DAGGER_SANDBOX"/workspace/script.sh + + # We remove the last line of the script, as bats cannot expand dagger + # to dagger() bats helper func inside bash files + sed '$d' <"$DAGGER_SANDBOX"/workspace/script.sh >"$DAGGER_SANDBOX"/tmpFile + mv "$DAGGER_SANDBOX"/tmpFile "$DAGGER_SANDBOX"/workspace/script.sh + + chmod +x "$DAGGER_SANDBOX"/workspace/script.sh + "$DAGGER_SANDBOX"/workspace/script.sh + + # Sync file from documentation + rsync -a test "$DAGGER_SANDBOX" + + # Command removed from script.sh above + dagger -w "$DAGGER_SANDBOX" new staging -p "$DAGGER_SANDBOX"/test + run dagger up -w "$DAGGER_SANDBOX" -e staging + assert_output --partial "input=run.gcpConfig.serviceKey" + + # Clean script.sh output + rm -rf ./test +} diff --git a/docs/learn/tests/gcpcloudrun/source.cue b/docs/learn/tests/gcpcloudrun/source.cue new file mode 100644 index 00000000..f0ee785d --- /dev/null +++ b/docs/learn/tests/gcpcloudrun/source.cue @@ -0,0 +1,39 @@ +package gcpcloudrun + +import ( + "alpha.dagger.io/dagger" + "alpha.dagger.io/docker" + "alpha.dagger.io/gcp" + "alpha.dagger.io/gcp/cloudrun" + "alpha.dagger.io/gcp/gcr" +) + +// Source code of the sample application +src: dagger.#Artifact & dagger.#Input + +// GCR full image name +imageRef: string & dagger.#Input + +image: docker.#Build & { + source: src +} + +gcpConfig: gcp.#Config + +creds: gcr.#Credentials & { + config: gcpConfig +} + +push: docker.#Push & { + target: imageRef + source: image + auth: { + username: creds.username + secret: creds.secret + } +} + +deploy: cloudrun.#Service & { + config: gcpConfig + image: push.ref +} diff --git a/docs/learn/tests/helpers.bash b/docs/learn/tests/helpers.bash new file mode 100644 index 00000000..a59efdc7 --- /dev/null +++ b/docs/learn/tests/helpers.bash @@ -0,0 +1,94 @@ +## Doc commands are being extracted from this file and helpers. +## Indentation is important, please append at the end + +common_setup() { + load 'node_modules/bats-support/load' + load 'node_modules/bats-assert/load' + + # Dagger Binary + # FIXME: `command -v` must be wrapped in a sub-bash, + # otherwise infinite recursion when DAGGER_BINARY is not set. + export DAGGER="${DAGGER_BINARY:-$(bash -c 'command -v dagger')}" + + # Set the workspace to the universe directory (so tests can run from anywhere) + UNIVERSE="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )" + DAGGER_WORKSPACE="$UNIVERSE" + export DAGGER_WORKSPACE + + # Force pretty printing for error reporting + DAGGER_LOG_FORMAT="pretty" + export DAGGER_LOG_FORMAT + + # Sandbox workspace. + DAGGER_SANDBOX="$(mktemp -d -t dagger-workspace-XXXXXX)" + export DAGGER_SANDBOX + dagger init -w "$DAGGER_SANDBOX" + + # allows the use of `sops` + SOPS_AGE_KEY_FILE=~/.config/dagger/keys.txt + export SOPS_AGE_KEY_FILE +} + +# dagger helper to execute the right binary +dagger() { + "${DAGGER}" "$@" +} + +# Setup sandbox for dagger example +# It clones the example repository and update Sandbox to +setup_example_sandbox() { + git -C "$DAGGER_SANDBOX" clone https://github.com/dagger/examples + + export DAGGER_SANDBOX="$DAGGER_SANDBOX"/examples/todoapp +} + + +# copy an environment from the current workspace to the sandbox. +# +# this is needed if the test requires altering inputs without dirtying the +# current environment. +# Usage: +# copy_to_sandbox myenv +# dagger input secret -w "$DAGGER_SANDBOX" -e myenv "temporary change" +# dagger up -w "$DAGGER_SANDBOX" -e myenv +# +# To use testdata directory in tests, add the package name as second flag +# Usage: +# copy_to_sandbox myenv mypackage +copy_to_sandbox() { + local name="$1" + local source="$DAGGER_WORKSPACE"/.dagger/env/"$name" + local target="$DAGGER_SANDBOX"/.dagger/env/"$name" + + cp -a "$source" "$target" + + if [ -d "$2" ]; then + local package="$2" + local source_package="$DAGGER_WORKSPACE"/"$package" + local target_package="$DAGGER_SANDBOX"/ + + cp -a "$source_package" "$target_package" + fi +} + +# Check if there is a localstack instance. +# +# This is needed to do docs test in the CI. +skip_unless_local_localstack() { + if [ "$(curl -s http://localhost:4566)" = '{"status": "running"}' ]; then + echo "Localstack available" + else + skip "Localstack not available" + fi +} + +# Check if there is a local kubernetes cluster. +# +# This is need to do kubernetes test in the CI. +skip_unless_local_kube() { + if [ -f ~/.kube/config ] && grep -q "127.0.0.1" ~/.kube/config &> /dev/null; then + echo "Kubernetes available" + else + skip "local kubernetes cluster not available" + fi +} \ No newline at end of file diff --git a/docs/learn/tests/kube-aws/basic/config.cue b/docs/learn/tests/kube-aws/basic/config.cue new file mode 100644 index 00000000..e927e6fe --- /dev/null +++ b/docs/learn/tests/kube-aws/basic/config.cue @@ -0,0 +1,18 @@ +package main + +import ( + "alpha.dagger.io/aws" + "alpha.dagger.io/aws/eks" +) + +// Value created for generic reference of `kubeconfig` in `todoapp.cue` +kubeconfig: eksConfig.kubeconfig + +// awsConfig for Amazon connection +awsConfig: aws.#Config + +// eksConfig used for deployment +eksConfig: eks.#KubeConfig & { + // config field references `gkeConfig` value to set in once + config: awsConfig +} diff --git a/docs/learn/tests/kube-aws/basic/input.cue b/docs/learn/tests/kube-aws/basic/input.cue new file mode 100644 index 00000000..95c4430a --- /dev/null +++ b/docs/learn/tests/kube-aws/basic/input.cue @@ -0,0 +1,11 @@ +package main + +import ( + "alpha.dagger.io/git" +) + +manifest: git.#Repository & { + remote: "https://github.com/dagger/examples.git" + ref: "main" + subdir: "todoapp/k8s" +} diff --git a/docs/learn/tests/kube-aws/basic/test/test.cue b/docs/learn/tests/kube-aws/basic/test/test.cue new file mode 100644 index 00000000..7e5fcecb --- /dev/null +++ b/docs/learn/tests/kube-aws/basic/test/test.cue @@ -0,0 +1,66 @@ +package main + +import ( + "alpha.dagger.io/dagger/op" + "alpha.dagger.io/kubernetes" +) + +TestEks: { + #_GetDeployment: """ + kubectl describe deployment todoapp | grep 'True' + """ + + #_DeleteDeployment: """ + kubectl delete deployment todoapp + kubectl delete service todoapp-service + """ + + #up: [ + op.#Load & { + from: kubernetes.#Kubectl + }, + + op.#WriteFile & { + dest: "/kubeconfig" + content: todoApp.kubeconfig + }, + + op.#WriteFile & { + dest: "/getPods.sh" + content: #_GetDeployment + }, + + op.#WriteFile & { + dest: "/deletePods.sh" + content: #_DeleteDeployment + }, + + // Get pods + op.#Exec & { + always: true + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/getPods.sh", + ] + env: KUBECONFIG: "/kubeconfig" + }, + + // Delete pods + op.#Exec & { + always: true + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/deletePods.sh", + ] + env: KUBECONFIG: "/kubeconfig" + }, + ] +} diff --git a/docs/learn/tests/kube-aws/basic/todoapp.cue b/docs/learn/tests/kube-aws/basic/todoapp.cue new file mode 100644 index 00000000..878f3f85 --- /dev/null +++ b/docs/learn/tests/kube-aws/basic/todoapp.cue @@ -0,0 +1,16 @@ +package main + +import ( + "alpha.dagger.io/dagger" + "alpha.dagger.io/kubernetes" +) + +// input: kubernetes objects directory to deploy to +// set with `dagger input dir manifest ./k8s -e kube` +manifest: dagger.#Artifact & dagger.#Input + +// Deploy the manifest to a kubernetes cluster +todoApp: kubernetes.#Resources & { + "kubeconfig": kubeconfig + source: manifest +} diff --git a/docs/learn/tests/kube-aws/cue-manifest/config.cue b/docs/learn/tests/kube-aws/cue-manifest/config.cue new file mode 100644 index 00000000..568ad9eb --- /dev/null +++ b/docs/learn/tests/kube-aws/cue-manifest/config.cue @@ -0,0 +1,25 @@ +package main + +import ( + "alpha.dagger.io/aws" + "alpha.dagger.io/aws/eks" + "alpha.dagger.io/aws/ecr" +) + +// Value created for generic reference of `kubeconfig` in `todoapp.cue` +kubeconfig: eksConfig.kubeconfig + +// awsConfig for Amazon connection +awsConfig: aws.#Config + +// eksConfig used for deployment +eksConfig: eks.#KubeConfig & { + // config field references `awsConfig` value to set in once + config: awsConfig +} + +// ecrCreds used for remote image push +ecrCreds: ecr.#Credentials & { + // config field references `awsConfig` value to set in once + config: awsConfig +} diff --git a/docs/learn/tests/kube-aws/cue-manifest/deployment.cue b/docs/learn/tests/kube-aws/cue-manifest/deployment.cue new file mode 100644 index 00000000..88d7b800 --- /dev/null +++ b/docs/learn/tests/kube-aws/cue-manifest/deployment.cue @@ -0,0 +1,43 @@ +package main + +// Deployment template containing all the common boilerplate shared by +// deployments of this application. +#Deployment: { + // Name of the deployment. This will be used to label resources automatically + // and generate selectors. + name: string + + // Container image. + image: string + + // 80 is the default port. + port: *80 | int + + // 1 is the default, but we allow any number. + replicas: *1 | int + + // Deployment manifest. Uses the name, image, port and replicas above to + // generate the resource manifest. + manifest: { + apiVersion: "apps/v1" + kind: "Deployment" + metadata: { + "name": name + labels: app: name + } + spec: { + "replicas": replicas + selector: matchLabels: app: name + template: { + metadata: labels: app: name + spec: containers: [{ + "name": name + "image": image + ports: [{ + containerPort: port + }] + }] + } + } + } +} diff --git a/docs/learn/tests/kube-aws/cue-manifest/input.cue b/docs/learn/tests/kube-aws/cue-manifest/input.cue new file mode 100644 index 00000000..1e21ec3d --- /dev/null +++ b/docs/learn/tests/kube-aws/cue-manifest/input.cue @@ -0,0 +1,13 @@ +package main + +import ( + "alpha.dagger.io/git" +) + +repository: git.#Repository & { + remote: "https://github.com/dagger/examples.git" + ref: "main" + subdir: "todoapp" +} + +registry: "125635003186.dkr.ecr.\(awsConfig.region).amazonaws.com/dagger-ci" diff --git a/docs/learn/tests/kube-aws/cue-manifest/manifest.cue b/docs/learn/tests/kube-aws/cue-manifest/manifest.cue new file mode 100644 index 00000000..df4ff0d9 --- /dev/null +++ b/docs/learn/tests/kube-aws/cue-manifest/manifest.cue @@ -0,0 +1,29 @@ +package main + +import ( + "encoding/yaml" +) + +// Define and generate kubernetes deployment to deploy to kubernetes cluster +#AppManifest: { + // Name of the application + name: string + + // Image to deploy to + image: string + + // Define a kubernetes deployment object + deployment: #Deployment & { + "name": name + "image": image + } + + // Define a kubernetes service object + service: #Service & { + "name": name + ports: http: deployment.port + } + + // Merge definitions and convert them back from CUE to YAML + manifest: yaml.MarshalStream([deployment.manifest, service.manifest]) +} diff --git a/docs/learn/tests/kube-aws/cue-manifest/service.cue b/docs/learn/tests/kube-aws/cue-manifest/service.cue new file mode 100644 index 00000000..8c5dc957 --- /dev/null +++ b/docs/learn/tests/kube-aws/cue-manifest/service.cue @@ -0,0 +1,36 @@ +package main + +// Service template containing all the common boilerplate shared by +// services of this application. +#Service: { + // Name of the service. This will be used to label resources automatically + // and generate selector. + name: string + + // NodePort is the default service type. + type: *"NodePort" | "LoadBalancer" | "ClusterIP" | "ExternalName" + + // Ports where the service should listen + ports: [string]: number + + // Service manifest. Uses the name, type and ports above to + // generate the resource manifest. + manifest: { + apiVersion: "v1" + kind: "Service" + metadata: { + "name": "\(name)-service" + labels: app: name + } + spec: { + "type": type + "ports": [ + for k, v in ports { + name: k + port: v + }, + ] + selector: app: name + } + } +} diff --git a/docs/learn/tests/kube-aws/cue-manifest/test/test.cue b/docs/learn/tests/kube-aws/cue-manifest/test/test.cue new file mode 100644 index 00000000..82f2fb40 --- /dev/null +++ b/docs/learn/tests/kube-aws/cue-manifest/test/test.cue @@ -0,0 +1,66 @@ +package main + +import ( + "alpha.dagger.io/dagger/op" + "alpha.dagger.io/kubernetes" +) + +TestEks: { + #_GetDeployment: """ + kubectl describe deployment todoapp | grep 'True' + """ + + #_DeleteDeployment: """ + kubectl delete deployment todoapp + kubectl delete service todoapp-service + """ + + #up: [ + op.#Load & { + from: kubernetes.#Kubectl + }, + + op.#WriteFile & { + dest: "/kubeconfig" + content: todoApp.kubeSrc.kubeconfig + }, + + op.#WriteFile & { + dest: "/getPods.sh" + content: #_GetDeployment + }, + + op.#WriteFile & { + dest: "/deletePods.sh" + content: #_DeleteDeployment + }, + + // Get pods + op.#Exec & { + always: true + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/getPods.sh", + ] + env: KUBECONFIG: "/kubeconfig" + }, + + // Delete pods + op.#Exec & { + always: true + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/deletePods.sh", + ] + env: KUBECONFIG: "/kubeconfig" + }, + ] +} diff --git a/docs/learn/tests/kube-aws/cue-manifest/todoapp.cue b/docs/learn/tests/kube-aws/cue-manifest/todoapp.cue new file mode 100644 index 00000000..acd1b847 --- /dev/null +++ b/docs/learn/tests/kube-aws/cue-manifest/todoapp.cue @@ -0,0 +1,45 @@ +package main + +import ( + "alpha.dagger.io/dagger" + "alpha.dagger.io/docker" + "alpha.dagger.io/kubernetes" +) + +// input: source code repository, must contain a Dockerfile +// set with `dagger input dir repository . -e kube` +repository: dagger.#Artifact & dagger.#Input + +// ECR registry to push images to +registry: string & dagger.#Input +tag: "test-ecr" + +// Todoapp deployment pipeline +todoApp: { + // Build the image from repositoru artifact + image: docker.#Build & { + source: repository + } + + // Push image to registry + remoteImage: docker.#Push & { + target: "\(registry):\(tag)" + source: image + auth: { + username: ecrCreds.username + secret: ecrCreds.secret + } + } + + // Generate deployment manifest + deployment: #AppManifest & { + name: "todoapp" + image: remoteImage.ref + } + + // Deploy the customized manifest to a kubernetes cluster + kubeSrc: kubernetes.#Resources & { + "kubeconfig": kubeconfig + manifest: deployment.manifest + } +} diff --git a/docs/learn/tests/kube-aws/deployment/config.cue b/docs/learn/tests/kube-aws/deployment/config.cue new file mode 100644 index 00000000..568ad9eb --- /dev/null +++ b/docs/learn/tests/kube-aws/deployment/config.cue @@ -0,0 +1,25 @@ +package main + +import ( + "alpha.dagger.io/aws" + "alpha.dagger.io/aws/eks" + "alpha.dagger.io/aws/ecr" +) + +// Value created for generic reference of `kubeconfig` in `todoapp.cue` +kubeconfig: eksConfig.kubeconfig + +// awsConfig for Amazon connection +awsConfig: aws.#Config + +// eksConfig used for deployment +eksConfig: eks.#KubeConfig & { + // config field references `awsConfig` value to set in once + config: awsConfig +} + +// ecrCreds used for remote image push +ecrCreds: ecr.#Credentials & { + // config field references `awsConfig` value to set in once + config: awsConfig +} diff --git a/docs/learn/tests/kube-aws/deployment/input.cue b/docs/learn/tests/kube-aws/deployment/input.cue new file mode 100644 index 00000000..2fb57750 --- /dev/null +++ b/docs/learn/tests/kube-aws/deployment/input.cue @@ -0,0 +1,19 @@ +package main + +import ( + "alpha.dagger.io/git" +) + +manifest: git.#Repository & { + remote: "https://github.com/dagger/examples.git" + ref: "main" + subdir: "todoapp/k8s" +} + +repository: git.#Repository & { + remote: "https://github.com/dagger/examples.git" + ref: "main" + subdir: "todoapp" +} + +registry: "125635003186.dkr.ecr.\(awsConfig.region).amazonaws.com/dagger-ci" diff --git a/docs/learn/tests/kube-aws/deployment/test/test.cue b/docs/learn/tests/kube-aws/deployment/test/test.cue new file mode 100644 index 00000000..82f2fb40 --- /dev/null +++ b/docs/learn/tests/kube-aws/deployment/test/test.cue @@ -0,0 +1,66 @@ +package main + +import ( + "alpha.dagger.io/dagger/op" + "alpha.dagger.io/kubernetes" +) + +TestEks: { + #_GetDeployment: """ + kubectl describe deployment todoapp | grep 'True' + """ + + #_DeleteDeployment: """ + kubectl delete deployment todoapp + kubectl delete service todoapp-service + """ + + #up: [ + op.#Load & { + from: kubernetes.#Kubectl + }, + + op.#WriteFile & { + dest: "/kubeconfig" + content: todoApp.kubeSrc.kubeconfig + }, + + op.#WriteFile & { + dest: "/getPods.sh" + content: #_GetDeployment + }, + + op.#WriteFile & { + dest: "/deletePods.sh" + content: #_DeleteDeployment + }, + + // Get pods + op.#Exec & { + always: true + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/getPods.sh", + ] + env: KUBECONFIG: "/kubeconfig" + }, + + // Delete pods + op.#Exec & { + always: true + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/deletePods.sh", + ] + env: KUBECONFIG: "/kubeconfig" + }, + ] +} diff --git a/docs/learn/tests/kube-aws/deployment/todoapp.cue b/docs/learn/tests/kube-aws/deployment/todoapp.cue new file mode 100644 index 00000000..52e4770c --- /dev/null +++ b/docs/learn/tests/kube-aws/deployment/todoapp.cue @@ -0,0 +1,60 @@ +package main + +import ( + "encoding/yaml" + + "alpha.dagger.io/dagger" + "alpha.dagger.io/docker" + "alpha.dagger.io/kubernetes" + "alpha.dagger.io/kubernetes/kustomize" +) + +// input: source code repository, must contain a Dockerfile +// set with `dagger input dir repository . -e kube` +repository: dagger.#Artifact & dagger.#Input + +// ECR registry to push images to +registry: string & dagger.#Input +tag: "test-ecr" + +// source of Kube config file. +// set with `dagger input dir manifest ./k8s -e kube` +manifest: dagger.#Artifact & dagger.#Input + +todoApp: { + // Build an image from the project repository + image: docker.#Build & { + source: repository + } + + // Push the image to a remote registry + remoteImage: docker.#Push & { + target: "\(registry):\(tag)" + source: image + auth: { + username: ecrCreds.username + secret: ecrCreds.secret + } + } + + // Update the image of the deployment to the deployed image + kustomization: kustomize.#Kustomize & { + source: manifest + + // Convert CUE to YAML. + kustomization: yaml.Marshal({ + resources: ["deployment.yaml", "service.yaml"] + + images: [{ + name: "public.ecr.aws/j7f8d3t2/todoapp" + newName: remoteImage.ref + }] + }) + } + + // Value created for generic reference of `kubeconfig` in `todoapp.cue` + kubeSrc: kubernetes.#Resources & { + "kubeconfig": kubeconfig + source: kustomization + } +} diff --git a/docs/learn/tests/kube-gcp/basic/config.cue b/docs/learn/tests/kube-gcp/basic/config.cue new file mode 100644 index 00000000..5ed60309 --- /dev/null +++ b/docs/learn/tests/kube-gcp/basic/config.cue @@ -0,0 +1,18 @@ +package main + +import ( + "alpha.dagger.io/gcp" + "alpha.dagger.io/gcp/gke" +) + +// Value created for generic reference of `kubeconfig` in `todoapp.cue` +kubeconfig: gkeConfig.kubeconfig + +// gcpConfig used for Google connection +gcpConfig: gcp.#Config + +// gkeConfig used for deployment +gkeConfig: gke.#KubeConfig & { + // config field references `gkeConfig` value to set in once + config: gcpConfig +} diff --git a/docs/learn/tests/kube-gcp/basic/input.cue b/docs/learn/tests/kube-gcp/basic/input.cue new file mode 100644 index 00000000..95c4430a --- /dev/null +++ b/docs/learn/tests/kube-gcp/basic/input.cue @@ -0,0 +1,11 @@ +package main + +import ( + "alpha.dagger.io/git" +) + +manifest: git.#Repository & { + remote: "https://github.com/dagger/examples.git" + ref: "main" + subdir: "todoapp/k8s" +} diff --git a/docs/learn/tests/kube-gcp/basic/test/test.cue b/docs/learn/tests/kube-gcp/basic/test/test.cue new file mode 100644 index 00000000..7e5fcecb --- /dev/null +++ b/docs/learn/tests/kube-gcp/basic/test/test.cue @@ -0,0 +1,66 @@ +package main + +import ( + "alpha.dagger.io/dagger/op" + "alpha.dagger.io/kubernetes" +) + +TestEks: { + #_GetDeployment: """ + kubectl describe deployment todoapp | grep 'True' + """ + + #_DeleteDeployment: """ + kubectl delete deployment todoapp + kubectl delete service todoapp-service + """ + + #up: [ + op.#Load & { + from: kubernetes.#Kubectl + }, + + op.#WriteFile & { + dest: "/kubeconfig" + content: todoApp.kubeconfig + }, + + op.#WriteFile & { + dest: "/getPods.sh" + content: #_GetDeployment + }, + + op.#WriteFile & { + dest: "/deletePods.sh" + content: #_DeleteDeployment + }, + + // Get pods + op.#Exec & { + always: true + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/getPods.sh", + ] + env: KUBECONFIG: "/kubeconfig" + }, + + // Delete pods + op.#Exec & { + always: true + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/deletePods.sh", + ] + env: KUBECONFIG: "/kubeconfig" + }, + ] +} diff --git a/docs/learn/tests/kube-gcp/basic/todoapp.cue b/docs/learn/tests/kube-gcp/basic/todoapp.cue new file mode 100644 index 00000000..878f3f85 --- /dev/null +++ b/docs/learn/tests/kube-gcp/basic/todoapp.cue @@ -0,0 +1,16 @@ +package main + +import ( + "alpha.dagger.io/dagger" + "alpha.dagger.io/kubernetes" +) + +// input: kubernetes objects directory to deploy to +// set with `dagger input dir manifest ./k8s -e kube` +manifest: dagger.#Artifact & dagger.#Input + +// Deploy the manifest to a kubernetes cluster +todoApp: kubernetes.#Resources & { + "kubeconfig": kubeconfig + source: manifest +} diff --git a/docs/learn/tests/kube-gcp/cue-manifest/config.cue b/docs/learn/tests/kube-gcp/cue-manifest/config.cue new file mode 100644 index 00000000..844b77f3 --- /dev/null +++ b/docs/learn/tests/kube-gcp/cue-manifest/config.cue @@ -0,0 +1,25 @@ +package main + +import ( + "alpha.dagger.io/gcp" + "alpha.dagger.io/gcp/gcr" + "alpha.dagger.io/gcp/gke" +) + +// Value created for generic reference of `kubeconfig` in `todoapp.cue` +kubeconfig: gkeConfig.kubeconfig + +// gcpConfig used for Google connection +gcpConfig: gcp.#Config + +// gkeConfig used for deployment +gkeConfig: gke.#KubeConfig & { + // config field references `gkeConfig` value to set in once + config: gcpConfig +} + +// gcrCreds used for remote image push +gcrCreds: gcr.#Credentials & { + // config field references `gcpConfig` value to set in once + config: gcpConfig +} diff --git a/docs/learn/tests/kube-gcp/cue-manifest/deployment.cue b/docs/learn/tests/kube-gcp/cue-manifest/deployment.cue new file mode 100644 index 00000000..88d7b800 --- /dev/null +++ b/docs/learn/tests/kube-gcp/cue-manifest/deployment.cue @@ -0,0 +1,43 @@ +package main + +// Deployment template containing all the common boilerplate shared by +// deployments of this application. +#Deployment: { + // Name of the deployment. This will be used to label resources automatically + // and generate selectors. + name: string + + // Container image. + image: string + + // 80 is the default port. + port: *80 | int + + // 1 is the default, but we allow any number. + replicas: *1 | int + + // Deployment manifest. Uses the name, image, port and replicas above to + // generate the resource manifest. + manifest: { + apiVersion: "apps/v1" + kind: "Deployment" + metadata: { + "name": name + labels: app: name + } + spec: { + "replicas": replicas + selector: matchLabels: app: name + template: { + metadata: labels: app: name + spec: containers: [{ + "name": name + "image": image + ports: [{ + containerPort: port + }] + }] + } + } + } +} diff --git a/docs/learn/tests/kube-gcp/cue-manifest/input.cue b/docs/learn/tests/kube-gcp/cue-manifest/input.cue new file mode 100644 index 00000000..fa993210 --- /dev/null +++ b/docs/learn/tests/kube-gcp/cue-manifest/input.cue @@ -0,0 +1,19 @@ +package main + +import ( + "alpha.dagger.io/git" +) + +manifest: git.#Repository & { + remote: "https://github.com/dagger/examples.git" + ref: "main" + subdir: "todoapp/k8s" +} + +repository: git.#Repository & { + remote: "https://github.com/dagger/examples.git" + ref: "main" + subdir: "todoapp" +} + +registry: "gcr.io/dagger-ci/test" diff --git a/docs/learn/tests/kube-gcp/cue-manifest/manifest.cue b/docs/learn/tests/kube-gcp/cue-manifest/manifest.cue new file mode 100644 index 00000000..df4ff0d9 --- /dev/null +++ b/docs/learn/tests/kube-gcp/cue-manifest/manifest.cue @@ -0,0 +1,29 @@ +package main + +import ( + "encoding/yaml" +) + +// Define and generate kubernetes deployment to deploy to kubernetes cluster +#AppManifest: { + // Name of the application + name: string + + // Image to deploy to + image: string + + // Define a kubernetes deployment object + deployment: #Deployment & { + "name": name + "image": image + } + + // Define a kubernetes service object + service: #Service & { + "name": name + ports: http: deployment.port + } + + // Merge definitions and convert them back from CUE to YAML + manifest: yaml.MarshalStream([deployment.manifest, service.manifest]) +} diff --git a/docs/learn/tests/kube-gcp/cue-manifest/service.cue b/docs/learn/tests/kube-gcp/cue-manifest/service.cue new file mode 100644 index 00000000..8c5dc957 --- /dev/null +++ b/docs/learn/tests/kube-gcp/cue-manifest/service.cue @@ -0,0 +1,36 @@ +package main + +// Service template containing all the common boilerplate shared by +// services of this application. +#Service: { + // Name of the service. This will be used to label resources automatically + // and generate selector. + name: string + + // NodePort is the default service type. + type: *"NodePort" | "LoadBalancer" | "ClusterIP" | "ExternalName" + + // Ports where the service should listen + ports: [string]: number + + // Service manifest. Uses the name, type and ports above to + // generate the resource manifest. + manifest: { + apiVersion: "v1" + kind: "Service" + metadata: { + "name": "\(name)-service" + labels: app: name + } + spec: { + "type": type + "ports": [ + for k, v in ports { + name: k + port: v + }, + ] + selector: app: name + } + } +} diff --git a/docs/learn/tests/kube-gcp/cue-manifest/test/test.cue b/docs/learn/tests/kube-gcp/cue-manifest/test/test.cue new file mode 100644 index 00000000..82f2fb40 --- /dev/null +++ b/docs/learn/tests/kube-gcp/cue-manifest/test/test.cue @@ -0,0 +1,66 @@ +package main + +import ( + "alpha.dagger.io/dagger/op" + "alpha.dagger.io/kubernetes" +) + +TestEks: { + #_GetDeployment: """ + kubectl describe deployment todoapp | grep 'True' + """ + + #_DeleteDeployment: """ + kubectl delete deployment todoapp + kubectl delete service todoapp-service + """ + + #up: [ + op.#Load & { + from: kubernetes.#Kubectl + }, + + op.#WriteFile & { + dest: "/kubeconfig" + content: todoApp.kubeSrc.kubeconfig + }, + + op.#WriteFile & { + dest: "/getPods.sh" + content: #_GetDeployment + }, + + op.#WriteFile & { + dest: "/deletePods.sh" + content: #_DeleteDeployment + }, + + // Get pods + op.#Exec & { + always: true + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/getPods.sh", + ] + env: KUBECONFIG: "/kubeconfig" + }, + + // Delete pods + op.#Exec & { + always: true + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/deletePods.sh", + ] + env: KUBECONFIG: "/kubeconfig" + }, + ] +} diff --git a/docs/learn/tests/kube-gcp/cue-manifest/todoapp.cue b/docs/learn/tests/kube-gcp/cue-manifest/todoapp.cue new file mode 100644 index 00000000..42135f3f --- /dev/null +++ b/docs/learn/tests/kube-gcp/cue-manifest/todoapp.cue @@ -0,0 +1,45 @@ +package main + +import ( + "alpha.dagger.io/dagger" + "alpha.dagger.io/docker" + "alpha.dagger.io/kubernetes" +) + +// input: source code repository, must contain a Dockerfile +// set with `dagger input dir repository . -e kube` +repository: dagger.#Artifact & dagger.#Input + +// GCR registry to push images to +registry: string & dagger.#Input +tag: "test-gcr" + +// Todoapp deployment pipeline +todoApp: { + // Build the image from repositoru artifact + image: docker.#Build & { + source: repository + } + + // Push image to registry + remoteImage: docker.#Push & { + target: "\(registry):\(tag)" + source: image + auth: { + username: gcrCreds.username + secret: gcrCreds.secret + } + } + + // Generate deployment manifest + deployment: #AppManifest & { + name: "todoapp" + image: remoteImage.ref + } + + // Deploy the customized manifest to a kubernetes cluster + kubeSrc: kubernetes.#Resources & { + "kubeconfig": kubeconfig + manifest: deployment.manifest + } +} diff --git a/docs/learn/tests/kube-gcp/deployment/config.cue b/docs/learn/tests/kube-gcp/deployment/config.cue new file mode 100644 index 00000000..844b77f3 --- /dev/null +++ b/docs/learn/tests/kube-gcp/deployment/config.cue @@ -0,0 +1,25 @@ +package main + +import ( + "alpha.dagger.io/gcp" + "alpha.dagger.io/gcp/gcr" + "alpha.dagger.io/gcp/gke" +) + +// Value created for generic reference of `kubeconfig` in `todoapp.cue` +kubeconfig: gkeConfig.kubeconfig + +// gcpConfig used for Google connection +gcpConfig: gcp.#Config + +// gkeConfig used for deployment +gkeConfig: gke.#KubeConfig & { + // config field references `gkeConfig` value to set in once + config: gcpConfig +} + +// gcrCreds used for remote image push +gcrCreds: gcr.#Credentials & { + // config field references `gcpConfig` value to set in once + config: gcpConfig +} diff --git a/docs/learn/tests/kube-gcp/deployment/input.cue b/docs/learn/tests/kube-gcp/deployment/input.cue new file mode 100644 index 00000000..fa993210 --- /dev/null +++ b/docs/learn/tests/kube-gcp/deployment/input.cue @@ -0,0 +1,19 @@ +package main + +import ( + "alpha.dagger.io/git" +) + +manifest: git.#Repository & { + remote: "https://github.com/dagger/examples.git" + ref: "main" + subdir: "todoapp/k8s" +} + +repository: git.#Repository & { + remote: "https://github.com/dagger/examples.git" + ref: "main" + subdir: "todoapp" +} + +registry: "gcr.io/dagger-ci/test" diff --git a/docs/learn/tests/kube-gcp/deployment/test/test.cue b/docs/learn/tests/kube-gcp/deployment/test/test.cue new file mode 100644 index 00000000..82f2fb40 --- /dev/null +++ b/docs/learn/tests/kube-gcp/deployment/test/test.cue @@ -0,0 +1,66 @@ +package main + +import ( + "alpha.dagger.io/dagger/op" + "alpha.dagger.io/kubernetes" +) + +TestEks: { + #_GetDeployment: """ + kubectl describe deployment todoapp | grep 'True' + """ + + #_DeleteDeployment: """ + kubectl delete deployment todoapp + kubectl delete service todoapp-service + """ + + #up: [ + op.#Load & { + from: kubernetes.#Kubectl + }, + + op.#WriteFile & { + dest: "/kubeconfig" + content: todoApp.kubeSrc.kubeconfig + }, + + op.#WriteFile & { + dest: "/getPods.sh" + content: #_GetDeployment + }, + + op.#WriteFile & { + dest: "/deletePods.sh" + content: #_DeleteDeployment + }, + + // Get pods + op.#Exec & { + always: true + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/getPods.sh", + ] + env: KUBECONFIG: "/kubeconfig" + }, + + // Delete pods + op.#Exec & { + always: true + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/deletePods.sh", + ] + env: KUBECONFIG: "/kubeconfig" + }, + ] +} diff --git a/docs/learn/tests/kube-gcp/deployment/todoapp.cue b/docs/learn/tests/kube-gcp/deployment/todoapp.cue new file mode 100644 index 00000000..795cd91e --- /dev/null +++ b/docs/learn/tests/kube-gcp/deployment/todoapp.cue @@ -0,0 +1,61 @@ +package main + +import ( + "encoding/yaml" + + "alpha.dagger.io/dagger" + "alpha.dagger.io/docker" + "alpha.dagger.io/kubernetes" + "alpha.dagger.io/kubernetes/kustomize" +) + +// input: source code repository, must contain a Dockerfile +// set with `dagger input dir repository . -e kube` +repository: dagger.#Artifact & dagger.#Input + +// GCR registry to push images to +registry: string & dagger.#Input +tag: "test-gcr" + +// source of Kube config file. +// set with `dagger input dir manifest ./k8s -e kube` +manifest: dagger.#Artifact & dagger.#Input + +// Declarative name +todoApp: { + // Build an image from the project repository + image: docker.#Build & { + source: repository + } + + // Push the image to a remote registry + remoteImage: docker.#Push & { + target: "\(registry):\(tag)" + source: image + auth: { + username: gcrCreds.username + secret: gcrCreds.secret + } + } + + // Update the image of the deployment to the deployed image + kustomization: kustomize.#Kustomize & { + source: manifest + + // Convert CUE to YAML. + kustomization: yaml.Marshal({ + resources: ["deployment.yaml", "service.yaml"] + + images: [{ + name: "public.ecr.aws/j7f8d3t2/todoapp" + newName: remoteImage.ref + }] + }) + } + + // Value created for generic reference of `kubeconfig` in `todoapp.cue` + kubeSrc: kubernetes.#Resources & { + "kubeconfig": kubeconfig + source: kustomization + } +} diff --git a/docs/learn/tests/kube-kind/basic/input.cue b/docs/learn/tests/kube-kind/basic/input.cue new file mode 100644 index 00000000..95c4430a --- /dev/null +++ b/docs/learn/tests/kube-kind/basic/input.cue @@ -0,0 +1,11 @@ +package main + +import ( + "alpha.dagger.io/git" +) + +manifest: git.#Repository & { + remote: "https://github.com/dagger/examples.git" + ref: "main" + subdir: "todoapp/k8s" +} diff --git a/docs/learn/tests/kube-kind/basic/todoapp.cue b/docs/learn/tests/kube-kind/basic/todoapp.cue new file mode 100644 index 00000000..878f3f85 --- /dev/null +++ b/docs/learn/tests/kube-kind/basic/todoapp.cue @@ -0,0 +1,16 @@ +package main + +import ( + "alpha.dagger.io/dagger" + "alpha.dagger.io/kubernetes" +) + +// input: kubernetes objects directory to deploy to +// set with `dagger input dir manifest ./k8s -e kube` +manifest: dagger.#Artifact & dagger.#Input + +// Deploy the manifest to a kubernetes cluster +todoApp: kubernetes.#Resources & { + "kubeconfig": kubeconfig + source: manifest +} diff --git a/docs/learn/tests/kube-kind/config.cue b/docs/learn/tests/kube-kind/config.cue new file mode 100644 index 00000000..9169451d --- /dev/null +++ b/docs/learn/tests/kube-kind/config.cue @@ -0,0 +1,8 @@ +package main + +import ( + "alpha.dagger.io/dagger" +) + +// set with `dagger input text kubeconfig -f "$HOME"/.kube/config -e kube` +kubeconfig: string & dagger.#Input diff --git a/docs/learn/tests/kube-kind/cue-manifest/deployment.cue b/docs/learn/tests/kube-kind/cue-manifest/deployment.cue new file mode 100644 index 00000000..88d7b800 --- /dev/null +++ b/docs/learn/tests/kube-kind/cue-manifest/deployment.cue @@ -0,0 +1,43 @@ +package main + +// Deployment template containing all the common boilerplate shared by +// deployments of this application. +#Deployment: { + // Name of the deployment. This will be used to label resources automatically + // and generate selectors. + name: string + + // Container image. + image: string + + // 80 is the default port. + port: *80 | int + + // 1 is the default, but we allow any number. + replicas: *1 | int + + // Deployment manifest. Uses the name, image, port and replicas above to + // generate the resource manifest. + manifest: { + apiVersion: "apps/v1" + kind: "Deployment" + metadata: { + "name": name + labels: app: name + } + spec: { + "replicas": replicas + selector: matchLabels: app: name + template: { + metadata: labels: app: name + spec: containers: [{ + "name": name + "image": image + ports: [{ + containerPort: port + }] + }] + } + } + } +} diff --git a/docs/learn/tests/kube-kind/cue-manifest/input.cue b/docs/learn/tests/kube-kind/cue-manifest/input.cue new file mode 100644 index 00000000..c7249135 --- /dev/null +++ b/docs/learn/tests/kube-kind/cue-manifest/input.cue @@ -0,0 +1,11 @@ +package main + +import ( + "alpha.dagger.io/git" +) + +repository: git.#Repository & { + remote: "https://github.com/dagger/examples.git" + ref: "main" + subdir: "todoapp" +} diff --git a/docs/learn/tests/kube-kind/cue-manifest/manifest.cue b/docs/learn/tests/kube-kind/cue-manifest/manifest.cue new file mode 100644 index 00000000..df4ff0d9 --- /dev/null +++ b/docs/learn/tests/kube-kind/cue-manifest/manifest.cue @@ -0,0 +1,29 @@ +package main + +import ( + "encoding/yaml" +) + +// Define and generate kubernetes deployment to deploy to kubernetes cluster +#AppManifest: { + // Name of the application + name: string + + // Image to deploy to + image: string + + // Define a kubernetes deployment object + deployment: #Deployment & { + "name": name + "image": image + } + + // Define a kubernetes service object + service: #Service & { + "name": name + ports: http: deployment.port + } + + // Merge definitions and convert them back from CUE to YAML + manifest: yaml.MarshalStream([deployment.manifest, service.manifest]) +} diff --git a/docs/learn/tests/kube-kind/cue-manifest/service.cue b/docs/learn/tests/kube-kind/cue-manifest/service.cue new file mode 100644 index 00000000..8c5dc957 --- /dev/null +++ b/docs/learn/tests/kube-kind/cue-manifest/service.cue @@ -0,0 +1,36 @@ +package main + +// Service template containing all the common boilerplate shared by +// services of this application. +#Service: { + // Name of the service. This will be used to label resources automatically + // and generate selector. + name: string + + // NodePort is the default service type. + type: *"NodePort" | "LoadBalancer" | "ClusterIP" | "ExternalName" + + // Ports where the service should listen + ports: [string]: number + + // Service manifest. Uses the name, type and ports above to + // generate the resource manifest. + manifest: { + apiVersion: "v1" + kind: "Service" + metadata: { + "name": "\(name)-service" + labels: app: name + } + spec: { + "type": type + "ports": [ + for k, v in ports { + name: k + port: v + }, + ] + selector: app: name + } + } +} diff --git a/docs/learn/tests/kube-kind/cue-manifest/todoapp.cue b/docs/learn/tests/kube-kind/cue-manifest/todoapp.cue new file mode 100644 index 00000000..9ffdbe33 --- /dev/null +++ b/docs/learn/tests/kube-kind/cue-manifest/todoapp.cue @@ -0,0 +1,41 @@ +package main + +import ( + "alpha.dagger.io/dagger" + "alpha.dagger.io/docker" + "alpha.dagger.io/kubernetes" +) + +// input: source code repository, must contain a Dockerfile +// set with `dagger input dir repository . -e kube` +repository: dagger.#Artifact & dagger.#Input + +// Registry to push images to +registry: string & dagger.#Input +tag: "test-kind" + +// Todoapp deployment pipeline +todoApp: { + // Build the image from repositoru artifact + image: docker.#Build & { + source: repository + } + + // Push image to registry + remoteImage: docker.#Push & { + target: "\(registry):\(tag)" + source: image + } + + // Generate deployment manifest + deployment: #AppManifest & { + name: "todoapp" + image: remoteImage.ref + } + + // Deploy the customized manifest to a kubernetes cluster + kubeSrc: kubernetes.#Resources & { + "kubeconfig": kubeconfig + manifest: deployment.manifest + } +} diff --git a/docs/learn/tests/kube-kind/deployment/input.cue b/docs/learn/tests/kube-kind/deployment/input.cue new file mode 100644 index 00000000..75733e04 --- /dev/null +++ b/docs/learn/tests/kube-kind/deployment/input.cue @@ -0,0 +1,17 @@ +package main + +import ( + "alpha.dagger.io/git" +) + +manifest: git.#Repository & { + remote: "https://github.com/dagger/examples.git" + ref: "main" + subdir: "todoapp/k8s" +} + +repository: git.#Repository & { + remote: "https://github.com/dagger/examples.git" + ref: "main" + subdir: "todoapp" +} diff --git a/docs/learn/tests/kube-kind/deployment/todoapp.cue b/docs/learn/tests/kube-kind/deployment/todoapp.cue new file mode 100644 index 00000000..17c05df1 --- /dev/null +++ b/docs/learn/tests/kube-kind/deployment/todoapp.cue @@ -0,0 +1,57 @@ +package main + +import ( + "encoding/yaml" + + "alpha.dagger.io/dagger" + "alpha.dagger.io/docker" + "alpha.dagger.io/kubernetes" + "alpha.dagger.io/kubernetes/kustomize" +) + +// input: source code repository, must contain a Dockerfile +// set with `dagger input dir repository . -e kube` +repository: dagger.#Artifact & dagger.#Input + +// Registry to push images to +registry: string & dagger.#Input +tag: "test-kind" + +// input: kubernetes objects directory to deploy to +// set with `dagger input dir manifest ./k8s -e kube` +manifest: dagger.#Artifact & dagger.#Input + +// Todoapp deployment pipeline +todoApp: { + // Build the image from repositoru artifact + image: docker.#Build & { + source: repository + } + + // Push image to registry + remoteImage: docker.#Push & { + target: "\(registry):\(tag)" + source: image + } + + // Update the image from manifest to use the deployed one + kustomization: kustomize.#Kustomize & { + source: manifest + + // Convert CUE to YAML. + kustomization: yaml.Marshal({ + resources: ["deployment.yaml", "service.yaml"] + + images: [{ + name: "public.ecr.aws/j7f8d3t2/todoapp" + newName: remoteImage.ref + }] + }) + } + + // Deploy the customized manifest to a kubernetes cluster + kubeSrc: kubernetes.#Resources & { + "kubeconfig": kubeconfig + source: kustomization + } +} diff --git a/docs/learn/tests/multibucket/netlify.cue b/docs/learn/tests/multibucket/netlify.cue new file mode 100644 index 00000000..f133b0b5 --- /dev/null +++ b/docs/learn/tests/multibucket/netlify.cue @@ -0,0 +1,10 @@ +package multibucket + +import ( + "alpha.dagger.io/netlify" +) + +// Netlify site +site: "netlify": netlify.#Site & { + contents: app.build +} diff --git a/docs/learn/tests/multibucket/source.cue b/docs/learn/tests/multibucket/source.cue new file mode 100644 index 00000000..638c2dcc --- /dev/null +++ b/docs/learn/tests/multibucket/source.cue @@ -0,0 +1,8 @@ +package multibucket + +import ( + "alpha.dagger.io/dagger" +) + +// Source code of the sample application +src: dagger.#Artifact & dagger.#Input diff --git a/docs/learn/tests/multibucket/yarn.cue b/docs/learn/tests/multibucket/yarn.cue new file mode 100644 index 00000000..951ae321 --- /dev/null +++ b/docs/learn/tests/multibucket/yarn.cue @@ -0,0 +1,10 @@ +package multibucket + +import ( + "alpha.dagger.io/js/yarn" +) + +// Build the source code using Yarn +app: yarn.#Package & { + source: src +} diff --git a/docs/learn/tests/package.json b/docs/learn/tests/package.json new file mode 100644 index 00000000..805413da --- /dev/null +++ b/docs/learn/tests/package.json @@ -0,0 +1,12 @@ +{ + "license": "Apache-2.0", + "scripts": { + "test": "bats --report-formatter junit --jobs 4 ." + }, + "devDependencies": { + "bats": "https://github.com/bats-core/bats-core#master", + "bats-assert": "https://github.com/bats-core/bats-assert", + "bats-support": "https://github.com/bats-core/bats-support" + } +} + diff --git a/docs/learn/tests/yarn.lock b/docs/learn/tests/yarn.lock new file mode 100644 index 00000000..b2efa236 --- /dev/null +++ b/docs/learn/tests/yarn.lock @@ -0,0 +1,15 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"bats-assert@https://github.com/bats-core/bats-assert": + version "2.0.0" + resolved "https://github.com/bats-core/bats-assert#e0de84e9c011223e7f88b7ccf1c929f4327097ba" + +"bats-support@https://github.com/bats-core/bats-support": + version "0.3.0" + resolved "https://github.com/bats-core/bats-support#d140a65044b2d6810381935ae7f0c94c7023c8c3" + +"bats@https://github.com/bats-core/bats-core#master": + version "1.4.1" + resolved "https://github.com/bats-core/bats-core#7ff2f3efc738976feaccfdf374164b61599f9e36" diff --git a/stdlib/helpers.bash b/stdlib/helpers.bash index 252fc5c3..e61da042 100644 --- a/stdlib/helpers.bash +++ b/stdlib/helpers.bash @@ -58,6 +58,7 @@ copy_to_sandbox() { cp -a "$source_package" "$target_package" fi } + # Check if there is a localstack instance. # # This is needed to do docs test in the CI. diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 3e55821a..2253de8e 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -1,4 +1,5 @@ const path = require("path"); +const remarkCodeImport = require('remark-code-import'); /** @type {import('@docusaurus/types').DocusaurusConfig} */ module.exports = { @@ -83,6 +84,7 @@ module.exports = { sidebarPath: require.resolve("./sidebars.js"), editUrl: "https://github.com/dagger/dagger/blob/main", routeBasePath: "/", + remarkPlugins: [remarkCodeImport], }, theme: { customCss: require.resolve("./src/css/custom.scss"), diff --git a/website/package.json b/website/package.json index efe5f8da..21f6c033 100644 --- a/website/package.json +++ b/website/package.json @@ -31,6 +31,7 @@ "react-dom": "^17.0.1", "react-social-login-buttons": "^3.5.1", "sass": "^1.38.1", + "remark-code-import": "^0.3.0", "url-loader": "^4.1.1" }, "browserslist": { diff --git a/website/yarn.lock b/website/yarn.lock index 058a8c7d..88eb6641 100644 --- a/website/yarn.lock +++ b/website/yarn.lock @@ -7901,6 +7901,14 @@ remark-admonitions@^1.2.1: unified "^8.4.2" unist-util-visit "^2.0.1" +remark-code-import@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/remark-code-import/-/remark-code-import-0.3.0.tgz#adc5b407e98ba50ad633b696a7843268cb227430" + integrity sha512-OAidTyShEroWMVP/WDEeth+DtbpnfCiOA03sDK86/EH+tukTxZaKakzSM5YlU9pb38v9NAX6FztZTazXunSKjQ== + dependencies: + to-gatsby-remark-plugin "^0.1.0" + unist-util-visit "^2.0.1" + remark-emoji@^2.1.0: version "2.2.0" resolved "https://registry.yarnpkg.com/remark-emoji/-/remark-emoji-2.2.0.tgz#1c702090a1525da5b80e15a8f963ef2c8236cac7" @@ -8979,6 +8987,13 @@ to-fast-properties@^2.0.0: resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= +to-gatsby-remark-plugin@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/to-gatsby-remark-plugin/-/to-gatsby-remark-plugin-0.1.0.tgz#34167b2c3cf3209745cf97e5a488042586f9990d" + integrity sha512-blmhJ/gIrytWnWLgPSRCkhCPeki6UBK2daa3k9mGahN7GjwHu8KrS7F70MvwlsG7IE794JLgwAdCbi4hU4faFQ== + dependencies: + to-vfile "^6.1.0" + to-object-path@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" @@ -9016,6 +9031,14 @@ to-regex@^3.0.1, to-regex@^3.0.2: regex-not "^1.0.2" safe-regex "^1.1.0" +to-vfile@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/to-vfile/-/to-vfile-6.1.0.tgz#5f7a3f65813c2c4e34ee1f7643a5646344627699" + integrity sha512-BxX8EkCxOAZe+D/ToHdDsJcVI4HqQfmw0tCkp31zf3dNP/XWIAjU4CmeuSwsSoOzOTqHPOL0KUzyZqJplkD0Qw== + dependencies: + is-buffer "^2.0.0" + vfile "^4.0.0" + toidentifier@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553"