From b999a3dd11869969ee14fddb5ddcf45c9130e33f Mon Sep 17 00:00:00 2001 From: Tom Chauveau Date: Fri, 18 Jun 2021 17:53:50 +0200 Subject: [PATCH 01/14] Remove old stdlib tests Signed-off-by: Tom Chauveau --- tests/stdlib.bats | 89 +------------------ .../aws/eks/.dagger/env/default/.gitignore | 2 - .../aws/eks/.dagger/env/default/plan/eks.cue | 53 ----------- .../aws/eks/.dagger/env/default/values.yaml | 26 ------ tests/stdlib/aws/eks/eks.cue | 53 ----------- tests/stdlib/docker/build/Dockerfile | 2 - tests/stdlib/docker/build/build.cue | 31 ------- tests/stdlib/docker/dockerfile/dockerfile.cue | 34 ------- .../docker/dockerfile/testdata/test.txt | 1 - tests/stdlib/kubernetes/helm/helm.cue | 54 ----------- .../helm/testdata/mychart/.helmignore | 23 ----- .../helm/testdata/mychart/Chart.yaml | 21 ----- .../helm/testdata/mychart/templates/NOTES.txt | 21 ----- .../testdata/mychart/templates/_helpers.tpl | 63 ------------- .../mychart/templates/deployment.yaml | 55 ------------ .../testdata/mychart/templates/ingress.yaml | 41 --------- .../testdata/mychart/templates/service.yaml | 15 ---- .../mychart/templates/serviceaccount.yaml | 12 --- .../templates/tests/test-connection.yaml | 15 ---- .../helm/testdata/mychart/values.yaml | 68 -------------- tests/stdlib/kubernetes/helm/verify.cue | 51 ----------- tests/stdlib/kubernetes/kubernetes.cue | 44 --------- .../stdlib/kubernetes/kustomize/kustomize.cue | 32 ------- .../kustomize/testdata/deployment.yaml | 22 ----- .../kubernetes/kustomize/testdata/pod.yaml | 12 --- tests/stdlib/kubernetes/kustomize/verify.cue | 72 --------------- tests/stdlib/kubernetes/verify.cue | 79 ---------------- tests/stdlib/terraform/s3/inputs.yaml | 24 ----- tests/stdlib/terraform/s3/main.cue | 25 ------ tests/stdlib/terraform/s3/testdata/test.tf | 34 ------- 30 files changed, 1 insertion(+), 1073 deletions(-) delete mode 100644 tests/stdlib/aws/eks/.dagger/env/default/.gitignore delete mode 100644 tests/stdlib/aws/eks/.dagger/env/default/plan/eks.cue delete mode 100644 tests/stdlib/aws/eks/.dagger/env/default/values.yaml delete mode 100644 tests/stdlib/aws/eks/eks.cue delete mode 100644 tests/stdlib/docker/build/Dockerfile delete mode 100644 tests/stdlib/docker/build/build.cue delete mode 100644 tests/stdlib/docker/dockerfile/dockerfile.cue delete mode 100644 tests/stdlib/docker/dockerfile/testdata/test.txt delete mode 100644 tests/stdlib/kubernetes/helm/helm.cue delete mode 100644 tests/stdlib/kubernetes/helm/testdata/mychart/.helmignore delete mode 100644 tests/stdlib/kubernetes/helm/testdata/mychart/Chart.yaml delete mode 100644 tests/stdlib/kubernetes/helm/testdata/mychart/templates/NOTES.txt delete mode 100644 tests/stdlib/kubernetes/helm/testdata/mychart/templates/_helpers.tpl delete mode 100644 tests/stdlib/kubernetes/helm/testdata/mychart/templates/deployment.yaml delete mode 100644 tests/stdlib/kubernetes/helm/testdata/mychart/templates/ingress.yaml delete mode 100644 tests/stdlib/kubernetes/helm/testdata/mychart/templates/service.yaml delete mode 100644 tests/stdlib/kubernetes/helm/testdata/mychart/templates/serviceaccount.yaml delete mode 100644 tests/stdlib/kubernetes/helm/testdata/mychart/templates/tests/test-connection.yaml delete mode 100644 tests/stdlib/kubernetes/helm/testdata/mychart/values.yaml delete mode 100644 tests/stdlib/kubernetes/helm/verify.cue delete mode 100644 tests/stdlib/kubernetes/kubernetes.cue delete mode 100644 tests/stdlib/kubernetes/kustomize/kustomize.cue delete mode 100644 tests/stdlib/kubernetes/kustomize/testdata/deployment.yaml delete mode 100644 tests/stdlib/kubernetes/kustomize/testdata/pod.yaml delete mode 100644 tests/stdlib/kubernetes/kustomize/verify.cue delete mode 100644 tests/stdlib/kubernetes/verify.cue delete mode 100644 tests/stdlib/terraform/s3/inputs.yaml delete mode 100644 tests/stdlib/terraform/s3/main.cue delete mode 100644 tests/stdlib/terraform/s3/testdata/test.tf diff --git a/tests/stdlib.bats b/tests/stdlib.bats index 2e9f7295..dcdd715b 100644 --- a/tests/stdlib.bats +++ b/tests/stdlib.bats @@ -6,59 +6,7 @@ setup() { # FIXME: move to universe/universe.bats # Assigned to: -@test "stdlib: kubernetes" { - skip_unless_local_kube - - "$DAGGER" init - dagger_new_with_plan kubernetes "$TESTDIR"/stdlib/kubernetes/ - - run "$DAGGER" input -e "kubernetes" text kubeconfig -f ~/.kube/config - assert_success - - run "$DAGGER" up -e "kubernetes" - assert_success -} - -# FIXME: move to universe/universe.bats -# Assigned to: -@test "stdlib: kustomize" { - "$DAGGER" compute "$TESTDIR"/stdlib/kubernetes/kustomize --input-dir TestKustomize.kustom.source="$TESTDIR"/stdlib/kubernetes/kustomize/testdata -} - -# FIXME: move to universe/universe.bats -# Assigned to: -@test "stdlib: helm" { - skip "helm is broken" - skip_unless_local_kube - - "$DAGGER" init - dagger_new_with_plan helm "$TESTDIR"/stdlib/kubernetes/helm - - run "$DAGGER" input -e "helm" text kubeconfig -f ~/.kube/config - assert_success - - cp -R "$TESTDIR"/stdlib/kubernetes/helm/testdata/mychart "$DAGGER_WORKSPACE"/testdata - run "$DAGGER" input -e "helm" dir TestHelmSimpleChart.deploy.chartSource "$DAGGER_WORKSPACE"/testdata - assert_success - - run "$DAGGER" up -e "helm" - assert_success -} - -# FIXME: move to universe/universe.bats -# Assigned to: -@test "stdlib: docker: build" { - "$DAGGER" compute "$TESTDIR"/stdlib/docker/build/ --input-dir source="$TESTDIR"/stdlib/docker/build -} - -# FIXME: move to universe/universe.bats -# Assigned to: -@test "stdlib: docker: dockerfile" { - "$DAGGER" compute "$TESTDIR"/stdlib/docker/dockerfile/ --input-dir source="$TESTDIR"/stdlib/docker/dockerfile/testdata -} - -# FIXME: move to universe/universe.bats -# Assigned to: +# Changes in https://github.com/dagger/dagger/pull/628 @test "stdlib: docker: push-and-pull" { skip_unless_secrets_available "$TESTDIR"/stdlib/docker/push-pull/inputs.yaml @@ -66,38 +14,3 @@ setup() { run "$DAGGER" compute --input-yaml "$TESTDIR"/stdlib/docker/push-pull/inputs.yaml --input-dir source="$TESTDIR"/stdlib/docker/push-pull/testdata "$TESTDIR"/stdlib/docker/push-pull/ assert_success } - -# FIXME: move to universe/universe.bats -# Assigned to: -@test "stdlib: terraform" { - skip_unless_secrets_available "$TESTDIR"/stdlib/terraform/s3/inputs.yaml - - "$DAGGER" init - dagger_new_with_plan terraform "$TESTDIR"/stdlib/terraform/s3 - - cp -R "$TESTDIR"/stdlib/terraform/s3/testdata "$DAGGER_WORKSPACE"/testdata - "$DAGGER" -e terraform input dir TestData "$DAGGER_WORKSPACE"/testdata - sops -d "$TESTDIR"/stdlib/terraform/s3/inputs.yaml | "$DAGGER" -e "terraform" input yaml "" -f - - - # it must fail because of a missing var - run "$DAGGER" up -e terraform - assert_failure - - # add the var and try again - "$DAGGER" -e terraform input text TestTerraform.apply.tfvars.input "42" - run "$DAGGER" up -e terraform - assert_success - - # ensure the tfvar was passed correctly - run "$DAGGER" query -e terraform \ - TestTerraform.apply.output.input.value -f text - assert_success - assert_output "42" - - # ensure the random value is always the same - # this proves we're effectively using the s3 backend - run "$DAGGER" query -e terraform \ - TestTerraform.apply.output.random.value -f json - assert_success - assert_output "36" -} diff --git a/tests/stdlib/aws/eks/.dagger/env/default/.gitignore b/tests/stdlib/aws/eks/.dagger/env/default/.gitignore deleted file mode 100644 index 01ec19b0..00000000 --- a/tests/stdlib/aws/eks/.dagger/env/default/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# dagger state -state/** diff --git a/tests/stdlib/aws/eks/.dagger/env/default/plan/eks.cue b/tests/stdlib/aws/eks/.dagger/env/default/plan/eks.cue deleted file mode 100644 index d0a92e9d..00000000 --- a/tests/stdlib/aws/eks/.dagger/env/default/plan/eks.cue +++ /dev/null @@ -1,53 +0,0 @@ -package eks - -import ( - "dagger.io/aws" - "dagger.io/aws/eks" - "dagger.io/kubernetes" - "dagger.io/dagger/op" -) - -TestConfig: awsConfig: aws.#Config & { - region: "us-east-2" -} - -TestCluster: eks.#KubeConfig & { - config: TestConfig.awsConfig - clusterName: *"dagger-example-eks-cluster" | string -} - -TestEks: { - #GetPods: - """ - kubectl get pods -A - """ - - #up: [ - op.#Load & { - from: kubernetes.#Kubectl - }, - - op.#WriteFile & { - dest: "/kubeconfig" - content: TestCluster.kubeconfig - }, - - op.#WriteFile & { - dest: "/getPods.sh" - content: #GetPods - }, - - op.#Exec & { - always: true - args: [ - "/bin/bash", - "--noprofile", - "--norc", - "-eo", - "pipefail", - "/getPods.sh", - ] - env: KUBECONFIG: "/kubeconfig" - }, - ] -} diff --git a/tests/stdlib/aws/eks/.dagger/env/default/values.yaml b/tests/stdlib/aws/eks/.dagger/env/default/values.yaml deleted file mode 100644 index 0d793b24..00000000 --- a/tests/stdlib/aws/eks/.dagger/env/default/values.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: default -inputs: - TestConfig.awsConfig.accessKey: - secret: ENC[AES256_GCM,data:dzhlip9kKU8mMEycFjq6MobD5BA=,iv:LKeYUbXpnWIZneGs7DCLVKxv1W2aa/3EVGO4jnDlOgc=,tag:+TcxQahxFTweyoPaROTJSQ==,type:str] - TestConfig.awsConfig.secretKey: - secret: ENC[AES256_GCM,data:bu3AI5jODWv4ePvRKw2l/1UOuH07Z0/oB2hiY4QqrhTcfjdSbr6kBg==,iv:BqddzzXqvAv0cAj2SVhoFx/kUOnRsoevqMRujCINVv0=,tag:u0KjVnbN8h54CLFARJmJ0g==,type:str] -sops: - kms: [] - gcp_kms: [] - azure_kv: [] - hc_vault: [] - age: - - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk - enc: | - -----BEGIN AGE ENCRYPTED FILE----- - YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSAzV0ZXNW5qaGNJMjF5bnBO - d1Z1RXFhSnNRM1Vwa3lyWFJ6VVFDZTQ3cUhZClh0N1lxZ3dwSFhHTjRyS092OVVj - Tkw4ZlU4S3g0T1VGS1RYYnB1dGlzbVkKLS0tIEc4T1Z3SEU2NUNhd2FkSXlIUERM - UE5Cd2VwYkd1MHlTOXNJVEU3RVpqU2sK86kXU6ZaaVHTg9BuCEcOxnDrrW00+bwu - AHttbzqYVuC3YxXjOTzAZL8aYTStk14wGdI6TirZ9pX0fyaKAfzBUQ== - -----END AGE ENCRYPTED FILE----- - lastmodified: "2021-05-27T16:01:59Z" - mac: ENC[AES256_GCM,data:T+0rcT9Xi/kJ8+EzCd7ewenDmc1cH/t2MxCpf+QXkILUC/uE8OgROizDMAiUYI2HpeBfZrmUgLMVzlTZirIbC51eWLAf6itbSIGKkVuz0uSNwhRpKGAROg6U1h39Scg6RpAvpzSTZvYOx5SwP78Uc6NQdp5yTDEb+0e9Wqzu+jU=,iv:INAN+EPwBv5dWWHQnaMr4QOBQWx3WCcohORvIPrBZN8=,tag:N4vtDowFKTDSHmMob5HgCw==,type:str] - pgp: [] - encrypted_suffix: secret - version: 3.7.1 diff --git a/tests/stdlib/aws/eks/eks.cue b/tests/stdlib/aws/eks/eks.cue deleted file mode 100644 index 1bfc98a1..00000000 --- a/tests/stdlib/aws/eks/eks.cue +++ /dev/null @@ -1,53 +0,0 @@ -package eks - -import ( - "dagger.io/aws" - "dagger.io/aws/eks" - "dagger.io/kubernetes" - "dagger.io/dagger/op" -) - -TestConfig: awsConfig: aws.#Config & { - region: "us-east-2" -} - -TestCluster: eks.#KubeConfig & { - config: TestConfig.awsConfig - clusterName: *"dagger-example-eks-cluster" | string -} - -TestEks: { - #GetPods: - """ - kubectl get pods -A - """ - - #up: [ - op.#Load & { - from: kubernetes.#Kubectl - }, - - op.#WriteFile & { - dest: "/kubeconfig" - content: TestCluster.kubeconfig - }, - - op.#WriteFile & { - dest: "/getPods.sh" - content: #GetPods - }, - - op.#Exec & { - always: true - args: [ - "/bin/bash", - "--noprofile", - "--norc", - "-eo", - "pipefail", - "/getPods.sh", - ] - env: KUBECONFIG: "/kubeconfig" - }, - ] -} diff --git a/tests/stdlib/docker/build/Dockerfile b/tests/stdlib/docker/build/Dockerfile deleted file mode 100644 index 987ce9be..00000000 --- a/tests/stdlib/docker/build/Dockerfile +++ /dev/null @@ -1,2 +0,0 @@ -FROM alpine -RUN echo test >> /test.txt \ No newline at end of file diff --git a/tests/stdlib/docker/build/build.cue b/tests/stdlib/docker/build/build.cue deleted file mode 100644 index 58601432..00000000 --- a/tests/stdlib/docker/build/build.cue +++ /dev/null @@ -1,31 +0,0 @@ -package docker - -import ( - "dagger.io/dagger" - "dagger.io/dagger/op" - "dagger.io/docker" -) - -// Build a Docker image from source, using included Dockerfile -source: dagger.#Artifact - -TestBuild: { - image: docker.#Build & { - "source": source - } - - verify: #up: [ - op.#Load & { - from: image - }, - - op.#Exec & { - always: true - args: [ - "sh", "-c", """ - grep -q "test" /test.txt - """, - ] - }, - ] -} diff --git a/tests/stdlib/docker/dockerfile/dockerfile.cue b/tests/stdlib/docker/dockerfile/dockerfile.cue deleted file mode 100644 index 7f982ab7..00000000 --- a/tests/stdlib/docker/dockerfile/dockerfile.cue +++ /dev/null @@ -1,34 +0,0 @@ -package docker - -import ( - "dagger.io/dagger" - "dagger.io/dagger/op" - "dagger.io/docker" -) - -source: dagger.#Artifact - -TestImageFromDockerfile: { - image: docker.#ImageFromDockerfile & { - dockerfile: """ - FROM alpine - COPY test.txt /test.txt - """ - context: source - } - - verify: #up: [ - op.#Load & { - from: image - }, - - op.#Exec & { - always: true - args: [ - "sh", "-c", """ - grep -q "test" /test.txt - """, - ] - }, - ] -} diff --git a/tests/stdlib/docker/dockerfile/testdata/test.txt b/tests/stdlib/docker/dockerfile/testdata/test.txt deleted file mode 100644 index 30d74d25..00000000 --- a/tests/stdlib/docker/dockerfile/testdata/test.txt +++ /dev/null @@ -1 +0,0 @@ -test \ No newline at end of file diff --git a/tests/stdlib/kubernetes/helm/helm.cue b/tests/stdlib/kubernetes/helm/helm.cue deleted file mode 100644 index 518b0fb2..00000000 --- a/tests/stdlib/kubernetes/helm/helm.cue +++ /dev/null @@ -1,54 +0,0 @@ -package main - -import ( - "dagger.io/dagger" - "dagger.io/kubernetes/helm" - "dagger.io/random" -) - -// We assume that a kinD cluster is running locally -// To deploy a local KinD cluster, follow this link : https://kind.sigs.k8s.io/docs/user/quick-start/ -kubeconfig: string @dagger(input) - -// Deploy user local chart -TestHelmSimpleChart: { - suffix: random.#String & { - seed: "simple" - } - - // Deploy chart - deploy: helm.#Chart & { - name: "dagger-test-helm-simple-chart-\(suffix.out)" - namespace: "dagger-test" - "kubeconfig": kubeconfig - chartSource: dagger.#Artifact - } - - // Verify deployment - verify: #VerifyHelm & { - chartName: deploy.name - namespace: deploy.namespace - } -} - -// Deploy remote chart -TestHelmRepoChart: { - suffix: random.#String & { - seed: "repo" - } - - // Deploy chart - deploy: helm.#Chart & { - name: "dagger-test-helm-repository-\(suffix.out)" - namespace: "dagger-test" - "kubeconfig": kubeconfig - repository: "https://charts.bitnami.com/bitnami" - chart: "redis" - } - - // Verify deployment - verify: #VerifyHelm & { - chartName: deploy.name - namespace: deploy.namespace - } -} diff --git a/tests/stdlib/kubernetes/helm/testdata/mychart/.helmignore b/tests/stdlib/kubernetes/helm/testdata/mychart/.helmignore deleted file mode 100644 index 0e8a0eb3..00000000 --- a/tests/stdlib/kubernetes/helm/testdata/mychart/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/tests/stdlib/kubernetes/helm/testdata/mychart/Chart.yaml b/tests/stdlib/kubernetes/helm/testdata/mychart/Chart.yaml deleted file mode 100644 index 1613bff5..00000000 --- a/tests/stdlib/kubernetes/helm/testdata/mychart/Chart.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: v2 -name: mychart -description: A Helm chart for Kubernetes - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -version: 0.1.0 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. -appVersion: 1.16.0 diff --git a/tests/stdlib/kubernetes/helm/testdata/mychart/templates/NOTES.txt b/tests/stdlib/kubernetes/helm/testdata/mychart/templates/NOTES.txt deleted file mode 100644 index 8b795a8a..00000000 --- a/tests/stdlib/kubernetes/helm/testdata/mychart/templates/NOTES.txt +++ /dev/null @@ -1,21 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range $host := .Values.ingress.hosts }} - {{- range .paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} - {{- end }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "mychart.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "mychart.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "mychart.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "mychart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 -{{- end }} diff --git a/tests/stdlib/kubernetes/helm/testdata/mychart/templates/_helpers.tpl b/tests/stdlib/kubernetes/helm/testdata/mychart/templates/_helpers.tpl deleted file mode 100644 index 8479665d..00000000 --- a/tests/stdlib/kubernetes/helm/testdata/mychart/templates/_helpers.tpl +++ /dev/null @@ -1,63 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "mychart.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "mychart.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "mychart.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Common labels -*/}} -{{- define "mychart.labels" -}} -helm.sh/chart: {{ include "mychart.chart" . }} -{{ include "mychart.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end -}} - -{{/* -Selector labels -*/}} -{{- define "mychart.selectorLabels" -}} -app.kubernetes.io/name: {{ include "mychart.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end -}} - -{{/* -Create the name of the service account to use -*/}} -{{- define "mychart.serviceAccountName" -}} -{{- if .Values.serviceAccount.create -}} - {{ default (include "mychart.fullname" .) .Values.serviceAccount.name }} -{{- else -}} - {{ default "default" .Values.serviceAccount.name }} -{{- end -}} -{{- end -}} diff --git a/tests/stdlib/kubernetes/helm/testdata/mychart/templates/deployment.yaml b/tests/stdlib/kubernetes/helm/testdata/mychart/templates/deployment.yaml deleted file mode 100644 index 38e698f8..00000000 --- a/tests/stdlib/kubernetes/helm/testdata/mychart/templates/deployment.yaml +++ /dev/null @@ -1,55 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "mychart.fullname" . }} - labels: - {{- include "mychart.labels" . | nindent 4 }} -spec: - replicas: {{ .Values.replicaCount }} - selector: - matchLabels: - {{- include "mychart.selectorLabels" . | nindent 6 }} - template: - metadata: - labels: - {{- include "mychart.selectorLabels" . | nindent 8 }} - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "mychart.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - containers: - - name: {{ .Chart.Name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: 80 - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/tests/stdlib/kubernetes/helm/testdata/mychart/templates/ingress.yaml b/tests/stdlib/kubernetes/helm/testdata/mychart/templates/ingress.yaml deleted file mode 100644 index 76d277c0..00000000 --- a/tests/stdlib/kubernetes/helm/testdata/mychart/templates/ingress.yaml +++ /dev/null @@ -1,41 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "mychart.fullname" . -}} -{{- $svcPort := .Values.service.port -}} -{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: networking.k8s.io/v1beta1 -{{- else -}} -apiVersion: extensions/v1beta1 -{{- end }} -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - {{- include "mychart.labels" . | nindent 4 }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ .host | quote }} - http: - paths: - {{- range .paths }} - - path: {{ . }} - backend: - serviceName: {{ $fullName }} - servicePort: {{ $svcPort }} - {{- end }} - {{- end }} -{{- end }} diff --git a/tests/stdlib/kubernetes/helm/testdata/mychart/templates/service.yaml b/tests/stdlib/kubernetes/helm/testdata/mychart/templates/service.yaml deleted file mode 100644 index bdceb88f..00000000 --- a/tests/stdlib/kubernetes/helm/testdata/mychart/templates/service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "mychart.fullname" . }} - labels: - {{- include "mychart.labels" . | nindent 4 }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - {{- include "mychart.selectorLabels" . | nindent 4 }} diff --git a/tests/stdlib/kubernetes/helm/testdata/mychart/templates/serviceaccount.yaml b/tests/stdlib/kubernetes/helm/testdata/mychart/templates/serviceaccount.yaml deleted file mode 100644 index 145e891e..00000000 --- a/tests/stdlib/kubernetes/helm/testdata/mychart/templates/serviceaccount.yaml +++ /dev/null @@ -1,12 +0,0 @@ -{{- if .Values.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "mychart.serviceAccountName" . }} - labels: - {{- include "mychart.labels" . | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end -}} diff --git a/tests/stdlib/kubernetes/helm/testdata/mychart/templates/tests/test-connection.yaml b/tests/stdlib/kubernetes/helm/testdata/mychart/templates/tests/test-connection.yaml deleted file mode 100644 index 0bd46ef1..00000000 --- a/tests/stdlib/kubernetes/helm/testdata/mychart/templates/tests/test-connection.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ include "mychart.fullname" . }}-test-connection" - labels: - {{- include "mychart.labels" . | nindent 4 }} - annotations: - "helm.sh/hook": test-success -spec: - containers: - - name: wget - image: busybox - command: ['wget'] - args: ['{{ include "mychart.fullname" . }}:{{ .Values.service.port }}'] - restartPolicy: Never diff --git a/tests/stdlib/kubernetes/helm/testdata/mychart/values.yaml b/tests/stdlib/kubernetes/helm/testdata/mychart/values.yaml deleted file mode 100644 index dbf4257e..00000000 --- a/tests/stdlib/kubernetes/helm/testdata/mychart/values.yaml +++ /dev/null @@ -1,68 +0,0 @@ -# Default values for mychart. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -replicaCount: 1 - -image: - repository: nginx - pullPolicy: IfNotPresent - -imagePullSecrets: [] -nameOverride: "" -fullnameOverride: "" - -serviceAccount: - # Specifies whether a service account should be created - create: true - # Annotations to add to the service account - annotations: {} - # The name of the service account to use. - # If not set and create is true, a name is generated using the fullname template - name: - -podSecurityContext: {} - # fsGroup: 2000 - -securityContext: {} - # capabilities: - # drop: - # - ALL - # readOnlyRootFilesystem: true - # runAsNonRoot: true - # runAsUser: 1000 - -service: - type: ClusterIP - port: 80 - -ingress: - enabled: false - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - hosts: - - host: chart-example.local - paths: [] - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi - -nodeSelector: {} - -tolerations: [] - -affinity: {} diff --git a/tests/stdlib/kubernetes/helm/verify.cue b/tests/stdlib/kubernetes/helm/verify.cue deleted file mode 100644 index 71615eb6..00000000 --- a/tests/stdlib/kubernetes/helm/verify.cue +++ /dev/null @@ -1,51 +0,0 @@ -package main - -import ( - "dagger.io/dagger/op" - "dagger.io/kubernetes" -) - -#VerifyHelm: { - chartName: string - - namespace: string - - // Verify that pod exist - #getHelmPods: - """ - kubectl get pods --namespace "$KUBE_NAMESPACE" | grep "\(chartName)" - """ - - #up: [ - op.#Load & { - from: kubernetes.#Kubectl - }, - - op.#WriteFile & { - dest: "/getHelmPods.sh" - content: #getHelmPods - }, - - op.#WriteFile & { - dest: "/kubeconfig" - content: kubeconfig - mode: 0o600 - }, - - op.#Exec & { - always: true - args: [ - "/bin/bash", - "--noprofile", - "--norc", - "-eo", - "pipefail", - "/getHelmPods.sh", - ] - env: { - KUBECONFIG: "/kubeconfig" - KUBE_NAMESPACE: namespace - } - }, - ] -} diff --git a/tests/stdlib/kubernetes/kubernetes.cue b/tests/stdlib/kubernetes/kubernetes.cue deleted file mode 100644 index 0f254aa3..00000000 --- a/tests/stdlib/kubernetes/kubernetes.cue +++ /dev/null @@ -1,44 +0,0 @@ -package main - -import ( - "encoding/yaml" - "dagger.io/kubernetes" - "dagger.io/random" -) - -// We assume that a kinD cluster is running locally -// To deploy a local KinD cluster, follow this link : https://kind.sigs.k8s.io/docs/user/quick-start/ -kubeconfig: string @dagger(input) - -TestKubeApply: { - suffix: random.#String & { - seed: "" - } - - // Pod spec - kubeSrc: { - apiVersion: "v1" - kind: "Pod" - metadata: name: "kube-test-\(suffix.out)" - spec: { - restartPolicy: "Never" - containers: [{ - name: "test" - image: "hello-world" - }] - } - } - - // Apply deployment - apply: kubernetes.#Resources & { - "kubeconfig": kubeconfig - namespace: "dagger-test" - manifest: yaml.Marshal(kubeSrc) - } - - // Verify deployment - verify: #VerifyApply & { - podname: kubeSrc.metadata.name - namespace: apply.namespace - } -} diff --git a/tests/stdlib/kubernetes/kustomize/kustomize.cue b/tests/stdlib/kubernetes/kustomize/kustomize.cue deleted file mode 100644 index 2ebe0682..00000000 --- a/tests/stdlib/kubernetes/kustomize/kustomize.cue +++ /dev/null @@ -1,32 +0,0 @@ -package main - -import ( - "encoding/yaml" - "dagger.io/dagger" - "dagger.io/kubernetes/kustomize" -) - -TestKustomize: { - testdata: dagger.#Artifact - - // Run Kustomize - kustom: kustomize.#Kustomize & { - source: testdata - kustomization: yaml.Marshal({ - resources: ["deployment.yaml", "pod.yaml"] - images: [{ - name: "nginx" - newTag: "v1" - }] - replicas: [{ - name: "nginx-deployment" - count: 2 - }] - }) - } - - // Verify kustomization generation - verify: #VerifyKustomize & { - source: kustom - } -} diff --git a/tests/stdlib/kubernetes/kustomize/testdata/deployment.yaml b/tests/stdlib/kubernetes/kustomize/testdata/deployment.yaml deleted file mode 100644 index e47d13ff..00000000 --- a/tests/stdlib/kubernetes/kustomize/testdata/deployment.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: nginx-deployment - labels: - app: nginx-deployment -spec: - replicas: 1 - template: - metadata: - name: nginx-deployment - labels: - app: nginx-deployment - spec: - containers: - - name: nginx-deployment - image: nginx - imagePullPolicy: IfNotPresent - restartPolicy: Always - selector: - matchLabels: - app: nginx-deployment diff --git a/tests/stdlib/kubernetes/kustomize/testdata/pod.yaml b/tests/stdlib/kubernetes/kustomize/testdata/pod.yaml deleted file mode 100644 index 179e8199..00000000 --- a/tests/stdlib/kubernetes/kustomize/testdata/pod.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: test-pod - labels: - app: test-pod -spec: - containers: - - name: test-pod - image: nginx - imagePullPolicy: IfNotPresent - restartPolicy: Always diff --git a/tests/stdlib/kubernetes/kustomize/verify.cue b/tests/stdlib/kubernetes/kustomize/verify.cue deleted file mode 100644 index 48075413..00000000 --- a/tests/stdlib/kubernetes/kustomize/verify.cue +++ /dev/null @@ -1,72 +0,0 @@ -package main - -import ( - "dagger.io/dagger/op" - "dagger.io/dagger" - "dagger.io/alpine" -) - -#VerifyKustomize: { - source: dagger.#Artifact - - #up: [ - op.#Load & { - from: alpine.#Image & { - package: bash: "=~5.1" - } - }, - - // Check files - op.#Exec & { - always: true - args: [ - "sh", "-c", "test $(ls /source | wc -l) = 1", - ] - mount: "/source": from: source - }, - - // Check image tag kustomization - op.#Exec & { - always: true - args: [ - "sh", "-c", #""" - grep -q "\- image: nginx:v1" /source/result.yaml - """#, - ] - mount: "/source": from: source - }, - - // Check replicas kustomization - op.#Exec & { - always: true - args: [ - "sh", "-c", #""" - grep -q "replicas: 2" /source/result.yaml - """#, - ] - mount: "/source": from: source - }, - - // Check pod merge by kustomization - op.#Exec & { - always: true - args: [ - "sh", "-c", #""" - grep -q "kind: Pod" /source/result.yaml - """#, - ] - mount: "/source": from: source - }, - - // Check pod name - op.#Exec & { - always: true - args: [ - "sh", "-c", #""" - grep -q "name: test-pod" /source/result.yaml - """#, - ] - mount: "/source": from: source - }, - ] -} diff --git a/tests/stdlib/kubernetes/verify.cue b/tests/stdlib/kubernetes/verify.cue deleted file mode 100644 index 7a41cf84..00000000 --- a/tests/stdlib/kubernetes/verify.cue +++ /dev/null @@ -1,79 +0,0 @@ -package main - -import ( - "dagger.io/dagger/op" - "dagger.io/kubernetes" -) - -#VerifyApply: { - podname: string - - namespace: string - - // Verify that pod exist - #GetPods: - """ - kubectl get pods --namespace "$KUBE_NAMESPACE" \( podname ) - """ - - // Clear that pod for future test - #DeletePods: - """ - kubectl delete pods --namespace "$KUBE_NAMESPACE" \( podname ) - """ - - #up: [ - op.#Load & { - from: kubernetes.#Kubectl - }, - - op.#WriteFile & { - dest: "/kubeconfig" - content: kubeconfig - mode: 0o600 - }, - - op.#WriteFile & { - dest: "/getPods.sh" - content: #GetPods - }, - - // Check pods - op.#Exec & { - always: true - args: [ - "/bin/bash", - "--noprofile", - "--norc", - "-eo", - "pipefail", - "/getPods.sh", - ] - env: { - KUBECONFIG: "/kubeconfig" - KUBE_NAMESPACE: namespace - } - }, - - op.#WriteFile & { - dest: "/deletePods.sh" - content: #DeletePods - }, - - op.#Exec & { - always: true - args: [ - "/bin/bash", - "--noprofile", - "--norc", - "-eo", - "pipefail", - "/deletePods.sh", - ] - env: { - KUBECONFIG: "/kubeconfig" - KUBE_NAMESPACE: namespace - } - }, - ] -} diff --git a/tests/stdlib/terraform/s3/inputs.yaml b/tests/stdlib/terraform/s3/inputs.yaml deleted file mode 100644 index ef2355cf..00000000 --- a/tests/stdlib/terraform/s3/inputs.yaml +++ /dev/null @@ -1,24 +0,0 @@ -TestConfig: - awsConfig: - accessKey: ENC[AES256_GCM,data:cZLf9D1ymnU4A44oGiQ4fFKdEB0=,iv:rNv9rnXSvIpKeUYRqseS9aKjEG4Wim7OW0EKEbBgp+M=,tag:cOzI4KsDgCgi/w7ByFKJJw==,type:str] - secretKey: ENC[AES256_GCM,data:ZFIHfnQYYu7ZhoXogVIHbd2wakBTw9D0TiHeadSKaYAQemCun/egNg==,iv:zISyY5zGZHfe5HZJHdfIUpX6siFIgLMrwAbZRyLH9FU=,tag:uD+1eLHY/AKR9vnpyBh+GQ==,type:str] -sops: - kms: [] - gcp_kms: [] - azure_kv: [] - hc_vault: [] - age: - - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk - enc: | - -----BEGIN AGE ENCRYPTED FILE----- - YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBPdU5ENVpScm0yd2RXWjRJ - aSsxWTNvSHBBeU94Z2ZKNjhXdzJHZGNybXkwCk9FVW5EM21LSTRHMkE5VG1SRFpL - ZGUyOHl3MEU3M3ZXTzBqSlExTU1uVTgKLS0tIDZRVDJOaEVZVnVSalRKMUVTTytV - ZWRONHhmOEJVd1lqM1NkMFdSNHU2THMKSjtxHeq/ZSgpXrevLH4AVYyRh4jO6qjT - J301rFx0Cu5qeSIhRiG54Pse83GD+fObDhfH0nPf5HZttDZxrISUdg== - -----END AGE ENCRYPTED FILE----- - lastmodified: "2021-05-28T20:45:06Z" - mac: ENC[AES256_GCM,data:7b6X10McAD1qvsS3ZFWeteP7zLC6IAo6NdFjvaX1iyrjoZ+fT8hNkIPVKyfPFTqZzNIZ7qEYJO2PKrTjbhf6a1LEsL9gtfoX4JwINDk66TgIsJsvdp4TRIlEKoRSKK08zc+A5YFAtD1Pj+a3+NnF32ZUsoH+jqSixH2hK51RI0U=,iv:JKeSA0bp+QBE8H/kS/eIL47k1Bsg4L0q/YU4OlJmIKU=,tag:f3gzp/Nv4p4DajNfoAicAg==,type:str] - pgp: [] - unencrypted_suffix: _unencrypted - version: 3.7.1 diff --git a/tests/stdlib/terraform/s3/main.cue b/tests/stdlib/terraform/s3/main.cue deleted file mode 100644 index 244f000f..00000000 --- a/tests/stdlib/terraform/s3/main.cue +++ /dev/null @@ -1,25 +0,0 @@ -package testing - -import ( - "dagger.io/dagger" - - "dagger.io/terraform" -) - -TestData: dagger.#Artifact - -TestConfig: awsConfig: { - accessKey: string - secretkey: string - region: "us-east-2" -} - -TestTerraform: apply: terraform.#Configuration & { - source: TestData - env: { - AWS_ACCESS_KEY_ID: TestConfig.awsConfig.accessKey - AWS_SECRET_ACCESS_KEY: TestConfig.awsConfig.secretKey - AWS_DEFAULT_REGION: TestConfig.awsConfig.region - AWS_REGION: TestConfig.awsConfig.region - } -} diff --git a/tests/stdlib/terraform/s3/testdata/test.tf b/tests/stdlib/terraform/s3/testdata/test.tf deleted file mode 100644 index 878484e2..00000000 --- a/tests/stdlib/terraform/s3/testdata/test.tf +++ /dev/null @@ -1,34 +0,0 @@ -terraform { - required_providers { - random = { - source = "hashicorp/random" - version = "3.1.0" - } - } - - backend "s3" { - bucket = "dagger-ci" - key = "terraform/tfstate" - region = "us-east-2" - } -} - -provider "random" { -} - -variable "input" { - type = string -} - -resource "random_integer" "test" { - min = 1 - max = 50 -} - -output "random" { - value = random_integer.test.result -} - -output "input" { - value = var.input -} From 2e9a0d65098043d10976f273940d081de8f212c9 Mon Sep 17 00:00:00 2001 From: Tom Chauveau Date: Fri, 18 Jun 2021 18:03:59 +0200 Subject: [PATCH 02/14] Add test to universe Signed-off-by: Tom Chauveau --- stdlib/.dagger/env/aws-eks/.gitignore | 2 + stdlib/.dagger/env/aws-eks/plan/eks.cue | 53 +++++++++++++ stdlib/.dagger/env/aws-eks/values.yaml | 28 +++++++ stdlib/.dagger/env/docker-build/.gitignore | 2 + .../env/docker-build/plan/dockerfile.cue | 57 +++++++++++++ stdlib/.dagger/env/docker-build/values.yaml | 30 +++++++ stdlib/.dagger/env/git/values.yaml | 6 +- .../env/kubernetes-deployment/.gitignore | 2 + .../kubernetes-deployment/plan/kubernetes.cue | 44 +++++++++++ .../env/kubernetes-deployment/plan/verify.cue | 79 +++++++++++++++++++ .../env/kubernetes-deployment/values.yaml | 23 ++++++ stdlib/.dagger/env/kubernetes-helm/.gitignore | 2 + .../.dagger/env/kubernetes-helm/plan/helm.cue | 56 +++++++++++++ .../env/kubernetes-helm/plan/verify.cue | 51 ++++++++++++ .../.dagger/env/kubernetes-helm/values.yaml | 27 +++++++ .../env/kubernetes-kustomize/.gitignore | 2 + .../kubernetes-kustomize/plan/kustomize.cue | 32 ++++++++ .../env/kubernetes-kustomize/plan/verify.cue | 72 +++++++++++++++++ .../env/kubernetes-kustomize/values.yaml | 27 +++++++ stdlib/.dagger/env/terraform/.gitignore | 2 + .../.dagger/env/terraform/plan/terraform.cue | 74 +++++++++++++++++ stdlib/.dagger/env/terraform/values.yaml | 31 ++++++++ stdlib/docker/testdata/build/Dockerfile | 2 + stdlib/docker/testdata/dockerfile/test.txt | 1 + stdlib/helpers.bash | 11 +++ .../helm/testdata/mychart/.helmignore | 23 ++++++ .../helm/testdata/mychart/Chart.yaml | 21 +++++ .../helm/testdata/mychart/templates/NOTES.txt | 21 +++++ .../testdata/mychart/templates/_helpers.tpl | 63 +++++++++++++++ .../mychart/templates/deployment.yaml | 55 +++++++++++++ .../testdata/mychart/templates/ingress.yaml | 41 ++++++++++ .../testdata/mychart/templates/service.yaml | 15 ++++ .../mychart/templates/serviceaccount.yaml | 12 +++ .../templates/tests/test-connection.yaml | 15 ++++ .../helm/testdata/mychart/values.yaml | 68 ++++++++++++++++ .../kustomize/testdata/deployment.yaml | 22 ++++++ stdlib/kubernetes/kustomize/testdata/pod.yaml | 12 +++ stdlib/terraform/testdata/test.tf | 34 ++++++++ stdlib/universe.bats | 62 +++++++++++++++ tests/stdlib/terraform/s3/inputs.yaml | 24 ++++++ 40 files changed, 1202 insertions(+), 2 deletions(-) create mode 100644 stdlib/.dagger/env/aws-eks/.gitignore create mode 100644 stdlib/.dagger/env/aws-eks/plan/eks.cue create mode 100644 stdlib/.dagger/env/aws-eks/values.yaml create mode 100644 stdlib/.dagger/env/docker-build/.gitignore create mode 100644 stdlib/.dagger/env/docker-build/plan/dockerfile.cue create mode 100644 stdlib/.dagger/env/docker-build/values.yaml create mode 100644 stdlib/.dagger/env/kubernetes-deployment/.gitignore create mode 100644 stdlib/.dagger/env/kubernetes-deployment/plan/kubernetes.cue create mode 100644 stdlib/.dagger/env/kubernetes-deployment/plan/verify.cue create mode 100644 stdlib/.dagger/env/kubernetes-deployment/values.yaml create mode 100644 stdlib/.dagger/env/kubernetes-helm/.gitignore create mode 100644 stdlib/.dagger/env/kubernetes-helm/plan/helm.cue create mode 100644 stdlib/.dagger/env/kubernetes-helm/plan/verify.cue create mode 100644 stdlib/.dagger/env/kubernetes-helm/values.yaml create mode 100644 stdlib/.dagger/env/kubernetes-kustomize/.gitignore create mode 100644 stdlib/.dagger/env/kubernetes-kustomize/plan/kustomize.cue create mode 100644 stdlib/.dagger/env/kubernetes-kustomize/plan/verify.cue create mode 100644 stdlib/.dagger/env/kubernetes-kustomize/values.yaml create mode 100644 stdlib/.dagger/env/terraform/.gitignore create mode 100644 stdlib/.dagger/env/terraform/plan/terraform.cue create mode 100644 stdlib/.dagger/env/terraform/values.yaml create mode 100644 stdlib/docker/testdata/build/Dockerfile create mode 100644 stdlib/docker/testdata/dockerfile/test.txt create mode 100644 stdlib/kubernetes/helm/testdata/mychart/.helmignore create mode 100644 stdlib/kubernetes/helm/testdata/mychart/Chart.yaml create mode 100644 stdlib/kubernetes/helm/testdata/mychart/templates/NOTES.txt create mode 100644 stdlib/kubernetes/helm/testdata/mychart/templates/_helpers.tpl create mode 100644 stdlib/kubernetes/helm/testdata/mychart/templates/deployment.yaml create mode 100644 stdlib/kubernetes/helm/testdata/mychart/templates/ingress.yaml create mode 100644 stdlib/kubernetes/helm/testdata/mychart/templates/service.yaml create mode 100644 stdlib/kubernetes/helm/testdata/mychart/templates/serviceaccount.yaml create mode 100644 stdlib/kubernetes/helm/testdata/mychart/templates/tests/test-connection.yaml create mode 100644 stdlib/kubernetes/helm/testdata/mychart/values.yaml create mode 100644 stdlib/kubernetes/kustomize/testdata/deployment.yaml create mode 100644 stdlib/kubernetes/kustomize/testdata/pod.yaml create mode 100644 stdlib/terraform/testdata/test.tf create mode 100644 tests/stdlib/terraform/s3/inputs.yaml diff --git a/stdlib/.dagger/env/aws-eks/.gitignore b/stdlib/.dagger/env/aws-eks/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/stdlib/.dagger/env/aws-eks/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/stdlib/.dagger/env/aws-eks/plan/eks.cue b/stdlib/.dagger/env/aws-eks/plan/eks.cue new file mode 100644 index 00000000..d0a92e9d --- /dev/null +++ b/stdlib/.dagger/env/aws-eks/plan/eks.cue @@ -0,0 +1,53 @@ +package eks + +import ( + "dagger.io/aws" + "dagger.io/aws/eks" + "dagger.io/kubernetes" + "dagger.io/dagger/op" +) + +TestConfig: awsConfig: aws.#Config & { + region: "us-east-2" +} + +TestCluster: eks.#KubeConfig & { + config: TestConfig.awsConfig + clusterName: *"dagger-example-eks-cluster" | string +} + +TestEks: { + #GetPods: + """ + kubectl get pods -A + """ + + #up: [ + op.#Load & { + from: kubernetes.#Kubectl + }, + + op.#WriteFile & { + dest: "/kubeconfig" + content: TestCluster.kubeconfig + }, + + op.#WriteFile & { + dest: "/getPods.sh" + content: #GetPods + }, + + op.#Exec & { + always: true + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/getPods.sh", + ] + env: KUBECONFIG: "/kubeconfig" + }, + ] +} diff --git a/stdlib/.dagger/env/aws-eks/values.yaml b/stdlib/.dagger/env/aws-eks/values.yaml new file mode 100644 index 00000000..7d9d9582 --- /dev/null +++ b/stdlib/.dagger/env/aws-eks/values.yaml @@ -0,0 +1,28 @@ +plan: + module: .dagger/env/aws-eks/plan +name: aws-eks +inputs: + TestConfig.awsConfig.accessKey: + secret: ENC[AES256_GCM,data:ZiNdgkTZlOyWht2CDpmYKN+ViTE=,iv:wdRiBw65BgSia9z//tUDirkkhw9O29ZoerX6eZnYx9k=,tag:S/0i/fRtQJg4Qp7tmUK4ag==,type:str] + TestConfig.awsConfig.secretKey: + secret: ENC[AES256_GCM,data:ywvQiDE4gmM6KasYWOvX1FY/Lerg5TghgoYTq1AlXDRHNGzZtY3ClQ==,iv:HCXweaSKHLwEA8Mq4up/TUaV7YDtsRpBpwYD19Jh4iw=,tag:l2hmI9BsGiRyulh4yDn/hw==,type:str] +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBVdWE4VlRMWGJ3WDExWkNl + S1dqU21uVXFjaXU5eWdKRmRCUXFCd2ZaTjNrCjlkNXI3WUdnRGVibmZkbXJYaEV4 + SXIveGNDNnZ6dDM4SjdrMmZIZVhyVzAKLS0tIGkzK0tMTTdHU2lacmtvakUwbGFE + M3U4UFV5REQzYko3QjlXVE02Z0J4WUkK8uHC67Mutls4drXbCi8AwuFqbRXeb69P + ZnOFZEB4NoayoOojr1mY9ssDTywHF4KwR4E9ZmJ3V3hlEAgMkqfvSA== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-06-17T18:46:34Z" + mac: ENC[AES256_GCM,data:B+WtEMOKXy8AT/YTUaKZ9aA8fQRt2pJp3IaABpj0oYI1vCG953MnDCIxj0j2bTQN5gyaFPF8UQ1o/pRJzCKhm26wbCByUrVdHxHTwoJ7arDqQGwcNKYAuQjLtMG7gsl0BqjCg0oKO5YEa24BqHVf1dEo9AcXd6LBwqvxVjmd98g=,iv:aWxj1Oq6wmUYuWnGOc2zIpzOYJVyXV9qSzBgF+iGsHI=,tag:Bx1A8UxghYq97wEdUxbmdg==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/stdlib/.dagger/env/docker-build/.gitignore b/stdlib/.dagger/env/docker-build/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/stdlib/.dagger/env/docker-build/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/stdlib/.dagger/env/docker-build/plan/dockerfile.cue b/stdlib/.dagger/env/docker-build/plan/dockerfile.cue new file mode 100644 index 00000000..70b021f2 --- /dev/null +++ b/stdlib/.dagger/env/docker-build/plan/dockerfile.cue @@ -0,0 +1,57 @@ +package docker + +import ( + "dagger.io/dagger" + "dagger.io/dagger/op" + "dagger.io/docker" +) + +TestSourceBuild: dagger.#Artifact @dagger(input) + +TestBuild: { + image: docker.#Build & { + source: TestSourceBuild + } + + verify: #up: [ + op.#Load & { + from: image + }, + + op.#Exec & { + always: true + args: [ + "sh", "-c", """ + grep -q "test" /test.txt + """, + ] + }, + ] +} + +TestSourceImageFromDockerfile: dagger.#Artifact @dagger(input) + +TestImageFromDockerfile: { + image: docker.#ImageFromDockerfile & { + dockerfile: """ + FROM alpine + COPY test.txt /test.txt + """ + context: TestSourceImageFromDockerfile + } + + verify: #up: [ + op.#Load & { + from: image + }, + + op.#Exec & { + always: true + args: [ + "sh", "-c", """ + grep -q "test" /test.txt + """, + ] + }, + ] +} diff --git a/stdlib/.dagger/env/docker-build/values.yaml b/stdlib/.dagger/env/docker-build/values.yaml new file mode 100644 index 00000000..e876cc46 --- /dev/null +++ b/stdlib/.dagger/env/docker-build/values.yaml @@ -0,0 +1,30 @@ +plan: + module: .dagger/env/docker-build/plan +name: docker-build +inputs: + TestSourceBuild: + dir: + path: ./docker/testdata/build + TestSourceImageFromDockerfile: + dir: + path: ./docker/testdata/dockerfile +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA0TXlFYWNvUldMdlRtWkEz + SlBEYUY1Q0thbFdSZGpaT00xQ2Jkc1J2WkdJClBXUGVTamdmZU1KNUdjam9HN0Zl + RjRQbVRHVjR6S3RCWlJLaElaM2ZWVG8KLS0tIDJJejFkQkxYeDdHcWdPS0p0QmJ0 + Mm5vT1dHbFViK2ZIakNnVkZTd2lhUHMK63jJsJVLJMbQE2NkAB8qv8JnPHpvcNes + z17EJgl0lCLqeNHtfrTfSiIP4wq8gNLK4avCKK+WGDOIMsXPzK6RNw== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-06-17T20:14:11Z" + mac: ENC[AES256_GCM,data:hlc0Bnfeoor/WKMbQRgTalkxngL0YXTwHAys/moXZ4ZMGd2lt+j4l4EkKSjb3QrJfPllCeqroohLKtN+lP4K9fSCMcfYzic2DTEP68rPwufmrgxys1snOHHgIEfqogL8p55fJdXn91x+WHhPNkbWaaH0WcboYsy0zemUIkjb+xc=,iv:8oUeR1dfT4lrVWyJpGPPFa/jlPgWA/ld3UM9Cw2znxk=,tag:59RyiXwzJ5j+c5faxs9U3w==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/stdlib/.dagger/env/git/values.yaml b/stdlib/.dagger/env/git/values.yaml index 2fd0d4a4..c209a8bd 100644 --- a/stdlib/.dagger/env/git/values.yaml +++ b/stdlib/.dagger/env/git/values.yaml @@ -1,3 +1,5 @@ +plan: + module: .dagger/env/git/plan name: git sops: kms: [] @@ -14,8 +16,8 @@ sops: TmhJNisyamw3d244aGVJSEVFVUVLZGsKvd+nowA0CLXQbdvyI4J0lBjs9vdISWlo gGvR49uul3Z8raVWXFUzsyQ8xTvYNg0ovynFG2KdagSKr1DlhKMBEQ== -----END AGE ENCRYPTED FILE----- - lastmodified: "2021-06-15T14:34:51Z" - mac: ENC[AES256_GCM,data:phQpRQlHv9c3VRcqZ7OkSfW4a9oPnTD2ucsB8TJatgzLrbP1+erj9x2jrPex0T2MExIFFzNynSAiWwueLYqCzUvuG2DfIokvM9erNfdpbIBTtJeWO9+hVIkzoQ6xeKg1wLb0q3U7Cbbe6GBFA3oabPN2kyzGbgS2LO2Ou77NMLk=,iv:sS0MRNEGBWos6XNAQEYK2UmaK9g0rd+Nx1xBNeh6w+M=,tag:DIcqzBvChde/C7T/yAhn+w==,type:str] + lastmodified: "2021-06-18T16:23:23Z" + mac: ENC[AES256_GCM,data:AdTUEx0RIrJU6aZZNn9iIrl0eM2eParknCVIQL7k1arLRfYH4WyMf9lUa03+Qy83r4miNh4a9kFpNWyodbOR/j7OiLgAxWGXc08XAnIU51F2H7b55cSW9yNJj5kfos2e1pS356MoSaswg4fH8EYVUNgWC6mdBcXzC1m7uiqTS0E=,iv:mK9sjOCd7ePWR4xe5qNwmPuIyNR1nE3Ql65cF15SovI=,tag:DPUTnGTF+Ve+A7ShACNrnQ==,type:str] pgp: [] encrypted_suffix: secret version: 3.7.1 diff --git a/stdlib/.dagger/env/kubernetes-deployment/.gitignore b/stdlib/.dagger/env/kubernetes-deployment/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/stdlib/.dagger/env/kubernetes-deployment/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/stdlib/.dagger/env/kubernetes-deployment/plan/kubernetes.cue b/stdlib/.dagger/env/kubernetes-deployment/plan/kubernetes.cue new file mode 100644 index 00000000..35f7caee --- /dev/null +++ b/stdlib/.dagger/env/kubernetes-deployment/plan/kubernetes.cue @@ -0,0 +1,44 @@ +package main + +import ( + "encoding/yaml" + "dagger.io/kubernetes" + "dagger.io/random" +) + +// We assume that a kinD cluster is running locally +// To deploy a local KinD cluster, follow this link : https://kind.sigs.k8s.io/docs/user/quick-start/ +TestKubeconfig: string @dagger(input) + +TestKubeApply: { + suffix: random.#String & { + seed: "" + } + + // Pod spec + kubeSrc: { + apiVersion: "v1" + kind: "Pod" + metadata: name: "kube-test-\(suffix.out)" + spec: { + restartPolicy: "Never" + containers: [{ + name: "test" + image: "hello-world" + }] + } + } + + // Apply deployment + apply: kubernetes.#Resources & { + kubeconfig: TestKubeconfig + namespace: "dagger-test" + manifest: yaml.Marshal(kubeSrc) + } + + // Verify deployment + verify: #VerifyApply & { + podname: kubeSrc.metadata.name + namespace: apply.namespace + } +} diff --git a/stdlib/.dagger/env/kubernetes-deployment/plan/verify.cue b/stdlib/.dagger/env/kubernetes-deployment/plan/verify.cue new file mode 100644 index 00000000..0150b5f3 --- /dev/null +++ b/stdlib/.dagger/env/kubernetes-deployment/plan/verify.cue @@ -0,0 +1,79 @@ +package main + +import ( + "dagger.io/dagger/op" + "dagger.io/kubernetes" +) + +#VerifyApply: { + podname: string + + namespace: string + + // Verify that pod exist + #GetPods: + """ + kubectl get pods --namespace "$KUBE_NAMESPACE" \( podname ) + """ + + // Clear that pod for future test + #DeletePods: + """ + kubectl delete pods --namespace "$KUBE_NAMESPACE" \( podname ) + """ + + #up: [ + op.#Load & { + from: kubernetes.#Kubectl + }, + + op.#WriteFile & { + dest: "/kubeconfig" + content: TestKubeconfig + mode: 0o600 + }, + + op.#WriteFile & { + dest: "/getPods.sh" + content: #GetPods + }, + + // Check pods + op.#Exec & { + always: true + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/getPods.sh", + ] + env: { + KUBECONFIG: "/kubeconfig" + KUBE_NAMESPACE: namespace + } + }, + + op.#WriteFile & { + dest: "/deletePods.sh" + content: #DeletePods + }, + + op.#Exec & { + always: true + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/deletePods.sh", + ] + env: { + KUBECONFIG: "/kubeconfig" + KUBE_NAMESPACE: namespace + } + }, + ] +} diff --git a/stdlib/.dagger/env/kubernetes-deployment/values.yaml b/stdlib/.dagger/env/kubernetes-deployment/values.yaml new file mode 100644 index 00000000..59be15cd --- /dev/null +++ b/stdlib/.dagger/env/kubernetes-deployment/values.yaml @@ -0,0 +1,23 @@ +plan: + module: .dagger/env/kubernetes-deployment/plan +name: kubernetes-deployment +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBIQ2hZZ3ZRVzRseXZyVW1h + L01WYkNrTzdHSEN5WTlyQzVDTm9FbzRENzFFCjdrcVhKa1ZwaGNyYmo3ditDR1hC + cStzcmVjUXY3V3FUZElRNUIzQlQzL0UKLS0tIHlmWTlUdFVOczM0TTF5RHFTUXps + SVVkOUtuWTJneE45em5iQ3JvbnIwWlkKgdJC5IzvVDxbWSfU41Xg/UGPxuVBSOGY + eqenr07uWppNaHuLuo9A+znQa2RQ0L2clcB2d+ka+6z5tQyHOfx1nA== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-06-18T15:41:02Z" + mac: ENC[AES256_GCM,data:R3DuHLEyfehKe1nCWHdKB9jyOs5TXI+r2BmQDMiwI8v0xfZdOZWfwGw3NAFGDZHbaLNTajQkzviDsMhaXg5bxvmK7P8PiJOOmnm/LnDRfnJirGRGpWA7bmsHH/QZL1lb75+cwUrwRZflkKoPy2bQyoC5Rze6/oNhPIUTCwQWaMo=,iv:73ZjXAcazCND3JhC94TjUOlcMbwfTz8YDFP1BPo8yUw=,tag:wUVcfyjtf4KzpU0jDrxleQ==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/stdlib/.dagger/env/kubernetes-helm/.gitignore b/stdlib/.dagger/env/kubernetes-helm/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/stdlib/.dagger/env/kubernetes-helm/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/stdlib/.dagger/env/kubernetes-helm/plan/helm.cue b/stdlib/.dagger/env/kubernetes-helm/plan/helm.cue new file mode 100644 index 00000000..6d1c5485 --- /dev/null +++ b/stdlib/.dagger/env/kubernetes-helm/plan/helm.cue @@ -0,0 +1,56 @@ +package main + +import ( + "dagger.io/kubernetes/helm" + "dagger.io/random" + "dagger.io/dagger" +) + +// We assume that a kinD cluster is running locally +// To deploy a local KinD cluster, follow this link : https://kind.sigs.k8s.io/docs/user/quick-start/ +TestKubeconfig: string @dagger(input) + +TestChartSource: dagger.#Artifact @dagger(input) + +// Deploy user local chart +TestHelmSimpleChart: { + suffix: random.#String & { + seed: "simple" + } + + // Deploy chart + deploy: helm.#Chart & { + name: "dagger-test-inline-chart-\(suffix.out)" + namespace: "dagger-test" + kubeconfig: TestKubeconfig + chartSource: TestChartSource + } + + // Verify deployment + verify: #VerifyHelm & { + chartName: deploy.name + namespace: deploy.namespace + } +} + +// Deploy remote chart +TestHelmRepoChart: { + suffix: random.#String & { + seed: "repo" + } + + // Deploy chart + deploy: helm.#Chart & { + name: "dagger-test-repository-\(suffix.out)" + namespace: "dagger-test" + kubeconfig: TestKubeconfig + repository: "https://charts.bitnami.com/bitnami" + chart: "redis" + } + + // Verify deployment + verify: #VerifyHelm & { + chartName: deploy.name + namespace: deploy.namespace + } +} diff --git a/stdlib/.dagger/env/kubernetes-helm/plan/verify.cue b/stdlib/.dagger/env/kubernetes-helm/plan/verify.cue new file mode 100644 index 00000000..581c1121 --- /dev/null +++ b/stdlib/.dagger/env/kubernetes-helm/plan/verify.cue @@ -0,0 +1,51 @@ +package main + +import ( + "dagger.io/dagger/op" + "dagger.io/kubernetes" +) + +#VerifyHelm: { + chartName: string + + namespace: string + + // Verify that pod exist + #getHelmPods: + """ + kubectl get pods --namespace "$KUBE_NAMESPACE" | grep "\(chartName)" + """ + + #up: [ + op.#Load & { + from: kubernetes.#Kubectl + }, + + op.#WriteFile & { + dest: "/getHelmPods.sh" + content: #getHelmPods + }, + + op.#WriteFile & { + dest: "/kubeconfig" + content: TestKubeconfig + mode: 0o600 + }, + + op.#Exec & { + always: true + args: [ + "/bin/bash", + "--noprofile", + "--norc", + "-eo", + "pipefail", + "/getHelmPods.sh", + ] + env: { + KUBECONFIG: "/kubeconfig" + KUBE_NAMESPACE: namespace + } + }, + ] +} diff --git a/stdlib/.dagger/env/kubernetes-helm/values.yaml b/stdlib/.dagger/env/kubernetes-helm/values.yaml new file mode 100644 index 00000000..3f79c0d5 --- /dev/null +++ b/stdlib/.dagger/env/kubernetes-helm/values.yaml @@ -0,0 +1,27 @@ +plan: + module: .dagger/env/kubernetes-helm/plan +name: kubernetes-helm +inputs: + TestChartSource: + dir: + path: ./kubernetes/helm/testdata/mychart +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBud1hMc0dTZTlIQ3lZVEQ5 + WjA2UlAvTm15ZEgycXlKKzhjTmU0Ui9xZHcwCkRxclFUTUE0aXRvaElkc3diV2Ix + N2VZZVIzS2t3cVl3UmtXOC9PY1VObzAKLS0tIG9ydkFzak1SaUo2NGxET3ZiNklZ + VHlGUExaMzcwM0pOM2VDY280UWZXSzQKAm7ZV1agxbla3Yrc7vrwJosSjQtWhdac + ZFyQ6Gi+9H7qHZM89yVjAaIg1lwr68HcjYgDzpvvhJO9YPfzwoLyHw== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-06-18T15:42:52Z" + mac: ENC[AES256_GCM,data:SzHFZpgiv+h1vRjq0GP+4nzj9az6pAwQwstxYz10yBGPQXnZv/VtJm071oouiK7pgD4i7cTvTKgIOaX9K74PiWSiTjWI5F9sGHvt9ZoGyU08OHM6zwGMDiYygBN2+5dd5jBvT4Xy6efa0IOMxSqhp69+VoJRWesAFsN6IfDcIEY=,iv:Af2WeB2eVk5hnWFWaQij7hz2wjXgNWDJTWDm13iKNvA=,tag:uvR1ruMc69ZhDJRtYCFQBw==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/stdlib/.dagger/env/kubernetes-kustomize/.gitignore b/stdlib/.dagger/env/kubernetes-kustomize/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/stdlib/.dagger/env/kubernetes-kustomize/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/stdlib/.dagger/env/kubernetes-kustomize/plan/kustomize.cue b/stdlib/.dagger/env/kubernetes-kustomize/plan/kustomize.cue new file mode 100644 index 00000000..2ebe0682 --- /dev/null +++ b/stdlib/.dagger/env/kubernetes-kustomize/plan/kustomize.cue @@ -0,0 +1,32 @@ +package main + +import ( + "encoding/yaml" + "dagger.io/dagger" + "dagger.io/kubernetes/kustomize" +) + +TestKustomize: { + testdata: dagger.#Artifact + + // Run Kustomize + kustom: kustomize.#Kustomize & { + source: testdata + kustomization: yaml.Marshal({ + resources: ["deployment.yaml", "pod.yaml"] + images: [{ + name: "nginx" + newTag: "v1" + }] + replicas: [{ + name: "nginx-deployment" + count: 2 + }] + }) + } + + // Verify kustomization generation + verify: #VerifyKustomize & { + source: kustom + } +} diff --git a/stdlib/.dagger/env/kubernetes-kustomize/plan/verify.cue b/stdlib/.dagger/env/kubernetes-kustomize/plan/verify.cue new file mode 100644 index 00000000..48075413 --- /dev/null +++ b/stdlib/.dagger/env/kubernetes-kustomize/plan/verify.cue @@ -0,0 +1,72 @@ +package main + +import ( + "dagger.io/dagger/op" + "dagger.io/dagger" + "dagger.io/alpine" +) + +#VerifyKustomize: { + source: dagger.#Artifact + + #up: [ + op.#Load & { + from: alpine.#Image & { + package: bash: "=~5.1" + } + }, + + // Check files + op.#Exec & { + always: true + args: [ + "sh", "-c", "test $(ls /source | wc -l) = 1", + ] + mount: "/source": from: source + }, + + // Check image tag kustomization + op.#Exec & { + always: true + args: [ + "sh", "-c", #""" + grep -q "\- image: nginx:v1" /source/result.yaml + """#, + ] + mount: "/source": from: source + }, + + // Check replicas kustomization + op.#Exec & { + always: true + args: [ + "sh", "-c", #""" + grep -q "replicas: 2" /source/result.yaml + """#, + ] + mount: "/source": from: source + }, + + // Check pod merge by kustomization + op.#Exec & { + always: true + args: [ + "sh", "-c", #""" + grep -q "kind: Pod" /source/result.yaml + """#, + ] + mount: "/source": from: source + }, + + // Check pod name + op.#Exec & { + always: true + args: [ + "sh", "-c", #""" + grep -q "name: test-pod" /source/result.yaml + """#, + ] + mount: "/source": from: source + }, + ] +} diff --git a/stdlib/.dagger/env/kubernetes-kustomize/values.yaml b/stdlib/.dagger/env/kubernetes-kustomize/values.yaml new file mode 100644 index 00000000..a9b6f70e --- /dev/null +++ b/stdlib/.dagger/env/kubernetes-kustomize/values.yaml @@ -0,0 +1,27 @@ +plan: + module: .dagger/env/kubernetes-kustomize/plan +name: kubernetes-kustomize +inputs: + TestKustomize.testdata: + dir: + path: ./kubernetes/kustomize/testdata +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBTL2Jyczk3QXZiUVkyd3cw + TlYzQ2NyR2ZGZnhSRmowSGRmbFBodFRPc2dnCnJpYjdCdUpEUE10d3I4clh1eDVV + MmVqbmxiNmRvSUNqZEY3clZnci9pRkkKLS0tIGVLSVFwTy9TSElFUkdjOVlWb3Yy + OFllMEh3cVJZZnFxbW4xS1RtcFQzcFUKo/1WcYp4nPBXba8wQBe3DMt6pYQJGoSu + ja5BiCffN5wOoW9WT0j8Clx21w7BXcl46+T5GYpXDQDcqf6nCv1kYQ== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-06-17T20:48:00Z" + mac: ENC[AES256_GCM,data:SCWiSiDccPkZApOcc8RsYP7WPZUqUyYVB0UgivLhIsNSY5q3kCdenPLTUp2zLOcwaWzTPGmj++QtZjoNobcIhdVt1aJ9uXLLKRUXaRGIO3Jmhg3wj7kSPNjbDLZEB6uyA9h3edQGVVivNlNGpo91tg35QcFPPSG7UiowFnsD0zM=,iv:44hkujM/ZWjtYHau8BFMdOIeBj5jF/WnW4OOK7oSw1Y=,tag:mtJdUR+sA0tjIyAWDpXQlA==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/stdlib/.dagger/env/terraform/.gitignore b/stdlib/.dagger/env/terraform/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/stdlib/.dagger/env/terraform/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/stdlib/.dagger/env/terraform/plan/terraform.cue b/stdlib/.dagger/env/terraform/plan/terraform.cue new file mode 100644 index 00000000..e34ea405 --- /dev/null +++ b/stdlib/.dagger/env/terraform/plan/terraform.cue @@ -0,0 +1,74 @@ +package terraform + +import ( + "dagger.io/dagger" + "dagger.io/dagger/op" + "dagger.io/alpine" + "dagger.io/terraform" +) + +TestData: dagger.#Artifact @dagger(input) + +TestConfig: awsConfig: { + accessKey: dagger.#Secret @dagger(input) + secretKey: dagger.#Secret @dagger(input) + region: "us-east-2" +} + +#TestGetConfig: { + accessKey: dagger.#Secret + + secretKey: dagger.#Secret + + visibleAccessKey: string + + visibleSecretKey: string + + #up: [ + op.#Load & {from: alpine.#Image & { + package: { + bash: true + jq: true + } + }}, + + op.#Exec & { + always: true + args: ["/bin/bash", "-c", #""" + export ACCESS_KEY=$(cat /accessKey) + export SECRET_KEY=$(cat /secretKey) + + jq --arg key0 'visibleAccessKey' --arg value0 "$ACCESS_KEY" \ + --arg key1 'visibleSecretKey' --arg value1 "$SECRET_KEY" \ + '. | .[$key0]=$value0 | .[$key1]=$value1' <<< '{}' > /out + """#, + ] + mount: { + "/accessKey": secret: accessKey + "/secretKey": secret: secretKey + } + }, + + op.#Export & { + source: "/out" + format: "json" + }, + ] +} + +TestTerraform: { + config: #TestGetConfig & { + accessKey: TestConfig.awsConfig.accessKey + secretKey: TestConfig.awsConfig.secretKey + } + + apply: terraform.#Configuration & { + source: TestData + env: { + AWS_ACCESS_KEY_ID: config.visibleAccessKey + AWS_SECRET_ACCESS_KEY: config.visibleSecretKey + AWS_DEFAULT_REGION: TestConfig.awsConfig.region + AWS_REGION: TestConfig.awsConfig.region + } + } +} diff --git a/stdlib/.dagger/env/terraform/values.yaml b/stdlib/.dagger/env/terraform/values.yaml new file mode 100644 index 00000000..fb5e132f --- /dev/null +++ b/stdlib/.dagger/env/terraform/values.yaml @@ -0,0 +1,31 @@ +plan: + module: .dagger/env/terraform/plan +name: terraform +inputs: + TestConfig.awsConfig.accessKey: + secret: ENC[AES256_GCM,data:V/p84nLbgjrytefnsfItiY71ikQ=,iv:i1x3UYP+sctwY9LrRp/rfeJ8/JPWOfiiJSG0NWUiXW0=,tag:IynKh1fQEhExmmR3qGx/zQ==,type:str] + TestConfig.awsConfig.secretKey: + secret: ENC[AES256_GCM,data:cBYaVhbeV9D6acJWNU7uL8AsEtpnY0wHM8td9ZAJ9ebGB+BY4iBZLQ==,iv:SDkRKQQKBSz/cRQlW65sIjF0PhHhhKkGUEgZe9CV7Ek=,tag:OCUQmgjP2p57YoLts9Dh4w==,type:str] + TestData: + dir: + path: ./terraform/testdata +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBkOTJpQWJWY3dnM2hDdXZG + bVJEN0dNUzQ0VGhneWtHVG1hUHA5ZjdhdHdvClR0ZVpKb1RYRnc3dy9wSjVuSHBn + c2RMbzE0Y2EzN2FVak9CMk9CK0hOTFkKLS0tIG9Fdi9xWWc0TU5WY1ZsVUdZM2lw + cC9LSiswbFRKaTNXUGNIWVZVbGJqV1UK3/wsgPwR5P2fzs80wcz1dM/8sbBWMR+B + dmhP99OQisIgcwGATy0nh726pYKtosDpSLIJkLZDAUq9qRKm9bch1w== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-06-18T16:01:11Z" + mac: ENC[AES256_GCM,data:XznDGqfZkC6vsv696qWVxbBCUgsyU/zPZg0NCULCXAfO08Hsteb0c93Y8DA3CV8flQW3cgn5XLugNnQADJ6luTXHbqIVMVMUSe1q41Kxl7exr/dn0robqaRm5MnloG823s9X3sAOcPzyTSxy1YVZfYaYbG23w9IeNmVTyaUttkU=,iv:kEQs7+bx+7j2v5b6Bx0r+ZVtp7rj/8mgX4oRUP7cruc=,tag:oQEfCPO/0V11rmkc0yaz3Q==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/stdlib/docker/testdata/build/Dockerfile b/stdlib/docker/testdata/build/Dockerfile new file mode 100644 index 00000000..987ce9be --- /dev/null +++ b/stdlib/docker/testdata/build/Dockerfile @@ -0,0 +1,2 @@ +FROM alpine +RUN echo test >> /test.txt \ No newline at end of file diff --git a/stdlib/docker/testdata/dockerfile/test.txt b/stdlib/docker/testdata/dockerfile/test.txt new file mode 100644 index 00000000..30d74d25 --- /dev/null +++ b/stdlib/docker/testdata/dockerfile/test.txt @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/stdlib/helpers.bash b/stdlib/helpers.bash index 76a7f46f..0bddf106 100644 --- a/stdlib/helpers.bash +++ b/stdlib/helpers.bash @@ -46,3 +46,14 @@ copy_to_sandbox() { cp -a "$source" "$target" } + +# 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 "user: kind-kind" ~/.kube/config &> /dev/null && 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/stdlib/kubernetes/helm/testdata/mychart/.helmignore b/stdlib/kubernetes/helm/testdata/mychart/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/stdlib/kubernetes/helm/testdata/mychart/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/stdlib/kubernetes/helm/testdata/mychart/Chart.yaml b/stdlib/kubernetes/helm/testdata/mychart/Chart.yaml new file mode 100644 index 00000000..1613bff5 --- /dev/null +++ b/stdlib/kubernetes/helm/testdata/mychart/Chart.yaml @@ -0,0 +1,21 @@ +apiVersion: v2 +name: mychart +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: 1.16.0 diff --git a/stdlib/kubernetes/helm/testdata/mychart/templates/NOTES.txt b/stdlib/kubernetes/helm/testdata/mychart/templates/NOTES.txt new file mode 100644 index 00000000..8b795a8a --- /dev/null +++ b/stdlib/kubernetes/helm/testdata/mychart/templates/NOTES.txt @@ -0,0 +1,21 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "mychart.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "mychart.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "mychart.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "mychart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/stdlib/kubernetes/helm/testdata/mychart/templates/_helpers.tpl b/stdlib/kubernetes/helm/testdata/mychart/templates/_helpers.tpl new file mode 100644 index 00000000..8479665d --- /dev/null +++ b/stdlib/kubernetes/helm/testdata/mychart/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "mychart.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "mychart.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "mychart.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "mychart.labels" -}} +helm.sh/chart: {{ include "mychart.chart" . }} +{{ include "mychart.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "mychart.selectorLabels" -}} +app.kubernetes.io/name: {{ include "mychart.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "mychart.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "mychart.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/stdlib/kubernetes/helm/testdata/mychart/templates/deployment.yaml b/stdlib/kubernetes/helm/testdata/mychart/templates/deployment.yaml new file mode 100644 index 00000000..38e698f8 --- /dev/null +++ b/stdlib/kubernetes/helm/testdata/mychart/templates/deployment.yaml @@ -0,0 +1,55 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "mychart.fullname" . }} + labels: + {{- include "mychart.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "mychart.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "mychart.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "mychart.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/stdlib/kubernetes/helm/testdata/mychart/templates/ingress.yaml b/stdlib/kubernetes/helm/testdata/mychart/templates/ingress.yaml new file mode 100644 index 00000000..76d277c0 --- /dev/null +++ b/stdlib/kubernetes/helm/testdata/mychart/templates/ingress.yaml @@ -0,0 +1,41 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "mychart.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "mychart.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} +{{- end }} diff --git a/stdlib/kubernetes/helm/testdata/mychart/templates/service.yaml b/stdlib/kubernetes/helm/testdata/mychart/templates/service.yaml new file mode 100644 index 00000000..bdceb88f --- /dev/null +++ b/stdlib/kubernetes/helm/testdata/mychart/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "mychart.fullname" . }} + labels: + {{- include "mychart.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "mychart.selectorLabels" . | nindent 4 }} diff --git a/stdlib/kubernetes/helm/testdata/mychart/templates/serviceaccount.yaml b/stdlib/kubernetes/helm/testdata/mychart/templates/serviceaccount.yaml new file mode 100644 index 00000000..145e891e --- /dev/null +++ b/stdlib/kubernetes/helm/testdata/mychart/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "mychart.serviceAccountName" . }} + labels: + {{- include "mychart.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end -}} diff --git a/stdlib/kubernetes/helm/testdata/mychart/templates/tests/test-connection.yaml b/stdlib/kubernetes/helm/testdata/mychart/templates/tests/test-connection.yaml new file mode 100644 index 00000000..0bd46ef1 --- /dev/null +++ b/stdlib/kubernetes/helm/testdata/mychart/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "mychart.fullname" . }}-test-connection" + labels: + {{- include "mychart.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "mychart.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/stdlib/kubernetes/helm/testdata/mychart/values.yaml b/stdlib/kubernetes/helm/testdata/mychart/values.yaml new file mode 100644 index 00000000..dbf4257e --- /dev/null +++ b/stdlib/kubernetes/helm/testdata/mychart/values.yaml @@ -0,0 +1,68 @@ +# Default values for mychart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: nginx + pullPolicy: IfNotPresent + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/stdlib/kubernetes/kustomize/testdata/deployment.yaml b/stdlib/kubernetes/kustomize/testdata/deployment.yaml new file mode 100644 index 00000000..e47d13ff --- /dev/null +++ b/stdlib/kubernetes/kustomize/testdata/deployment.yaml @@ -0,0 +1,22 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment + labels: + app: nginx-deployment +spec: + replicas: 1 + template: + metadata: + name: nginx-deployment + labels: + app: nginx-deployment + spec: + containers: + - name: nginx-deployment + image: nginx + imagePullPolicy: IfNotPresent + restartPolicy: Always + selector: + matchLabels: + app: nginx-deployment diff --git a/stdlib/kubernetes/kustomize/testdata/pod.yaml b/stdlib/kubernetes/kustomize/testdata/pod.yaml new file mode 100644 index 00000000..179e8199 --- /dev/null +++ b/stdlib/kubernetes/kustomize/testdata/pod.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Pod +metadata: + name: test-pod + labels: + app: test-pod +spec: + containers: + - name: test-pod + image: nginx + imagePullPolicy: IfNotPresent + restartPolicy: Always diff --git a/stdlib/terraform/testdata/test.tf b/stdlib/terraform/testdata/test.tf new file mode 100644 index 00000000..878484e2 --- /dev/null +++ b/stdlib/terraform/testdata/test.tf @@ -0,0 +1,34 @@ +terraform { + required_providers { + random = { + source = "hashicorp/random" + version = "3.1.0" + } + } + + backend "s3" { + bucket = "dagger-ci" + key = "terraform/tfstate" + region = "us-east-2" + } +} + +provider "random" { +} + +variable "input" { + type = string +} + +resource "random_integer" "test" { + min = 1 + max = 50 +} + +output "random" { + value = random_integer.test.result +} + +output "input" { + value = var.input +} diff --git a/stdlib/universe.bats b/stdlib/universe.bats index 2bceeac2..16681b0e 100644 --- a/stdlib/universe.bats +++ b/stdlib/universe.bats @@ -32,10 +32,18 @@ setup() { dagger -e aws-s3 up } +@test "aws: eks" { + dagger -e aws-eks up +} + @test "docker run: local" { dagger -e docker-run-local up } +@test "docker build" { + dagger -e docker-build up +} + @test "docker command: ssh" { dagger -e docker-command-ssh up } @@ -53,6 +61,34 @@ setup() { dagger -e docker-run-ssh up } +@test "kubernetes: deployment" { + skip_unless_local_kube + + # Set kubeconfig + dagger -e kubernetes-deployment input text TestKubeconfig -f "$HOME"/.kube/config + + dagger -e kubernetes-deployment up + + # Unset kubeconfig + dagger -e kubernetes-deployment input unset TestKubeconfig +} + +@test "kubernetes: kustomize" { + dagger -e kubernetes-kustomize up +} + +@test "kubernetes: helm" { + skip_unless_local_kube + + # Set kubeconfig + dagger -e kubernetes-helm input text TestKubeconfig -f "$HOME"/.kube/config + + dagger -e kubernetes-helm up + + # Unset kubeconfig + dagger -e kubernetes-helm input unset TestKubeconfig +} + @test "google cloud: gcr" { dagger -e google-gcr up } @@ -60,3 +96,29 @@ setup() { @test "google cloud: gke" { dagger -e google-gke up } + +@test "terraform" { + # it must fail because of a missing var + run dagger -e terraform up + assert_failure + + # Add the var and try again + run dagger -e terraform input text TestTerraform.apply.tfvars.input "42" + run dagger -e terraform up + assert_success + + # ensure the tfvar was passed correctly + run dagger query -e terraform TestTerraform.apply.output.input.value -f text + assert_success + assert_output "42" + + # ensure the random value is always the same + # this proves we're effectively using the s3 backend + run dagger query -e terraform TestTerraform.apply.output.random.value -f json + assert_success + assert_output "36" + + # Unset input + run dagger -e terraform input unset TestTerraform.apply.tfvars.input + assert_success +} \ No newline at end of file diff --git a/tests/stdlib/terraform/s3/inputs.yaml b/tests/stdlib/terraform/s3/inputs.yaml new file mode 100644 index 00000000..ef2355cf --- /dev/null +++ b/tests/stdlib/terraform/s3/inputs.yaml @@ -0,0 +1,24 @@ +TestConfig: + awsConfig: + accessKey: ENC[AES256_GCM,data:cZLf9D1ymnU4A44oGiQ4fFKdEB0=,iv:rNv9rnXSvIpKeUYRqseS9aKjEG4Wim7OW0EKEbBgp+M=,tag:cOzI4KsDgCgi/w7ByFKJJw==,type:str] + secretKey: ENC[AES256_GCM,data:ZFIHfnQYYu7ZhoXogVIHbd2wakBTw9D0TiHeadSKaYAQemCun/egNg==,iv:zISyY5zGZHfe5HZJHdfIUpX6siFIgLMrwAbZRyLH9FU=,tag:uD+1eLHY/AKR9vnpyBh+GQ==,type:str] +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBPdU5ENVpScm0yd2RXWjRJ + aSsxWTNvSHBBeU94Z2ZKNjhXdzJHZGNybXkwCk9FVW5EM21LSTRHMkE5VG1SRFpL + ZGUyOHl3MEU3M3ZXTzBqSlExTU1uVTgKLS0tIDZRVDJOaEVZVnVSalRKMUVTTytV + ZWRONHhmOEJVd1lqM1NkMFdSNHU2THMKSjtxHeq/ZSgpXrevLH4AVYyRh4jO6qjT + J301rFx0Cu5qeSIhRiG54Pse83GD+fObDhfH0nPf5HZttDZxrISUdg== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-05-28T20:45:06Z" + mac: ENC[AES256_GCM,data:7b6X10McAD1qvsS3ZFWeteP7zLC6IAo6NdFjvaX1iyrjoZ+fT8hNkIPVKyfPFTqZzNIZ7qEYJO2PKrTjbhf6a1LEsL9gtfoX4JwINDk66TgIsJsvdp4TRIlEKoRSKK08zc+A5YFAtD1Pj+a3+NnF32ZUsoH+jqSixH2hK51RI0U=,iv:JKeSA0bp+QBE8H/kS/eIL47k1Bsg4L0q/YU4OlJmIKU=,tag:f3gzp/Nv4p4DajNfoAicAg==,type:str] + pgp: [] + unencrypted_suffix: _unencrypted + version: 3.7.1 From 9c20c45453e5ba89bdc58eb5a0d2af2660cf7352 Mon Sep 17 00:00:00 2001 From: Tom Chauveau Date: Fri, 18 Jun 2021 19:15:48 +0200 Subject: [PATCH 03/14] Use sandbox in tests Signed-off-by: Tom Chauveau --- .../.dagger/env/kubernetes-helm/plan/helm.cue | 2 +- stdlib/helpers.bash | 12 +++++++ stdlib/universe.bats | 35 ++++++++++++------- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/stdlib/.dagger/env/kubernetes-helm/plan/helm.cue b/stdlib/.dagger/env/kubernetes-helm/plan/helm.cue index 6d1c5485..ab06eb13 100644 --- a/stdlib/.dagger/env/kubernetes-helm/plan/helm.cue +++ b/stdlib/.dagger/env/kubernetes-helm/plan/helm.cue @@ -39,7 +39,7 @@ TestHelmRepoChart: { seed: "repo" } - // Deploy chart + // Deploy remote chart deploy: helm.#Chart & { name: "dagger-test-repository-\(suffix.out)" namespace: "dagger-test" diff --git a/stdlib/helpers.bash b/stdlib/helpers.bash index 0bddf106..f2f4b4c7 100644 --- a/stdlib/helpers.bash +++ b/stdlib/helpers.bash @@ -39,12 +39,24 @@ dagger() { # 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 local kubernetes cluster. diff --git a/stdlib/universe.bats b/stdlib/universe.bats index 16681b0e..66d6a965 100644 --- a/stdlib/universe.bats +++ b/stdlib/universe.bats @@ -64,13 +64,16 @@ setup() { @test "kubernetes: deployment" { skip_unless_local_kube - # Set kubeconfig - dagger -e kubernetes-deployment input text TestKubeconfig -f "$HOME"/.kube/config + # Copy deployment to sandbox + copy_to_sandbox kubernetes-deployment - dagger -e kubernetes-deployment up + # Set kubeconfig + dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment input text TestKubeconfig -f "$HOME"/.kube/config + + dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment up # Unset kubeconfig - dagger -e kubernetes-deployment input unset TestKubeconfig + dagger -w "$DAGGER_SANDBOX" -e kubernetes-deployment input unset TestKubeconfig } @test "kubernetes: kustomize" { @@ -80,13 +83,16 @@ setup() { @test "kubernetes: helm" { skip_unless_local_kube - # Set kubeconfig - dagger -e kubernetes-helm input text TestKubeconfig -f "$HOME"/.kube/config + # Copy deployment to sandbox + copy_to_sandbox kubernetes-helm kubernetes - dagger -e kubernetes-helm up + # Set kubeconfig + dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm input text TestKubeconfig -f "$HOME"/.kube/config + + dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm up # Unset kubeconfig - dagger -e kubernetes-helm input unset TestKubeconfig + dagger -w "$DAGGER_SANDBOX" -e kubernetes-helm input unset TestKubeconfig } @test "google cloud: gcr" { @@ -102,23 +108,26 @@ setup() { run dagger -e terraform up assert_failure + # Copy deployment to sandbox + copy_to_sandbox terraform terraform + # Add the var and try again - run dagger -e terraform input text TestTerraform.apply.tfvars.input "42" - run dagger -e terraform up + run dagger -w "$DAGGER_SANDBOX" -e terraform input text TestTerraform.apply.tfvars.input "42" + run dagger -w "$DAGGER_SANDBOX" -e terraform up assert_success # ensure the tfvar was passed correctly - run dagger query -e terraform TestTerraform.apply.output.input.value -f text + run dagger -w "$DAGGER_SANDBOX" query -e terraform TestTerraform.apply.output.input.value -f text assert_success assert_output "42" # ensure the random value is always the same # this proves we're effectively using the s3 backend - run dagger query -e terraform TestTerraform.apply.output.random.value -f json + run dagger -w "$DAGGER_SANDBOX" query -e terraform TestTerraform.apply.output.random.value -f json assert_success assert_output "36" # Unset input - run dagger -e terraform input unset TestTerraform.apply.tfvars.input + run dagger -w "$DAGGER_SANDBOX" -e terraform input unset TestTerraform.apply.tfvars.input assert_success } \ No newline at end of file From 7d9ff46ebd13c53ea279e1553545c138288d8866 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Fri, 18 Jun 2021 18:01:14 +0200 Subject: [PATCH 04/14] revert input dir management to llb.Copy to fix cache for yarn source pkg Signed-off-by: Sam Alba --- environment/pipeline.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/environment/pipeline.go b/environment/pipeline.go index db6e9012..c3d33e6a 100644 --- a/environment/pipeline.go +++ b/environment/pipeline.go @@ -342,9 +342,20 @@ func (p *Pipeline) Local(ctx context.Context, op *compiler.Value, st llb.State) opts = append(opts, llb.ExcludePatterns(excludePatterns)) } - return llb.Local( - dir, - opts..., + // FIXME: Remove the `Copy` and use `Local` directly. + // + // Copy'ing is a costly operation which should be unnecessary. + // However, using llb.Local directly breaks caching sometimes for unknown reasons. + return st.File( + llb.Copy( + llb.Local( + dir, + opts..., + ), + "/", + "/", + ), + llb.WithCustomName(p.vertexNamef("Local %s [copy]", dir)), ), nil } From efed4f73ea3d52aa6ca359d63792e5457f50787f Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Mon, 21 Jun 2021 11:37:48 +0200 Subject: [PATCH 05/14] input/dir: ignore .dagger/ directory by default Signed-off-by: Sam Alba --- environment/pipeline.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/environment/pipeline.go b/environment/pipeline.go index c3d33e6a..28170def 100644 --- a/environment/pipeline.go +++ b/environment/pipeline.go @@ -329,8 +329,10 @@ func (p *Pipeline) Local(ctx context.Context, op *compiler.Value, st llb.State) if err != nil { return st, err } + + // Excludes .dagger directory by default + excludePatterns := []string{"**/.dagger/"} if len(excludes) > 0 { - excludePatterns := []string{} for _, i := range excludes { pattern, err := i.String() if err != nil { @@ -338,9 +340,8 @@ func (p *Pipeline) Local(ctx context.Context, op *compiler.Value, st llb.State) } excludePatterns = append(excludePatterns, pattern) } - - opts = append(opts, llb.ExcludePatterns(excludePatterns)) } + opts = append(opts, llb.ExcludePatterns(excludePatterns)) // FIXME: Remove the `Copy` and use `Local` directly. // From 9452b84de81c7d78ea6cd10225a6521614dda733 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Mon, 21 Jun 2021 13:21:48 +0200 Subject: [PATCH 06/14] docs: move netlify.toml to website Signed-off-by: Andrea Luzzardi --- netlify.toml => website/netlify.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) rename netlify.toml => website/netlify.toml (89%) diff --git a/netlify.toml b/website/netlify.toml similarity index 89% rename from netlify.toml rename to website/netlify.toml index 80a56210..703a4e4a 100644 --- a/netlify.toml +++ b/website/netlify.toml @@ -1,5 +1,4 @@ [build] - base = "website/" publish = "build/" command = "yarn build" @@ -10,12 +9,12 @@ # compare the current commit to the previous. # We can't use `$CACHED_COMMIT_REF` because that points to the PR preview # that was built before merging. - ignore = "git diff --quiet HEAD^ HEAD -- . ../docs/ ../netlify.toml" + ignore = "git diff --quiet HEAD^ HEAD -- . ../docs/" [context.deploy-preview] # Do not build the site if there's no site-related changes since the last # deploy. - ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../docs/ ../netlify.toml" + ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF . ../docs/" command = "yarn build:withoutAuth" [[redirects]] From 49277af6802ba623ca6e5869f781ed380acb9760 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Thu, 17 Jun 2021 14:11:10 +0000 Subject: [PATCH 07/14] Add simple test environment for core features Signed-off-by: Solomon Hykes --- .dagger/env/test-core/.gitignore | 2 ++ .dagger/env/test-core/plan/test-core.cue | 11 +++++++++ .dagger/env/test-core/values.yaml | 27 +++++++++++++++++++++ tests/core.bats | 30 ++++++++++++++++++++++++ tests/helpers.bash | 7 +++++- 5 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 .dagger/env/test-core/.gitignore create mode 100644 .dagger/env/test-core/plan/test-core.cue create mode 100644 .dagger/env/test-core/values.yaml create mode 100644 tests/core.bats diff --git a/.dagger/env/test-core/.gitignore b/.dagger/env/test-core/.gitignore new file mode 100644 index 00000000..01ec19b0 --- /dev/null +++ b/.dagger/env/test-core/.gitignore @@ -0,0 +1,2 @@ +# dagger state +state/** diff --git a/.dagger/env/test-core/plan/test-core.cue b/.dagger/env/test-core/plan/test-core.cue new file mode 100644 index 00000000..60122bbb --- /dev/null +++ b/.dagger/env/test-core/plan/test-core.cue @@ -0,0 +1,11 @@ +package testcore + +import ( + "dagger.io/dagger" +) + +name: string | *"world" @dagger(input) +message: "Hello, \(name)!" @dagger(output) + +dir: dagger.#Artifact @dagger(input) +samedir: dir @dagger(output) diff --git a/.dagger/env/test-core/values.yaml b/.dagger/env/test-core/values.yaml new file mode 100644 index 00000000..41ba947a --- /dev/null +++ b/.dagger/env/test-core/values.yaml @@ -0,0 +1,27 @@ +plan: + module: .dagger/env/test-core/plan +name: test-core +inputs: + dir: + dir: + path: ./tests +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBhOW1rUy9vNFBDaXRDUHJu + ZVZYM1FucVorRDdUcmRaYmg3eTlTNzhhYWdjCndWZWxhZnhCZG4xZU9JQ1VyMXdR + OHY0TS81bk9FL2JuUEhuTmcxa29ORGcKLS0tIGxJUzNrZmRBNHZGRFY2Z01QK2JP + MlM1Ukdqbi9SQ0pqTi9FZ3MxN2E2QmsKHwd7P6KHPVdynOoto1jf3G4+5+vf87wU + HX1KD7Od5wRdBwn7r3OS8mdvuNIYpJDUb5YDrfjQypt020ohLocNiA== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2021-06-17T14:07:53Z" + mac: ENC[AES256_GCM,data:afYut7wdvsJQgxlBg6NEV6DWk8vPi81mZgQAuWb4oe4WJeI1T9cYdtjOHPlmIpjqb86VQHJ29YTzektei2+k+VBawQxcsvefK7X1QboJTfMKLfsiug4qzNWjc7JZDvTb6dsDFM1U96gjSoAIVwdLMnucbu3681Fd7qSQgqNS61Q=,iv:ZQDHzXp0RJcUI4RtOVjdepV8zTa2kIHQhAltLkudDck=,tag:AnSFi1mKrEuXSqE4R+g7dw==,type:str] + pgp: [] + encrypted_suffix: secret + version: 3.7.1 diff --git a/tests/core.bats b/tests/core.bats new file mode 100644 index 00000000..542c9eae --- /dev/null +++ b/tests/core.bats @@ -0,0 +1,30 @@ +# Test core Dagger features & types + +setup() { + load 'helpers' + + common_setup + + # Use native Dagger environment here + unset DAGGER_WORKSPACE +} + +@test "core: inputs" { + # List available inputs + run dagger -e test-core input list + assert_success + assert_output --partial 'name' + assert_output --partial 'dir' + + # Set text input + dagger -e test-core input text name Bob + run dagger -e test-core up + assert_success + assert_output --partial 'Hello, Bob!' + + # Unset text input + dagger -e test-core input unset name + run dagger -e test-core up + assert_success + assert_output --partial 'Hello, world!' +} diff --git a/tests/helpers.bash b/tests/helpers.bash index 6eeca33a..e4f231c9 100644 --- a/tests/helpers.bash +++ b/tests/helpers.bash @@ -27,6 +27,11 @@ dagger_new_with_plan() { } +# dagger helper to execute the right binary +dagger() { + "${DAGGER}" "$@" +} + skip_unless_secrets_available() { local inputFile="$1" sops exec-file "$inputFile" echo > /dev/null 2>&1 || skip "$inputFile cannot be decrypted" @@ -38,4 +43,4 @@ skip_unless_local_kube() { else skip "local kubernetes cluster not available" fi -} \ No newline at end of file +} From 8383efdba6eeb8581835856304ca7d80ca2d6fd5 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Fri, 18 Jun 2021 16:55:45 +0000 Subject: [PATCH 08/14] stdlib: dagger.#Input Signed-off-by: Solomon Hykes --- .dagger/env/test-core/plan/test-core.cue | 8 ++++++-- stdlib/dagger/dagger.cue | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.dagger/env/test-core/plan/test-core.cue b/.dagger/env/test-core/plan/test-core.cue index 60122bbb..a3495b94 100644 --- a/.dagger/env/test-core/plan/test-core.cue +++ b/.dagger/env/test-core/plan/test-core.cue @@ -4,8 +4,12 @@ import ( "dagger.io/dagger" ) -name: string | *"world" @dagger(input) +name: dagger.#Input & { + string | *"world" +} + message: "Hello, \(name)!" @dagger(output) -dir: dagger.#Artifact @dagger(input) +dir: dagger.#Input & dagger.#Artifact + samedir: dir @dagger(output) diff --git a/stdlib/dagger/dagger.cue b/stdlib/dagger/dagger.cue index 8dc76711..094159b3 100644 --- a/stdlib/dagger/dagger.cue +++ b/stdlib/dagger/dagger.cue @@ -19,3 +19,9 @@ import ( id: string } + +#Input: { + @dagger(input) + _ + ... +} From 53f4ef049ae2ac387308842943e7d82c06defc8b Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Mon, 21 Jun 2021 09:07:18 +0000 Subject: [PATCH 09/14] stdlib: dagger.#Output Signed-off-by: Solomon Hykes --- .dagger/env/test-core/plan/test-core.cue | 4 ++-- stdlib/dagger/dagger.cue | 6 ++++++ tests/core.bats | 7 ++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.dagger/env/test-core/plan/test-core.cue b/.dagger/env/test-core/plan/test-core.cue index a3495b94..aae00c60 100644 --- a/.dagger/env/test-core/plan/test-core.cue +++ b/.dagger/env/test-core/plan/test-core.cue @@ -8,8 +8,8 @@ name: dagger.#Input & { string | *"world" } -message: "Hello, \(name)!" @dagger(output) +message: dagger.#Output & "Hello, \(name)!" dir: dagger.#Input & dagger.#Artifact -samedir: dir @dagger(output) +samedir: dagger.#Output & dir diff --git a/stdlib/dagger/dagger.cue b/stdlib/dagger/dagger.cue index 094159b3..f0463135 100644 --- a/stdlib/dagger/dagger.cue +++ b/stdlib/dagger/dagger.cue @@ -25,3 +25,9 @@ import ( _ ... } + +#Output: { + @dagger(output) + _ + ... +} diff --git a/tests/core.bats b/tests/core.bats index 542c9eae..ee600509 100644 --- a/tests/core.bats +++ b/tests/core.bats @@ -9,7 +9,7 @@ setup() { unset DAGGER_WORKSPACE } -@test "core: inputs" { +@test "core: inputs & outputs" { # List available inputs run dagger -e test-core input list assert_success @@ -22,9 +22,14 @@ setup() { assert_success assert_output --partial 'Hello, Bob!' + run dagger -e test-core output list + assert_success + assert_output --partial 'message "Hello, Bob!"' + # Unset text input dagger -e test-core input unset name run dagger -e test-core up assert_success assert_output --partial 'Hello, world!' } + From f4afe5d12945018e4d6f5e6e2351343add1b31ed Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Mon, 21 Jun 2021 15:14:18 +0200 Subject: [PATCH 10/14] test: added test for ignoring .dagger directory in input dir Signed-off-by: Sam Alba --- tests/cli.bats | 14 ++++++++++++++ tests/cli/input/ignore/main.cue | 20 ++++++++++++++++++++ tests/cli/input/ignore/testdata/.dagger/foo | 0 tests/cli/input/ignore/testdata/testfile | 1 + 4 files changed, 35 insertions(+) create mode 100644 tests/cli/input/ignore/main.cue create mode 100644 tests/cli/input/ignore/testdata/.dagger/foo create mode 100644 tests/cli/input/ignore/testdata/testfile diff --git a/tests/cli.bats b/tests/cli.bats index 4dd1e32a..8fcc086e 100644 --- a/tests/cli.bats +++ b/tests/cli.bats @@ -308,6 +308,20 @@ setup() { }' } +@test "dagger input dir: ignore .dagger" { + "$DAGGER" init + + dagger_new_with_plan input "$TESTDIR"/cli/input/ignore + + run [ -d "$TESTDIR"/cli/input/ignore/testdata/.dagger ] + assert_success + + cp -R "$TESTDIR"/cli/input/ignore/testdata/ "$DAGGER_WORKSPACE"/testdata + "$DAGGER" input -e "input" dir "source" "$DAGGER_WORKSPACE"/testdata + "$DAGGER" up -e "input" + assert_success +} + @test "dagger input git" { "$DAGGER" init diff --git a/tests/cli/input/ignore/main.cue b/tests/cli/input/ignore/main.cue new file mode 100644 index 00000000..8cd23563 --- /dev/null +++ b/tests/cli/input/ignore/main.cue @@ -0,0 +1,20 @@ +package testing + +import ( + "dagger.io/dagger/op" + "dagger.io/dagger" +) + +source: dagger.#Artifact + +#up: [ + op.#FetchContainer & {ref: "busybox"}, + op.#Exec & { + args: ["sh", "-c", """ + set -exu + [ -f /source/testfile ] + [ ! -d /source/.dagger ] + """] + mount: "/source": from: source + }, +] diff --git a/tests/cli/input/ignore/testdata/.dagger/foo b/tests/cli/input/ignore/testdata/.dagger/foo new file mode 100644 index 00000000..e69de29b diff --git a/tests/cli/input/ignore/testdata/testfile b/tests/cli/input/ignore/testdata/testfile new file mode 100644 index 00000000..20495ffb --- /dev/null +++ b/tests/cli/input/ignore/testdata/testfile @@ -0,0 +1 @@ +thisisatest From 479dc5040265c146f2a75cc5ac70ff24a8c67240 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Mon, 21 Jun 2021 15:19:26 +0200 Subject: [PATCH 11/14] docs: disable deploying using dagger Signed-off-by: Andrea Luzzardi --- .github/workflows/docs.yml | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index dcd3541d..00000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Docs - -on: - push: - tags: - - v* - paths: - - "docs/**" - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: "0" - - uses: dagger/dagger-action@v1 - with: - age-key: ${{ secrets.DAGGER_AGE_KEY }} - args: up -e docs From e8b8c477512bb2b671ab24366e0f28ca24e8257c Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Thu, 17 Jun 2021 12:55:54 +0000 Subject: [PATCH 12/14] Remove original examples directory Signed-off-by: Solomon Hykes --- examples/README.md | 297 ------------ examples/jamstack/backend.cue | 112 ----- examples/jamstack/database.cue | 41 -- examples/jamstack/ecr_image.cue | 53 --- examples/jamstack/ecs.cue | 152 ------ examples/jamstack/frontend.cue | 57 --- examples/jamstack/infra.cue | 35 -- examples/jamstack/inputs.yaml | 34 -- examples/jamstack/main.cue | 22 - examples/kubernetes-app/main.cue | 53 --- .../testdata/mychart/.helmignore | 23 - .../testdata/mychart/Chart.yaml | 21 - .../testdata/mychart/templates/NOTES.txt | 21 - .../testdata/mychart/templates/_helpers.tpl | 63 --- .../mychart/templates/deployment.yaml | 55 --- .../testdata/mychart/templates/ingress.yaml | 41 -- .../testdata/mychart/templates/service.yaml | 15 - .../mychart/templates/serviceaccount.yaml | 12 - .../templates/tests/test-connection.yaml | 15 - .../testdata/mychart/values.yaml | 68 --- .../cfn_template_eks_controlplane.cue | 447 ------------------ .../cfn_template_eks_nodegroup.cue | 89 ---- examples/kubernetes-aws/infrastructure.cue | 41 -- examples/kubernetes-aws/main.cue | 29 -- examples/monitoring/http_monitor.cue | 269 ----------- examples/monitoring/main.cue | 34 -- examples/react/.dagger/env/default/.gitignore | 2 - .../react/.dagger/env/default/values.yaml | 28 -- examples/react/cue.mod/pkg/dagger.io | 1 - examples/react/main.cue | 27 -- examples/simple-s3/main.cue | 29 -- examples/simple-s3/website/index.html | 9 - tests/examples.bats | 18 - 33 files changed, 2213 deletions(-) delete mode 100644 examples/README.md delete mode 100644 examples/jamstack/backend.cue delete mode 100644 examples/jamstack/database.cue delete mode 100644 examples/jamstack/ecr_image.cue delete mode 100644 examples/jamstack/ecs.cue delete mode 100644 examples/jamstack/frontend.cue delete mode 100644 examples/jamstack/infra.cue delete mode 100644 examples/jamstack/inputs.yaml delete mode 100644 examples/jamstack/main.cue delete mode 100644 examples/kubernetes-app/main.cue delete mode 100644 examples/kubernetes-app/testdata/mychart/.helmignore delete mode 100644 examples/kubernetes-app/testdata/mychart/Chart.yaml delete mode 100644 examples/kubernetes-app/testdata/mychart/templates/NOTES.txt delete mode 100644 examples/kubernetes-app/testdata/mychart/templates/_helpers.tpl delete mode 100644 examples/kubernetes-app/testdata/mychart/templates/deployment.yaml delete mode 100644 examples/kubernetes-app/testdata/mychart/templates/ingress.yaml delete mode 100644 examples/kubernetes-app/testdata/mychart/templates/service.yaml delete mode 100644 examples/kubernetes-app/testdata/mychart/templates/serviceaccount.yaml delete mode 100644 examples/kubernetes-app/testdata/mychart/templates/tests/test-connection.yaml delete mode 100644 examples/kubernetes-app/testdata/mychart/values.yaml delete mode 100644 examples/kubernetes-aws/cfn_template_eks_controlplane.cue delete mode 100644 examples/kubernetes-aws/cfn_template_eks_nodegroup.cue delete mode 100644 examples/kubernetes-aws/infrastructure.cue delete mode 100644 examples/kubernetes-aws/main.cue delete mode 100644 examples/monitoring/http_monitor.cue delete mode 100644 examples/monitoring/main.cue delete mode 100644 examples/react/.dagger/env/default/.gitignore delete mode 100644 examples/react/.dagger/env/default/values.yaml delete mode 120000 examples/react/cue.mod/pkg/dagger.io delete mode 100644 examples/react/main.cue delete mode 100644 examples/simple-s3/main.cue delete mode 100644 examples/simple-s3/website/index.html delete mode 100644 tests/examples.bats diff --git a/examples/README.md b/examples/README.md deleted file mode 100644 index 5de5c8b1..00000000 --- a/examples/README.md +++ /dev/null @@ -1,297 +0,0 @@ -# Dagger Examples - -All example commands should be executed in the `examples/` directory -in an up-to-date checkout of the [dagger repository](https://github.com/dagger/dagger). - -## Deploy a static page to S3 - -This example shows how to generate a simple HTML page and serve it from an S3 bucket. - -Components: - -- [Amazon S3](https://aws.amazon.com/s3/) for hosting - -1. Initialize a new workspace - -```sh -cd ./simple-s3 -dagger init -``` - -2. Create a new environment - -```sh -dagger new simple-s3 -cp *.cue ./.dagger/env/simple-s3/plan/ -``` - -3. Configure your AWS credentials - -```sh -dagger input secret awsConfig.accessKey MY_AWS_ACCESS_KEY -dagger input secret awsConfig.secretKey MY_AWS_SECRET_KEY -``` - -4. Specify the source code location - -```sh -dagger input dir source website -``` - -5. Deploy! - -```sh -dagger up -``` - -6. Check the URL - -```sh -curl -i $(dagger query url -f text) -``` - -## Deploy a simple React application - -This example shows how to deploy an example React Application. [Read the deployment plan](https://github.com/dagger/dagger/tree/main/examples/react) - -Audience: Javascript developers looking to deploy their application. - -Components: - -- [Netlify](https://netlify.com) for application hosting -- [Yarn](https://yarnpkg.com) for building -- [Github](https://github.com) for source code hosting -- [React-Todo-App](https://github.com/kabirbaidhya/react-todo-app) by Kabir Baidhya as a sample application. - -1. Initialize a new workspace - -```sh -cd ./react -dagger init -``` - -2. Create a new environment - -```sh -dagger new react -cp *.cue ./.dagger/env/react/plan/ -``` - -3. Configure the deployment with your Netlify access token. - You can create new tokens from the [Netlify dashboard](https://app.netlify.com/user/applications/personal). - -```sh -dagger input secret www.account.token MY_TOKEN -``` - -_NOTE: there is a dedicated command for encrypted secret inputs, but it is -not yet implemented. Coming soon!_ - -4. Deploy! - -```sh -dagger up -``` - -## Deploy a complete JAMstack app - -This example shows how to deploy a complete app with a backend, a database and a frontend. - -This app assumes the following infrastructure is available: - -- AWS ECS Cluster -- AWS ALB with a TLS certificate -- AWS RDS Instance (MySQL or PostgreSQL) -- AWS ECR repository - -1. Initialize a new workspace - -```sh -cd ./jamstack -dagger init -``` - -2. Create a new environment - -```sh -dagger new jamstack -cp *.cue ./.dagger/env/jamstack/plan/ -``` - -3. Edit the inputs - -Edit the file `inputs.yaml` and review all values to match to your infrastructure. - -Add the inputs to the deployment: - -```sh -dagger input yaml "" -f ./inputs.yaml -``` - -4. Deploy! - -```sh -dagger up -``` - -The example `inputs.yaml` from the `./examples/jamstack` directory takes the source code from a remote git repository, but you can remove this from the file and instead points to a local source code: - -```sh -dagger input dir backend.source ./my/local/backend/code -``` - -And the same mechanism applies for every single key in this file. - -5. Get the App URL - -```sh -dagger query url -``` - -## Provision a Kubernetes cluster on AWS - -This example shows how to provision a new Kubernetes cluster on AWS, and configure your `kubectl` client to use it. [Read the deployment plan](https://github.com/dagger/dagger/tree/main/examples/kubernetes-aws) - -Audience: infrastructure teams looking to provisioning kubernetes clusters as part of automated CICD pipelines. - -Components: - -- [Amazon EKS](https://aws.amazon.com/eks) for Kubernetes hosting -- [Amazon CloudFormation](https://aws.amazon.com/cloudformation) for infrastructure provisioning -- [Kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) as kubernetes client - -1. Initialize a new workspace - -```sh -cd ./kubernetes-aws -dagger init -``` - -2. Create a new environment - -```sh -dagger new kubernetes-aws -cp *.cue ./.dagger/env/kubernetes-aws/plan/ -``` - -3. Configure the deployment with your AWS credentials - -```sh -dagger input secret awsConfig.accessKey MY_AWS_ACCESS_KEY -dagger input secret awsConfig.secretKey MY_AWS_SECRET_KEY -``` - -4. Deploy! - -```sh -dagger up -``` - -5. Export the generated kubectl config - -```sh -dagger query kubeconfig.kubeconfig | jq . > kubeconfig -``` - -## Add HTTP monitoring to your application - -This example shows how to implement a robust HTTP(s) monitoring service on top of AWS. [Read the deployment plan](https://github.com/dagger/dagger/tree/main/examples/monitoring). - -Audience: application team looking to improve the reliability of their application. - -Components: - -- [Amazon Cloudwatch Synthetics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html) for hosting the monitoring scripts -- [Amazon CloudFormation](https://aws.amazon.com/cloudformation) for infrastructure provisioning - -1. Initialize a new workspace - -```sh -cd ./monitoring -dagger init -``` - -2. Create a new environment - -```sh -dagger new monitoring -cp *.cue ./.dagger/env/monitoring/plan/ -``` - -2. Configure the deployment with your AWS credentials - -```sh -dagger input text awsConfig.accessKey MY_AWS_ACCESS_KEY -dagger input text awsConfig.secretKey MY_AWS_SECRET_KEY -``` - -3. Configure the monitoring parameters - -```sh -dagger input text website https://MYWEBSITE.TLD -``` - -```sh -dagger input text email my_email@my_domain.tld -``` - -4. Deploy! - -```sh -dagger up -``` - -## Deploy an application to your Kubernetes cluster - -This example shows two different ways to deploy an application to an existing Kubernetes cluster: with and without a Helm chart. Read the deployment plan](https://github.com/dagger/dagger/tree/main/examples/kubernetes-app) - -NOTE: this example requires an EKS cluster to allow authentication with your AWS credentials; but can easily be adapter to deploy to any Kubernetes cluster. - -Components: - -- [Amazon EKS](https://aws.amazon.com/eks) for Kubernetes hosting -- [Kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) as kubernetes client -- [Helm](https://helm.sh) to manage kubernetes configuration (optional) - -How to run: - -1. Initialize a new workspace - -```sh -cd ./kubernetes-app -dagger init -``` - -2. Create a new environment - -```sh -dagger new kubernetes-app -cp *.cue ./.dagger/env/kubernetes-app/plan/ -``` - -3. Configure the deployment with your AWS credentials - -```sh -dagger input secret awsConfig.accessKey MY_AWS_ACCESS_KEY -dagger input secret awsConfig.secretKey MY_AWS_SECRET_KEY -``` - -4. Configure the EKS cluster to deploy to - -Note: if you have run the `kubernetes-aws` example, you may skip this step. - -```sh -dagger input text cluster.clusterName MY_CLUSTER_NAME -``` - -5. Load the Helm chart - -```sh -dagger input dir helmChart.chart ./kubernetes-app/testdata/mychart -``` - -6. Deploy! - -```sh -dagger up -``` diff --git a/examples/jamstack/backend.cue b/examples/jamstack/backend.cue deleted file mode 100644 index ad79986e..00000000 --- a/examples/jamstack/backend.cue +++ /dev/null @@ -1,112 +0,0 @@ -package main - -import ( - "dagger.io/dagger" - "dagger.io/aws/ecs" - "dagger.io/git" -) - -// Backend configuration -backend: { - - // Source code to build this container - source: git.#Repository | dagger.#Artifact @dagger(input) - - // Container environment variables - environment: { - [string]: string - } @dagger(input) - - // Public hostname (need to match the master domain configures on the loadbalancer) - hostname: string @dagger(input) - - // Container configuration - container: { - // Desired number of running containers - desiredCount: *1 | int @dagger(input) - // Time to wait for the HTTP timeout to complete - healthCheckTimeout: *10 | int @dagger(input) - // HTTP Path to perform the healthcheck request (HTTP Get) - healthCheckPath: *"/" | string @dagger(input) - // Number of times the health check needs to fail before recycling the container - healthCheckUnhealthyThreshold: *2 | int @dagger(input) - // Port used by the process inside the container - port: *80 | int @dagger(input) - // Memory to allocate - memory: *1024 | int @dagger(input) - // Override the default container command - command: [...string] @dagger(input) - // Custom dockerfile path - dockerfilePath: *"" | string @dagger(input) - // docker build args - dockerBuildArgs: { - [string]: string - } @dagger(input) - } - - // Init container runs only once when the main container starts - initContainer: { - command: [...string] @dagger(input) - environment: { - [string]: string - } @dagger(input) - } -} - -// Backend deployment logic -backend: { - let slug = name - - // Docker image built from source, pushed to ECR - image: #ECRImage & { - source: backend.source - repository: infra.ecrRepository - tag: slug - awsConfig: infra.awsConfig - if backend.container.dockerfilePath != "" { - dockerfilePath: backend.container.dockerfilePath - } - buildArgs: backend.container.dockerBuildArgs - } - - // Creates an ECS Task + Service + deploy via Cloudformation - app: #ECSApp & { - awsConfig: infra.awsConfig - "slug": slug - clusterName: infra.ecsClusterName - vpcId: infra.vpcId - elbListenerArn: infra.elbListenerArn - if infra.ecsTaskRoleArn != _|_ { - taskRoleArn: infra.ecsTaskRoleArn - } - hostname: backend.hostname - healthCheck: { - timeout: backend.container.healthCheckTimeout - path: backend.container.healthCheckPath - unhealthyThresholdCount: backend.container.healthCheckUnhealthyThreshold - } - desiredCount: backend.container.desiredCount - container: { - command: backend.container.command - environment: backend.environment - port: backend.container.port - memory: backend.container.memory - "image": image.ref - } - } - - // Optional container to run one-time during the deploy (eg. db migration) - if len(backend.initContainer.command) > 0 { - initContainer: ecs.#RunTask & { - config: infra.awsConfig - containerName: slug - cluster: infra.ecsClusterName - if infra.ecsTaskRoleArn != _|_ { - roleArn: infra.ecsTaskRoleArn - } - containerEnvironment: backend.initContainer.environment - containerCommand: backend.initContainer.command - taskArn: app.taskArn - } - } -} diff --git a/examples/jamstack/database.cue b/examples/jamstack/database.cue deleted file mode 100644 index 46fe445a..00000000 --- a/examples/jamstack/database.cue +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "encoding/base64" - "dagger.io/aws/rds" -) - -database: { - let slug = name - dbType: "mysql" | "postgresql" @dagger(input) - - db: rds.#Database & { - config: infra.awsConfig - name: slug - dbArn: infra.rdsInstanceArn - "dbType": dbType - secretArn: infra.rdsAdminSecretArn - } - - user: rds.#User & { - config: infra.awsConfig - dbArn: infra.rdsInstanceArn - "dbType": dbType - secretArn: infra.rdsAdminSecretArn - username: slug - // FIXME: make it secure (generate infra side?) - password: base64.Encode(null, "pwd-\(slug)") - grantDatabase: db.out - } - - instance: rds.#Instance & { - config: infra.awsConfig - dbArn: infra.rdsInstanceArn - } - - hostname: instance.hostname - port: instance.port - dbName: db.out - username: user.out - password: user.password -} diff --git a/examples/jamstack/ecr_image.cue b/examples/jamstack/ecr_image.cue deleted file mode 100644 index a98c5544..00000000 --- a/examples/jamstack/ecr_image.cue +++ /dev/null @@ -1,53 +0,0 @@ -package main - -import ( - "dagger.io/dagger" - "dagger.io/dagger/op" - "dagger.io/aws" - "dagger.io/aws/ecr" -) - -// Build an image and push it to ECR -#ECRImage: { - source: dagger.#Artifact - // Path of the Dockerfile - dockerfilePath?: string - repository: string - tag: string - awsConfig: aws.#Config - buildArgs: [string]: string - - // Use these credentials to push - ecrCreds: ecr.#Credentials & { - config: awsConfig - } - - ref: { - string - - #up: [ - // Build the docker image - op.#DockerBuild & { - context: source - if dockerfilePath != _|_ { - "dockerfilePath": dockerfilePath - } - buildArg: buildArgs - }, - // Login to Registry - op.#DockerLogin & { - target: repository - username: ecrCreds.username - secret: ecrCreds.secret - }, - // Push the image to the registry - op.#PushContainer & { - ref: "\(repository):\(tag)" - }, - op.#Export & { - source: "/dagger/image_ref" - format: "string" - }, - ] - } -} diff --git a/examples/jamstack/ecs.cue b/examples/jamstack/ecs.cue deleted file mode 100644 index e496c8ac..00000000 --- a/examples/jamstack/ecs.cue +++ /dev/null @@ -1,152 +0,0 @@ -package main - -import ( - "encoding/json" - - "dagger.io/aws" - "dagger.io/aws/elb" - "dagger.io/aws/cloudformation" -) - -#ECSApp: { - awsConfig: aws.#Config - slug: string - clusterName: string - vpcId: string - elbListenerArn: string - taskRoleArn: *"" | string - hostname: string - healthCheck: { - timeout: *10 | int - path: *"/" | string - unhealthyThresholdCount: *2 | int - } - desiredCount: int - container: { - command: [...string] - environment: [string]: string - port: *80 | int - cpu: *256 | int - memory: *1024 | int - image: string - } - - taskArn: cfnStack.outputs.TaskArn - - elbRulePriority: elb.#RandomRulePriority & { - config: awsConfig - listenerArn: elbListenerArn - vhost: hostname - } - - cfnStack: cloudformation.#Stack & { - config: awsConfig - stackName: slug - onFailure: "DO_NOTHING" - parameters: { - ELBRulePriority: elbRulePriority.out - ImageRef: container.image - ELBListenerArn: elbListenerArn - } - source: json.Marshal(template) - } - - template: { - AWSTemplateFormatVersion: "2010-09-09" - Description: "Dagger deployed app" - Parameters: { - ELBRulePriority: Type: "Number" - ImageRef: Type: "String" - ELBListenerArn: Type: "String" - } - Resources: { - ECSTaskDefinition: { - Type: "AWS::ECS::TaskDefinition" - Properties: { - Cpu: "\(container.cpu)" - Memory: "\(container.memory)" - if taskRoleArn != "" { - TaskRoleArn: taskRoleArn - } - NetworkMode: "bridge" - ContainerDefinitions: [{ - if len(container.command) > 0 { - Command: container.command - } - Name: slug - Image: Ref: "ImageRef" - Essential: true - Environment: [ for k, v in container.environment { - Name: k - Value: v - }] - PortMappings: [{ - ContainerPort: container.port - }] - StopTimeout: 5 - LogConfiguration: { - LogDriver: "awslogs" - Options: { - "awslogs-group": "bl/provider/ecs/\(clusterName)" - "awslogs-region": Ref: "AWS::Region" - "awslogs-create-group": "true" - "awslogs-stream-prefix": slug - } - } - }] - } - } - ECSListenerRule: { - Type: "AWS::ElasticLoadBalancingV2::ListenerRule" - Properties: { - ListenerArn: Ref: "ELBListenerArn" - Priority: Ref: "ELBRulePriority" - Conditions: [{ - Field: "host-header" - Values: [hostname]}] - Actions: [{ - Type: "forward" - TargetGroupArn: Ref: "ECSTargetGroup" - }]}} - ECSTargetGroup: { - Type: "AWS::ElasticLoadBalancingV2::TargetGroup" - Properties: { - Protocol: "HTTP" - VpcId: vpcId - Port: 80 - HealthCheckPath: healthCheck.path - UnhealthyThresholdCount: healthCheck.unhealthyThresholdCount - HealthCheckTimeoutSeconds: healthCheck.timeout - HealthCheckIntervalSeconds: healthCheck.timeout + 1 - HealthyThresholdCount: 3 - TargetGroupAttributes: [{ - Value: "10" - Key: "deregistration_delay.timeout_seconds" - }]}} - ECSService: { - Type: "AWS::ECS::Service" - Properties: { - Cluster: clusterName - DesiredCount: desiredCount - LaunchType: "EC2" - LoadBalancers: [{ - ContainerPort: container.port - TargetGroupArn: Ref: "ECSTargetGroup" - ContainerName: slug - }] - ServiceName: slug - TaskDefinition: Ref: "ECSTaskDefinition" - DeploymentConfiguration: { - DeploymentCircuitBreaker: { - Enable: true - Rollback: true - } - MaximumPercent: 200 - MinimumHealthyPercent: 100 - }} - DependsOn: "ECSListenerRule" - } - } - Outputs: TaskArn: Value: Ref: "ECSTaskDefinition" - } -} diff --git a/examples/jamstack/frontend.cue b/examples/jamstack/frontend.cue deleted file mode 100644 index d6596e6a..00000000 --- a/examples/jamstack/frontend.cue +++ /dev/null @@ -1,57 +0,0 @@ -package main - -import ( - "dagger.io/dagger" - "dagger.io/netlify" - "dagger.io/js/yarn" - "dagger.io/git" -) - -frontend: { - // Source code to build the app - source: git.#Repository | dagger.#Artifact @dagger(input) - - writeEnvFile?: string @dagger(input) - - // Yarn Build - yarn: { - // Run this yarn script - script: string | *"build" @dagger(input) - - // Read build output from this directory - // (path must be relative to working directory). - buildDir: string | *"build" @dagger(input) - } - - // Build environment variables - environment: { - [string]: string @dagger(input) - } - environment: { - NODE_ENV: string | *"production" @dagger(input) - } - environment: { - APP_URL: "https://\(name).netlify.app/" @dagger(input) - } -} - -frontend: { - app: yarn.#Package & { - source: frontend.source - env: frontend.environment - - if frontend.writeEnvFile != _|_ { - writeEnvFile: frontend.writeEnvFile - } - - script: frontend.yarn.script - buildDir: frontend.yarn.buildDir - } - - // Host the application with Netlify - site: netlify.#Site & { - "name": name - account: infra.netlifyAccount - contents: app.build - } -} diff --git a/examples/jamstack/infra.cue b/examples/jamstack/infra.cue deleted file mode 100644 index db076093..00000000 --- a/examples/jamstack/infra.cue +++ /dev/null @@ -1,35 +0,0 @@ -package main - -import ( - "dagger.io/aws" - "dagger.io/netlify" -) - -infra: { - // AWS auth & default region - awsConfig: aws.#Config - - // VPC Id - vpcId: string @dagger(input) - - // ECR Image repository - ecrRepository: string @dagger(input) - - // ECS cluster name - ecsClusterName: string @dagger(input) - - // Execution Role ARN used for all tasks running on the cluster - ecsTaskRoleArn?: string @dagger(input) - - // ELB listener ARN - elbListenerArn: string @dagger(input) - - // Secret ARN for the admin password of the RDS Instance - rdsAdminSecretArn: string @dagger(input) - - // ARN of the RDS Instance - rdsInstanceArn: string @dagger(input) - - // Netlify credentials - netlifyAccount: netlify.#Account @dagger(input) -} diff --git a/examples/jamstack/inputs.yaml b/examples/jamstack/inputs.yaml deleted file mode 100644 index fd9d0658..00000000 --- a/examples/jamstack/inputs.yaml +++ /dev/null @@ -1,34 +0,0 @@ -name: my-app -infra: - awsConfig: - accessKey: - secretKey: - region: us-east-1 - vpcId: vpc-020ctgv0bcde4242 - ecrRepository: 8563296674124.dkr.ecr.us-east-1.amazonaws.com/apps - ecsClusterName: bl-ecs-acme-764-ECSCluster-lRIVVg09G4HX - elbListenerArn: arn:aws:elasticloadbalancing:us-east-1:8563296674124:listener/app/bl-ec-ECSAL-OSYI03K07BCO/3c2d3e78347bde5b/d02ac88cc007e24e - rdsAdminSecretArn: arn:aws:secretsmanager:us-east-1:8563296674124:secret:AdminPassword-NQbBi7oU4CYS9-IGgS3B - rdsInstanceArn: arn:aws:rds:us-east-1:8563296674124:cluster:bl-rds-acme-764-rdscluster-8eg3xbfjggkfdg - netlifyAccount: - token: -database: - dbType: mysql -backend: - source: - remote: https://github.com/blocklayerhq/acme-clothing.git - ref: HEAD - subdir: ./crate/code/api - hostname: my-app.acme-764-api.microstaging.io - container: - healthCheckPath: /health-check - healthCheckTimeout: 40 -frontend: - source: - remote: https://github.com/blocklayerhq/acme-clothing.git - ref: HEAD - subdir: ./crate/code/web - writeEnvFile: .env - yarn: - buildDir: public - script: build:client diff --git a/examples/jamstack/main.cue b/examples/jamstack/main.cue deleted file mode 100644 index 05b40ef1..00000000 --- a/examples/jamstack/main.cue +++ /dev/null @@ -1,22 +0,0 @@ -package main - -// Name of the application -name: string & =~"[a-z0-9-]+" @dagger(input) - -// Inject db info in the container environment -backend: environment: { - DB_USERNAME: database.username - DB_HOSTNAME: database.hostname - DB_PASSWORD: database.password - DB_DBNAME: database.dbName - DB_PORT: "\(database.port)" - DB_TYPE: database.dbType -} - -// Configure the frontend with the API URL -frontend: environment: APP_URL_API: url.backendURL - -url: { - frontendURL: frontend.site.url @dagger(output) - backendURL: "https://\(backend.hostname)/" @dagger(output) -} diff --git a/examples/kubernetes-app/main.cue b/examples/kubernetes-app/main.cue deleted file mode 100644 index 3185ef5b..00000000 --- a/examples/kubernetes-app/main.cue +++ /dev/null @@ -1,53 +0,0 @@ -package main - -import ( - "encoding/yaml" - "dagger.io/dagger" - "dagger.io/aws" - "dagger.io/aws/eks" - "dagger.io/kubernetes" - "dagger.io/kubernetes/helm" -) - -kubeSrc: { - apiVersion: "v1" - kind: "Pod" - metadata: name: "kube-test" - spec: { - restartPolicy: "Never" - containers: [{ - name: "test" - image: "hello-world" - }] - } -} - -// Fill using: -// --input-string awsConfig.accessKey=XXX -// --input-string awsConfig.secretKey=XXX -awsConfig: aws.#Config & { - region: *"us-east-2" | string -} - -// Take the kubeconfig from the EKS cluster -cluster: eks.#KubeConfig & { - config: awsConfig - clusterName: *"dagger-example-eks-cluster" | string -} - -// Example of a simple `kubectl apply` using a simple config -kubeApply: kubernetes.#Resources & { - manifest: yaml.Marshal(kubeSrc) - namespace: "test" - kubeconfig: cluster.kubeconfig -} - -// Example of a `helm install` using a local chart -// Fill using: -// --input-dir helmChart.chartSource=./testdata/mychart -helmChart: helm.#Chart & { - name: "test-helm" - namespace: "test" - kubeconfig: cluster.kubeconfig - chartSource: dagger.#Artifact -} diff --git a/examples/kubernetes-app/testdata/mychart/.helmignore b/examples/kubernetes-app/testdata/mychart/.helmignore deleted file mode 100644 index 0e8a0eb3..00000000 --- a/examples/kubernetes-app/testdata/mychart/.helmignore +++ /dev/null @@ -1,23 +0,0 @@ -# Patterns to ignore when building packages. -# This supports shell glob matching, relative path matching, and -# negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ diff --git a/examples/kubernetes-app/testdata/mychart/Chart.yaml b/examples/kubernetes-app/testdata/mychart/Chart.yaml deleted file mode 100644 index 1613bff5..00000000 --- a/examples/kubernetes-app/testdata/mychart/Chart.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: v2 -name: mychart -description: A Helm chart for Kubernetes - -# A chart can be either an 'application' or a 'library' chart. -# -# Application charts are a collection of templates that can be packaged into versioned archives -# to be deployed. -# -# Library charts provide useful utilities or functions for the chart developer. They're included as -# a dependency of application charts to inject those utilities and functions into the rendering -# pipeline. Library charts do not define any templates and therefore cannot be deployed. -type: application - -# This is the chart version. This version number should be incremented each time you make changes -# to the chart and its templates, including the app version. -version: 0.1.0 - -# This is the version number of the application being deployed. This version number should be -# incremented each time you make changes to the application. -appVersion: 1.16.0 diff --git a/examples/kubernetes-app/testdata/mychart/templates/NOTES.txt b/examples/kubernetes-app/testdata/mychart/templates/NOTES.txt deleted file mode 100644 index 8b795a8a..00000000 --- a/examples/kubernetes-app/testdata/mychart/templates/NOTES.txt +++ /dev/null @@ -1,21 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range $host := .Values.ingress.hosts }} - {{- range .paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} - {{- end }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "mychart.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "mychart.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "mychart.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "mychart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 -{{- end }} diff --git a/examples/kubernetes-app/testdata/mychart/templates/_helpers.tpl b/examples/kubernetes-app/testdata/mychart/templates/_helpers.tpl deleted file mode 100644 index 8479665d..00000000 --- a/examples/kubernetes-app/testdata/mychart/templates/_helpers.tpl +++ /dev/null @@ -1,63 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "mychart.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "mychart.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "mychart.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Common labels -*/}} -{{- define "mychart.labels" -}} -helm.sh/chart: {{ include "mychart.chart" . }} -{{ include "mychart.selectorLabels" . }} -{{- if .Chart.AppVersion }} -app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} -{{- end }} -app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- end -}} - -{{/* -Selector labels -*/}} -{{- define "mychart.selectorLabels" -}} -app.kubernetes.io/name: {{ include "mychart.name" . }} -app.kubernetes.io/instance: {{ .Release.Name }} -{{- end -}} - -{{/* -Create the name of the service account to use -*/}} -{{- define "mychart.serviceAccountName" -}} -{{- if .Values.serviceAccount.create -}} - {{ default (include "mychart.fullname" .) .Values.serviceAccount.name }} -{{- else -}} - {{ default "default" .Values.serviceAccount.name }} -{{- end -}} -{{- end -}} diff --git a/examples/kubernetes-app/testdata/mychart/templates/deployment.yaml b/examples/kubernetes-app/testdata/mychart/templates/deployment.yaml deleted file mode 100644 index 38e698f8..00000000 --- a/examples/kubernetes-app/testdata/mychart/templates/deployment.yaml +++ /dev/null @@ -1,55 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "mychart.fullname" . }} - labels: - {{- include "mychart.labels" . | nindent 4 }} -spec: - replicas: {{ .Values.replicaCount }} - selector: - matchLabels: - {{- include "mychart.selectorLabels" . | nindent 6 }} - template: - metadata: - labels: - {{- include "mychart.selectorLabels" . | nindent 8 }} - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "mychart.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} - containers: - - name: {{ .Chart.Name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: 80 - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/examples/kubernetes-app/testdata/mychart/templates/ingress.yaml b/examples/kubernetes-app/testdata/mychart/templates/ingress.yaml deleted file mode 100644 index 76d277c0..00000000 --- a/examples/kubernetes-app/testdata/mychart/templates/ingress.yaml +++ /dev/null @@ -1,41 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "mychart.fullname" . -}} -{{- $svcPort := .Values.service.port -}} -{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: networking.k8s.io/v1beta1 -{{- else -}} -apiVersion: extensions/v1beta1 -{{- end }} -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - {{- include "mychart.labels" . | nindent 4 }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ .host | quote }} - http: - paths: - {{- range .paths }} - - path: {{ . }} - backend: - serviceName: {{ $fullName }} - servicePort: {{ $svcPort }} - {{- end }} - {{- end }} -{{- end }} diff --git a/examples/kubernetes-app/testdata/mychart/templates/service.yaml b/examples/kubernetes-app/testdata/mychart/templates/service.yaml deleted file mode 100644 index bdceb88f..00000000 --- a/examples/kubernetes-app/testdata/mychart/templates/service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "mychart.fullname" . }} - labels: - {{- include "mychart.labels" . | nindent 4 }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - {{- include "mychart.selectorLabels" . | nindent 4 }} diff --git a/examples/kubernetes-app/testdata/mychart/templates/serviceaccount.yaml b/examples/kubernetes-app/testdata/mychart/templates/serviceaccount.yaml deleted file mode 100644 index 145e891e..00000000 --- a/examples/kubernetes-app/testdata/mychart/templates/serviceaccount.yaml +++ /dev/null @@ -1,12 +0,0 @@ -{{- if .Values.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "mychart.serviceAccountName" . }} - labels: - {{- include "mychart.labels" . | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end -}} diff --git a/examples/kubernetes-app/testdata/mychart/templates/tests/test-connection.yaml b/examples/kubernetes-app/testdata/mychart/templates/tests/test-connection.yaml deleted file mode 100644 index 0bd46ef1..00000000 --- a/examples/kubernetes-app/testdata/mychart/templates/tests/test-connection.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ include "mychart.fullname" . }}-test-connection" - labels: - {{- include "mychart.labels" . | nindent 4 }} - annotations: - "helm.sh/hook": test-success -spec: - containers: - - name: wget - image: busybox - command: ['wget'] - args: ['{{ include "mychart.fullname" . }}:{{ .Values.service.port }}'] - restartPolicy: Never diff --git a/examples/kubernetes-app/testdata/mychart/values.yaml b/examples/kubernetes-app/testdata/mychart/values.yaml deleted file mode 100644 index dbf4257e..00000000 --- a/examples/kubernetes-app/testdata/mychart/values.yaml +++ /dev/null @@ -1,68 +0,0 @@ -# Default values for mychart. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -replicaCount: 1 - -image: - repository: nginx - pullPolicy: IfNotPresent - -imagePullSecrets: [] -nameOverride: "" -fullnameOverride: "" - -serviceAccount: - # Specifies whether a service account should be created - create: true - # Annotations to add to the service account - annotations: {} - # The name of the service account to use. - # If not set and create is true, a name is generated using the fullname template - name: - -podSecurityContext: {} - # fsGroup: 2000 - -securityContext: {} - # capabilities: - # drop: - # - ALL - # readOnlyRootFilesystem: true - # runAsNonRoot: true - # runAsUser: 1000 - -service: - type: ClusterIP - port: 80 - -ingress: - enabled: false - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - hosts: - - host: chart-example.local - paths: [] - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi - -nodeSelector: {} - -tolerations: [] - -affinity: {} diff --git a/examples/kubernetes-aws/cfn_template_eks_controlplane.cue b/examples/kubernetes-aws/cfn_template_eks_controlplane.cue deleted file mode 100644 index 522cc67e..00000000 --- a/examples/kubernetes-aws/cfn_template_eks_controlplane.cue +++ /dev/null @@ -1,447 +0,0 @@ -package main - -#CFNTemplate: eksControlPlane: { - AWSTemplateFormatVersion: "2010-09-09" - Description: "Amazon EKS Sample VPC - Private and Public subnets" - Parameters: { - VpcBlock: { - Type: "String" - Default: "192.168.0.0/16" - Description: "The CIDR range for the VPC. This should be a valid private (RFC 1918) CIDR range." - } - PublicSubnet01Block: { - Type: "String" - Default: "192.168.0.0/18" - Description: "CidrBlock for public subnet 01 within the VPC" - } - PublicSubnet02Block: { - Type: "String" - Default: "192.168.64.0/18" - Description: "CidrBlock for public subnet 02 within the VPC" - } - PrivateSubnet01Block: { - Type: "String" - Default: "192.168.128.0/18" - Description: "CidrBlock for private subnet 01 within the VPC" - } - PrivateSubnet02Block: { - Type: "String" - Default: "192.168.192.0/18" - Description: "CidrBlock for private subnet 02 within the VPC" - } - ClusterName: { - Type: "String" - Description: "The EKS cluster name" - } - } - Metadata: "AWS::CloudFormation::Interface": ParameterGroups: [ - { - Label: default: "Worker Network Configuration" - Parameters: [ - "VpcBlock", - "PublicSubnet01Block", - "PublicSubnet02Block", - "PrivateSubnet01Block", - "PrivateSubnet02Block", - ] - }, - ] - Resources: { - VPC: { - Type: "AWS::EC2::VPC" - Properties: { - CidrBlock: Ref: "VpcBlock" - EnableDnsSupport: true - EnableDnsHostnames: true - Tags: [ - { - Key: "Name" - Value: "Fn::Sub": "${AWS::StackName}-VPC" - }, - ] - } - } - InternetGateway: Type: "AWS::EC2::InternetGateway" - VPCGatewayAttachment: { - Type: "AWS::EC2::VPCGatewayAttachment" - Properties: { - InternetGatewayId: Ref: "InternetGateway" - VpcId: Ref: "VPC" - } - } - PublicRouteTable: { - Type: "AWS::EC2::RouteTable" - Properties: { - VpcId: Ref: "VPC" - Tags: [ - { - Key: "Name" - Value: "Public Subnets" - }, - { - Key: "Network" - Value: "Public" - }, - ] - } - } - PrivateRouteTable01: { - Type: "AWS::EC2::RouteTable" - Properties: { - VpcId: Ref: "VPC" - Tags: [ - { - Key: "Name" - Value: "Private Subnet AZ1" - }, - { - Key: "Network" - Value: "Private01" - }, - ] - } - } - PrivateRouteTable02: { - Type: "AWS::EC2::RouteTable" - Properties: { - VpcId: Ref: "VPC" - Tags: [ - { - Key: "Name" - Value: "Private Subnet AZ2" - }, - { - Key: "Network" - Value: "Private02" - }, - ] - } - } - PublicRoute: { - DependsOn: "VPCGatewayAttachment" - Type: "AWS::EC2::Route" - Properties: { - RouteTableId: Ref: "PublicRouteTable" - DestinationCidrBlock: "0.0.0.0/0" - GatewayId: Ref: "InternetGateway" - } - } - PrivateRoute01: { - DependsOn: [ - "VPCGatewayAttachment", - "NatGateway01", - ] - Type: "AWS::EC2::Route" - Properties: { - RouteTableId: Ref: "PrivateRouteTable01" - DestinationCidrBlock: "0.0.0.0/0" - NatGatewayId: Ref: "NatGateway01" - } - } - PrivateRoute02: { - DependsOn: [ - "VPCGatewayAttachment", - "NatGateway02", - ] - Type: "AWS::EC2::Route" - Properties: { - RouteTableId: Ref: "PrivateRouteTable02" - DestinationCidrBlock: "0.0.0.0/0" - NatGatewayId: Ref: "NatGateway02" - } - } - NatGateway01: { - DependsOn: [ - "NatGatewayEIP1", - "PublicSubnet01", - "VPCGatewayAttachment", - ] - Type: "AWS::EC2::NatGateway" - Properties: { - AllocationId: "Fn::GetAtt": [ - "NatGatewayEIP1", - "AllocationId", - ] - SubnetId: Ref: "PublicSubnet01" - Tags: [ - { - Key: "Name" - Value: "Fn::Sub": "${AWS::StackName}-NatGatewayAZ1" - }, - ] - } - } - NatGateway02: { - DependsOn: [ - "NatGatewayEIP2", - "PublicSubnet02", - "VPCGatewayAttachment", - ] - Type: "AWS::EC2::NatGateway" - Properties: { - AllocationId: "Fn::GetAtt": [ - "NatGatewayEIP2", - "AllocationId", - ] - SubnetId: Ref: "PublicSubnet02" - Tags: [ - { - Key: "Name" - Value: "Fn::Sub": "${AWS::StackName}-NatGatewayAZ2" - }, - ] - } - } - NatGatewayEIP1: { - DependsOn: [ - "VPCGatewayAttachment", - ] - Type: "AWS::EC2::EIP" - Properties: Domain: "vpc" - } - NatGatewayEIP2: { - DependsOn: [ - "VPCGatewayAttachment", - ] - Type: "AWS::EC2::EIP" - Properties: Domain: "vpc" - } - PublicSubnet01: { - Type: "AWS::EC2::Subnet" - Metadata: Comment: "Subnet 01" - Properties: { - MapPublicIpOnLaunch: true - AvailabilityZone: "Fn::Select": [ - "0", - { - "Fn::GetAZs": Ref: "AWS::Region" - }, - ] - CidrBlock: Ref: "PublicSubnet01Block" - VpcId: Ref: "VPC" - Tags: [ - { - Key: "Name" - Value: "Fn::Sub": "${AWS::StackName}-PublicSubnet01" - }, - { - Key: "Fn::Sub": "kubernetes.io/cluster/${ClusterName}" - Value: "shared" - }, - ] - } - } - PublicSubnet02: { - Type: "AWS::EC2::Subnet" - Metadata: Comment: "Subnet 02" - Properties: { - MapPublicIpOnLaunch: true - AvailabilityZone: "Fn::Select": [ - "1", - { - "Fn::GetAZs": Ref: "AWS::Region" - }, - ] - CidrBlock: Ref: "PublicSubnet02Block" - VpcId: Ref: "VPC" - Tags: [ - { - Key: "Name" - Value: "Fn::Sub": "${AWS::StackName}-PublicSubnet02" - }, - { - Key: "Fn::Sub": "kubernetes.io/cluster/${ClusterName}" - Value: "shared" - }, - ] - } - } - PrivateSubnet01: { - Type: "AWS::EC2::Subnet" - Metadata: Comment: "Subnet 03" - Properties: { - AvailabilityZone: "Fn::Select": [ - "0", - { - "Fn::GetAZs": Ref: "AWS::Region" - }, - ] - CidrBlock: Ref: "PrivateSubnet01Block" - VpcId: Ref: "VPC" - Tags: [ - { - Key: "Name" - Value: "Fn::Sub": "${AWS::StackName}-PrivateSubnet01" - }, - { - Key: "Fn::Sub": "kubernetes.io/cluster/${ClusterName}" - Value: "shared" - }, - ] - } - } - PrivateSubnet02: { - Type: "AWS::EC2::Subnet" - Metadata: Comment: "Private Subnet 02" - Properties: { - AvailabilityZone: "Fn::Select": [ - "1", - { - "Fn::GetAZs": Ref: "AWS::Region" - }, - ] - CidrBlock: Ref: "PrivateSubnet02Block" - VpcId: Ref: "VPC" - Tags: [ - { - Key: "Name" - Value: "Fn::Sub": "${AWS::StackName}-PrivateSubnet02" - }, - { - Key: "Fn::Sub": "kubernetes.io/cluster/${ClusterName}" - Value: "shared" - }, - ] - } - } - PublicSubnet01RouteTableAssociation: { - Type: "AWS::EC2::SubnetRouteTableAssociation" - Properties: { - SubnetId: Ref: "PublicSubnet01" - RouteTableId: Ref: "PublicRouteTable" - } - } - PublicSubnet02RouteTableAssociation: { - Type: "AWS::EC2::SubnetRouteTableAssociation" - Properties: { - SubnetId: Ref: "PublicSubnet02" - RouteTableId: Ref: "PublicRouteTable" - } - } - PrivateSubnet01RouteTableAssociation: { - Type: "AWS::EC2::SubnetRouteTableAssociation" - Properties: { - SubnetId: Ref: "PrivateSubnet01" - RouteTableId: Ref: "PrivateRouteTable01" - } - } - PrivateSubnet02RouteTableAssociation: { - Type: "AWS::EC2::SubnetRouteTableAssociation" - Properties: { - SubnetId: Ref: "PrivateSubnet02" - RouteTableId: Ref: "PrivateRouteTable02" - } - } - ControlPlaneSecurityGroup: { - Type: "AWS::EC2::SecurityGroup" - Properties: { - GroupDescription: "Cluster communication with worker nodes" - VpcId: Ref: "VPC" - } - } - EKSIAMRole: { - Type: "AWS::IAM::Role" - Properties: { - AssumeRolePolicyDocument: Statement: [ - { - Effect: "Allow" - Principal: Service: [ - "eks.amazonaws.com", - ] - Action: [ - "sts:AssumeRole", - ] - - }, - ] - ManagedPolicyArns: [ - "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy", - "arn:aws:iam::aws:policy/AmazonEKSServicePolicy", - ] - } - } - EKSCluster: { - Type: "AWS::EKS::Cluster" - Properties: { - Name: Ref: "ClusterName" - Version: "1.19" - RoleArn: "Fn::GetAtt": ["EKSIAMRole", "Arn"] - ResourcesVpcConfig: { - SecurityGroupIds: [{Ref: "ControlPlaneSecurityGroup"}] - SubnetIds: [ - {Ref: "PublicSubnet01"}, - {Ref: "PublicSubnet02"}, - {Ref: "PrivateSubnet01"}, - {Ref: "PrivateSubnet02"}, - ] - } - } - DependsOn: ["EKSIAMRole", "PublicSubnet01", "PublicSubnet02", "PrivateSubnet01", "PrivateSubnet02", "ControlPlaneSecurityGroup"] - } - } - Outputs: { - SubnetIds: { - Description: "Subnets IDs in the VPC" - Value: "Fn::Join": [ - ",", - [ - { - Ref: "PublicSubnet01" - }, - { - Ref: "PublicSubnet02" - }, - { - Ref: "PrivateSubnet01" - }, - { - Ref: "PrivateSubnet02" - }, - ], - ] - } - PublicSubnets: { - Description: "List of the public subnets" - Value: "Fn::Join": [ - ",", - [ - { - Ref: "PublicSubnet01" - }, - { - Ref: "PublicSubnet02" - }, - ], - ] - } - PrivateSubnets: { - Description: "List of the private subnets" - Value: "Fn::Join": [ - ",", - [ - { - Ref: "PrivateSubnet01" - }, - { - Ref: "PrivateSubnet02" - }, - ], - ] - } - DefaultSecurityGroup: { - Description: "Security group for the cluster control plane communication with worker nodes" - Value: "Fn::Join": [ - ",", - [ - { - Ref: "ControlPlaneSecurityGroup" - }, - ], - ] - } - VPC: { - Description: "The VPC Id" - Value: Ref: "VPC" - } - } -} diff --git a/examples/kubernetes-aws/cfn_template_eks_nodegroup.cue b/examples/kubernetes-aws/cfn_template_eks_nodegroup.cue deleted file mode 100644 index ab38c50f..00000000 --- a/examples/kubernetes-aws/cfn_template_eks_nodegroup.cue +++ /dev/null @@ -1,89 +0,0 @@ -package main - -#CFNTemplate: eksNodeGroup: { - AWSTemplateFormatVersion: "2010-09-09" - Description: "Amazon EKS - Node Group" - Parameters: { - ClusterName: { - Type: "String" - Description: "The cluster name provided when the cluster was created. If it is incorrect, nodes will not be able to join the cluster." - } - NodeAutoScalingGroupDesiredCapacity: { - Type: "Number" - Default: 3 - Description: "Desired capacity of Node Group ASG." - } - NodeAutoScalingGroupMaxSize: { - Type: "Number" - Default: 4 - Description: "Maximum size of Node Group ASG. Set to at least 1 greater than NodeAutoScalingGroupDesiredCapacity." - } - NodeAutoScalingGroupMinSize: { - Type: "Number" - Default: 1 - Description: "Minimum size of Node Group ASG." - } - NodeInstanceType: { - Type: "String" - Default: "t3.medium" - ConstraintDescription: "Must be a valid EC2 instance type" - Description: "EC2 instance type for the node instances" - } - Subnets: { - Type: "List" - Description: "The subnets where workers can be created." - } - } - Resources: { - NodeInstanceRole: { - Type: "AWS::IAM::Role" - Properties: { - AssumeRolePolicyDocument: { - Version: "2012-10-17" - Statement: [ - { - Effect: "Allow" - Principal: Service: [ - "ec2.amazonaws.com", - ] - Action: [ - "sts:AssumeRole", - ] - }, - ] - } - ManagedPolicyArns: [ - "arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy", - "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy", - "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly", - ] - Path: "/" - } - } - Nodegroup: { - Type: "AWS::EKS::Nodegroup" - Properties: { - ClusterName: Ref: "ClusterName" - NodeRole: "Fn::GetAtt": [ - "NodeInstanceRole", - "Arn", - ] - ScalingConfig: { - MaxSize: Ref: "NodeAutoScalingGroupMaxSize" - MinSize: Ref: "NodeAutoScalingGroupMinSize" - DesiredSize: Ref: "NodeAutoScalingGroupDesiredCapacity" - } - InstanceTypes: [{Ref: "NodeInstanceType"}] - AmiType: "AL2_x86_64" - Subnets: Ref: "Subnets" - } - } - } - Outputs: NodeInstanceRole: { - Description: "The node instance role" - Value: "Fn::GetAtt": [ - "NodeInstanceRole", - "Arn", - ] - } -} diff --git a/examples/kubernetes-aws/infrastructure.cue b/examples/kubernetes-aws/infrastructure.cue deleted file mode 100644 index 2e43c7d5..00000000 --- a/examples/kubernetes-aws/infrastructure.cue +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "encoding/json" - - "dagger.io/aws" - "dagger.io/aws/cloudformation" -) - -#Infrastructure: { - awsConfig: aws.#Config - namePrefix: *"" | string - workerNodeCapacity: *3 | >=1 - workerNodeInstanceType: *"t3.medium" | string - - clusterName: "\(namePrefix)eks-cluster" - - eksControlPlane: cloudformation.#Stack & { - config: awsConfig - source: json.Marshal(#CFNTemplate.eksControlPlane) - stackName: "\(namePrefix)eks-controlplane" - neverUpdate: true - timeout: 30 - parameters: ClusterName: clusterName - } - - eksNodeGroup: cloudformation.#Stack & { - config: awsConfig - source: json.Marshal(#CFNTemplate.eksNodeGroup) - stackName: "\(namePrefix)eks-nodegroup" - neverUpdate: true - timeout: 30 - parameters: { - ClusterName: clusterName - NodeAutoScalingGroupDesiredCapacity: 1 - NodeAutoScalingGroupMaxSize: NodeAutoScalingGroupDesiredCapacity + 1 - NodeInstanceType: workerNodeInstanceType - Subnets: eksControlPlane.outputs.SubnetIds - } - } -} diff --git a/examples/kubernetes-aws/main.cue b/examples/kubernetes-aws/main.cue deleted file mode 100644 index e2dc91f3..00000000 --- a/examples/kubernetes-aws/main.cue +++ /dev/null @@ -1,29 +0,0 @@ -package main - -import ( - "dagger.io/aws" - "dagger.io/aws/eks" -) - -// AWS account: credentials and region -awsConfig: aws.#Config & { - region: *"us-east-2" | string -} - -// Auto-provision an EKS cluster: -// - VPC, Nat Gateways, Subnets, Security Group -// - EKS Cluster -// - Instance Node Group: auto-scaling-group, ec2 instances, etc... -// base config can be changed (number of EC2 instances, types, etc...) -infra: #Infrastructure & { - "awsConfig": awsConfig - namePrefix: "dagger-example-" - workerNodeCapacity: int | *1 - workerNodeInstanceType: "t3.small" -} - -// Client configuration for kubectl -kubeconfig: eks.#KubeConfig & { - config: awsConfig - clusterName: infra.clusterName -} diff --git a/examples/monitoring/http_monitor.cue b/examples/monitoring/http_monitor.cue deleted file mode 100644 index 0840a230..00000000 --- a/examples/monitoring/http_monitor.cue +++ /dev/null @@ -1,269 +0,0 @@ -package main - -import ( - "strings" - "regexp" - "encoding/json" - - "dagger.io/aws" - "dagger.io/aws/cloudformation" -) - -#Notification: { - protocol: string - endpoint: string -} - -#Canary: { - name: =~"^[0-9a-z_-]{1,21}$" - slug: strings.Join(regexp.FindAll("[0-9a-zA-Z]*", name, -1), "") - url: string - expectedHTTPCode: *200 | int - timeoutInSeconds: *30 | int - intervalExpression: *"1 minute" | string -} - -#HTTPMonitor: { - - // For sending notifications - notifications: [...#Notification] - // Canaries (tests) - canaries: [...#Canary] - // Name of the Cloudformation stack - cfnStackName: string - // AWS Config - awsConfig: aws.#Config - - cfnStack: cloudformation.#Stack & { - config: awsConfig - source: json.Marshal(#cfnTemplate) - stackName: cfnStackName - onFailure: "DO_NOTHING" - } - - // Function handler - #lambdaHandler: { - url: string - expectedHTTPCode: int - - script: #""" - var synthetics = require('Synthetics'); - const log = require('SyntheticsLogger'); - - const pageLoadBlueprint = async function () { - - // INSERT URL here - const URL = "\#(url)"; - - let page = await synthetics.getPage(); - const response = await page.goto(URL, {waitUntil: 'domcontentloaded', timeout: 30000}); - //Wait for page to render. - //Increase or decrease wait time based on endpoint being monitored. - await page.waitFor(15000); - // This will take a screenshot that will be included in test output artifacts - await synthetics.takeScreenshot('loaded', 'loaded'); - let pageTitle = await page.title(); - log.info('Page title: ' + pageTitle); - if (response.status() !== \#(expectedHTTPCode)) { - throw "Failed to load page!"; - } - }; - - exports.handler = async () => { - return await pageLoadBlueprint(); - }; - """# - } - - #cfnTemplate: { - AWSTemplateFormatVersion: "2010-09-09" - Description: "CloudWatch Synthetics website monitoring" - Resources: { - Topic: { - Type: "AWS::SNS::Topic" - Properties: Subscription: [ - for e in notifications { - Endpoint: e.endpoint - Protocol: e.protocol - }, - ] - } - TopicPolicy: { - Type: "AWS::SNS::TopicPolicy" - Properties: { - PolicyDocument: { - Id: "Id1" - Version: "2012-10-17" - Statement: [ - { - Sid: "Sid1" - Effect: "Allow" - Principal: AWS: "*" - Action: "sns:Publish" - Resource: Ref: "Topic" - Condition: StringEquals: "AWS:SourceOwner": Ref: "AWS::AccountId" - }, - ] - } - Topics: [ - { - Ref: "Topic" - }, - ] - } - } - CanaryBucket: { - Type: "AWS::S3::Bucket" - Properties: {} - } - CanaryRole: { - Type: "AWS::IAM::Role" - Properties: { - AssumeRolePolicyDocument: { - Version: "2012-10-17" - Statement: [ - { - Effect: "Allow" - Principal: Service: "lambda.amazonaws.com" - Action: "sts:AssumeRole" - }, - ] - } - Policies: [ - { - PolicyName: "execution" - PolicyDocument: { - Version: "2012-10-17" - Statement: [ - { - Effect: "Allow" - Action: "s3:ListAllMyBuckets" - Resource: "*" - }, - { - Effect: "Allow" - Action: "s3:PutObject" - Resource: "Fn::Sub": "${CanaryBucket.Arn}/*" - }, - { - Effect: "Allow" - Action: "s3:GetBucketLocation" - Resource: "Fn::GetAtt": [ - "CanaryBucket", - "Arn", - ] - }, - { - Effect: "Allow" - Action: "cloudwatch:PutMetricData" - Resource: "*" - Condition: StringEquals: "cloudwatch:namespace": "CloudWatchSynthetics" - }, - ] - } - }, - ] - } - } - CanaryLogGroup: { - Type: "AWS::Logs::LogGroup" - Properties: { - LogGroupName: "Fn::Sub": "/aws/lambda/cwsyn-\(cfnStackName)" - RetentionInDays: 14 - } - } - CanaryPolicy: { - Type: "AWS::IAM::Policy" - Properties: { - PolicyDocument: Statement: [ - { - Effect: "Allow" - Action: [ - "logs:CreateLogStream", - "logs:PutLogEvents", - ] - Resource: "Fn::GetAtt": [ - "CanaryLogGroup", - "Arn", - ] - }, - ] - PolicyName: "logs" - Roles: [ - { - Ref: "CanaryRole" - }, - ] - } - } - for canary in canaries { - "Canary\(canary.slug)": { - Type: "AWS::Synthetics::Canary" - Properties: { - ArtifactS3Location: "Fn::Sub": "s3://${CanaryBucket}" - Code: { - #handler: #lambdaHandler & { - url: canary.url - expectedHTTPCode: canary.expectedHTTPCode - } - Handler: "index.handler" - Script: #handler.script - } - ExecutionRoleArn: "Fn::GetAtt": [ - "CanaryRole", - "Arn", - ] - FailureRetentionPeriod: 30 - Name: canary.name - RunConfig: TimeoutInSeconds: canary.timeoutInSeconds - RuntimeVersion: "syn-1.0" - Schedule: { - DurationInSeconds: "0" - Expression: "rate(\(canary.intervalExpression))" - } - StartCanaryAfterCreation: true - SuccessRetentionPeriod: 30 - } - } - "SuccessPercentAlarm\(canary.slug)": { - DependsOn: "TopicPolicy" - Type: "AWS::CloudWatch::Alarm" - Properties: { - AlarmActions: [ - { - Ref: "Topic" - }, - ] - AlarmDescription: "Canary is failing." - ComparisonOperator: "LessThanThreshold" - Dimensions: [ - { - Name: "CanaryName" - Value: Ref: "Canary\(canary.slug)" - }, - ] - EvaluationPeriods: 1 - MetricName: "SuccessPercent" - Namespace: "CloudWatchSynthetics" - OKActions: [ - { - Ref: "Topic" - }, - ] - Period: 300 - Statistic: "Minimum" - Threshold: 90 - TreatMissingData: "notBreaching" - } - } - } - } - Outputs: { - for canary in canaries { - "\(canary.slug)Canary": Value: Ref: "Canary\(canary.slug)" - "\(canary.slug)URL": Value: canary.url - } - NumberCanaries: Value: len(canaries) - } - } -} diff --git a/examples/monitoring/main.cue b/examples/monitoring/main.cue deleted file mode 100644 index 49469f2d..00000000 --- a/examples/monitoring/main.cue +++ /dev/null @@ -1,34 +0,0 @@ -package main - -import ( - "dagger.io/aws" -) - -// AWS account: credentials and region -awsConfig: aws.#Config & { - region: *"us-east-1" | string @dagger(input) -} - -// URL of the website to monitor -website: string | *"https://www.google.com" @dagger(input) - -// Email address to notify of monitoring alerts -email: string @dagger(input) - -// The monitoring service running on AWS Cloudwatch -monitor: #HTTPMonitor & { - notifications: [ - #Notification & { - endpoint: email - protocol: "email" - }, - ] - canaries: [ - #Canary & { - name: "default" - url: website - }, - ] - cfnStackName: "my-monitor" - "awsConfig": awsConfig -} diff --git a/examples/react/.dagger/env/default/.gitignore b/examples/react/.dagger/env/default/.gitignore deleted file mode 100644 index 01ec19b0..00000000 --- a/examples/react/.dagger/env/default/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# dagger state -state/** diff --git a/examples/react/.dagger/env/default/values.yaml b/examples/react/.dagger/env/default/values.yaml deleted file mode 100644 index 8832017e..00000000 --- a/examples/react/.dagger/env/default/values.yaml +++ /dev/null @@ -1,28 +0,0 @@ -plan: - module: . -name: default -inputs: - www.account.name: - text: blocklayer - www.account.token: - secret: ENC[AES256_GCM,data:AGeCt/UJzWJ4UnzS/+t21GYz5wXPUoplYXTi1USXdi72wZemhzZncR2a+A==,iv:07DgGFL0oKgQsSZnp9s/Zz+6rdLShtHfStJZ9tHpsI4=,tag:jkY6TMrf7DaJMAc8/kJcAw==,type:str] -sops: - kms: [] - gcp_kms: [] - azure_kv: [] - hc_vault: [] - age: - - recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk - enc: | - -----BEGIN AGE ENCRYPTED FILE----- - YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBudkl4d2czaHZkSGt0SnVm - dm8xRTdaRE1WenpOczYxRFdMcDRkWDNmL1VzCjRHeWt3dnBITjlSNDZteWJhRmha - NWsrTThTZCt2eDJkRjgyOTFJeHdBMzgKLS0tIE9jOTFWMTRQei9iUkcvZDFrbmxn - ZnFaRWtEM241cDVCTStnK25BcDYyWlUKT2U8IFC21xMigjaTHHgkdUxIXKshxTmg - Q8254/qEWk+mJfsGxPf54d1RtqNqDX17kK/LeooSYAz7aqBjVLfG6w== - -----END AGE ENCRYPTED FILE----- - lastmodified: "2021-06-15T16:43:58Z" - mac: ENC[AES256_GCM,data:ihY1s1/ngxPrL940WkhRiVdmA+zPqcx9bVqlsWyAPfM/E5thIylNn7qMBDyFG6tHJAQFdqpbwCbQuKn6MVs+d+IgsoBwIcN1y4xQn2LhC53ludL2tG4CYyZM5EKx43EE/whzTuyNrPl9ykfx/u+KeQD5CNbaB9PrDjrtc+rNrPQ=,iv:7T2NHDXWrPJAsOVLPVhqFYnYcZjoBtE5x8R4CDUD+yM=,tag:yaXlTdSH7uvQiimKVPrvFg==,type:str] - pgp: [] - encrypted_suffix: secret - version: 3.7.1 diff --git a/examples/react/cue.mod/pkg/dagger.io b/examples/react/cue.mod/pkg/dagger.io deleted file mode 120000 index 1aafa4de..00000000 --- a/examples/react/cue.mod/pkg/dagger.io +++ /dev/null @@ -1 +0,0 @@ -../../../../stdlib \ No newline at end of file diff --git a/examples/react/main.cue b/examples/react/main.cue deleted file mode 100644 index 44c60c9e..00000000 --- a/examples/react/main.cue +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import ( - "dagger.io/netlify" - "dagger.io/js/yarn" - "dagger.io/git" -) - -// Source code of the sample application -repo: git.#Repository & { - remote: "https://github.com/kabirbaidhya/react-todo-app.git" - ref: "624041b17bd62292143f99bce474a0e3c2d2dd61" -} - -// Host the application with Netlify -www: netlify.#Site & { - // Site name can be overridden - name: string | *"dagger-examples-react" @dagger(input) - - // Deploy the output of yarn build - // (Netlify build feature is not used, to avoid extra cost). - contents: app.build -} - -app: yarn.#Package & { - source: repo -} diff --git a/examples/simple-s3/main.cue b/examples/simple-s3/main.cue deleted file mode 100644 index 7235ab19..00000000 --- a/examples/simple-s3/main.cue +++ /dev/null @@ -1,29 +0,0 @@ -package main - -import ( - "dagger.io/aws" - "dagger.io/aws/s3" - "dagger.io/dagger" -) - -// AWS Config for credentials and default region -awsConfig: aws.#Config & { - region: *"us-east-1" | string @dagger(input) -} - -// Name of the S3 bucket to use -bucket: *"dagger-io-examples" | string @dagger(input) - -// Source code to deploy -source: dagger.#Artifact @dagger(input) - -// Deployed URL -url: "\(deploy.url)index.html" @dagger(output) - -deploy: s3.#Object & { - always: true - config: awsConfig - "source": source - contentType: "text/html" - target: "s3://\(bucket)/" -} diff --git a/examples/simple-s3/website/index.html b/examples/simple-s3/website/index.html deleted file mode 100644 index cdc7f010..00000000 --- a/examples/simple-s3/website/index.html +++ /dev/null @@ -1,9 +0,0 @@ - - -My Simple Website - -

Shopping list

-
  • Salad
  • -
  • Eggs
  • -
  • Potatoes
  • - diff --git a/tests/examples.bats b/tests/examples.bats deleted file mode 100644 index 8f5ceb72..00000000 --- a/tests/examples.bats +++ /dev/null @@ -1,18 +0,0 @@ -setup() { - load 'helpers' - - common_setup -} - -@test "example: react" { - DAGGER_WORKSPACE="$TESTDIR"/../examples/react - export DAGGER_WORKSPACE - - "$DAGGER" up - - # curl the URL we just deployed to check if it worked - deployUrl=$("$DAGGER" query -l error -f text www.deployUrl) - run curl -sS "$deployUrl" - assert_success - assert_output --partial "Todo App" -} \ No newline at end of file From 656b01041dc263649e6709ba9210a8ff32f2ed3b Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Mon, 21 Jun 2021 13:13:18 +0000 Subject: [PATCH 13/14] Docs: 102: use new dagger.#Input in sample code Signed-off-by: Solomon Hykes --- docs/learn/102-dev.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/learn/102-dev.md b/docs/learn/102-dev.md index d0ed3d8d..42fc10f3 100644 --- a/docs/learn/102-dev.md +++ b/docs/learn/102-dev.md @@ -140,10 +140,10 @@ import ( ) // Source code of the sample application -src: dagger.#Artifact @dagger(input) +src: dagger.#Artifact & dagger.#Input ``` -This defines a component at the key `src`, of type `dagger.#Artifact`, annotated as an user input. +This defines a component at the key `src`, and specifies that it is both an artifact and an input. ### Component 2: yarn package From ec83ed50471529f7dc981ad6687dc9e29be52b0f Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Mon, 21 Jun 2021 15:26:41 +0200 Subject: [PATCH 14/14] docs: add netlify build hook Signed-off-by: Andrea Luzzardi --- .github/workflows/docs.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..11c83319 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,17 @@ +name: Docs + +on: + push: + tags: + - v* + paths: + - "docs/**" + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - run: curl -X POST "https://api.netlify.com/build_hooks/${{ secrets.DOCS_NETLIFY_BUILD_HOOK }}"