From 2d72303bc4e54ec5d584021247f0e413574d5efc Mon Sep 17 00:00:00 2001 From: Tom Chauveau Date: Thu, 22 Apr 2021 17:30:40 +0200 Subject: [PATCH 1/2] Fix AWS eks kubeconfig generation Signed-off-by: Tom Chauveau --- stdlib/aws/eks/eks.cue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stdlib/aws/eks/eks.cue b/stdlib/aws/eks/eks.cue index cd94428d..529a6d0e 100644 --- a/stdlib/aws/eks/eks.cue +++ b/stdlib/aws/eks/eks.cue @@ -1,7 +1,7 @@ package eks import ( - "dagger.io/dagger" + // "dagger.io/dagger" "dagger.io/dagger/op" "dagger.io/aws" ) @@ -19,16 +19,18 @@ import ( // kubeconfig is the generated kube configuration file kubeconfig: { - dagger.#Secret + string// FIXME There is a problem with dagger.#Artifact type #up: [ op.#Load & { from: aws.#CLI }, + op.#WriteFile & { dest: "/entrypoint.sh" content: #Code }, + op.#Exec & { always: true args: [ From 9fc247848fe140d6115fb642d937fb5a3c648ba9 Mon Sep 17 00:00:00 2001 From: Tom Chauveau Date: Thu, 22 Apr 2021 17:30:58 +0200 Subject: [PATCH 2/2] Add test on AWS eks Signed-off-by: Tom Chauveau --- stdlib/aws/eks/eks.cue | 4 +-- tests/stdlib.bats | 5 ++++ tests/stdlib/aws/eks/eks.cue | 53 ++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 tests/stdlib/aws/eks/eks.cue diff --git a/stdlib/aws/eks/eks.cue b/stdlib/aws/eks/eks.cue index 529a6d0e..a56fce0d 100644 --- a/stdlib/aws/eks/eks.cue +++ b/stdlib/aws/eks/eks.cue @@ -1,7 +1,6 @@ package eks import ( - // "dagger.io/dagger" "dagger.io/dagger/op" "dagger.io/aws" ) @@ -19,7 +18,8 @@ import ( // kubeconfig is the generated kube configuration file kubeconfig: { - string// FIXME There is a problem with dagger.#Artifact type + // FIXME There is a problem with dagger.#Secret type + string #up: [ op.#Load & { diff --git a/tests/stdlib.bats b/tests/stdlib.bats index 106de816..0da60c0a 100644 --- a/tests/stdlib.bats +++ b/tests/stdlib.bats @@ -42,4 +42,9 @@ setup() { skip_unless_secrets_available "$TESTDIR"/stdlib/aws/inputs.yaml "$DAGGER" compute "$TESTDIR"/stdlib/aws/s3 --input-dir TestDirectory="$TESTDIR"/stdlib/aws/s3/testdata --input-yaml "$TESTDIR"/stdlib/aws/inputs.yaml +} +@test "stdlib: aws" { + skip_unless_secrets_available "$TESTDIR"/stdlib/aws/inputs.yaml + + "$DAGGER" compute "$TESTDIR"/stdlib/aws/eks --input-yaml "$TESTDIR"/stdlib/aws/inputs.yaml } \ No newline at end of file diff --git a/tests/stdlib/aws/eks/eks.cue b/tests/stdlib/aws/eks/eks.cue new file mode 100644 index 00000000..1bfc98a1 --- /dev/null +++ b/tests/stdlib/aws/eks/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" + }, + ] +}