Merge pull request #667 from grouville/revert_kubernetes/help_to_str

Revert kubernetes/helm packages and tests from secret to str type
This commit is contained in:
Sam Alba 2021-06-17 11:49:47 +02:00 committed by GitHub
commit 4dd7a37b07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 30 additions and 15 deletions

View File

@ -32,7 +32,7 @@ Apply Kubernetes resources
| ------------- |:-------------: |:-------------: | | ------------- |:-------------: |:-------------: |
|*namespace* | `*"default" \| string` |Kubernetes Namespace to deploy to | |*namespace* | `*"default" \| string` |Kubernetes Namespace to deploy to |
|*version* | `*"v1.19.9" \| string` |Version of kubectl client | |*version* | `*"v1.19.9" \| string` |Version of kubectl client |
|*kubeconfig* | `dagger.#Secret` |Kube config file | |*kubeconfig* | `string` |Kube config file |
### kubernetes.#Resources Outputs ### kubernetes.#Resources Outputs

View File

@ -24,7 +24,7 @@ Install a Helm chart
|*timeout* | `*"5m" \| string` |time to wait for any individual Kubernetes operation (like Jobs for hooks) | |*timeout* | `*"5m" \| string` |time to wait for any individual Kubernetes operation (like Jobs for hooks) |
|*wait* | `*true \| bool` |if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as timeout | |*wait* | `*true \| bool` |if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as timeout |
|*atomic* | `*true \| bool` |if set, installation process purges chart on fail. The wait option will be set automatically if atomic is used | |*atomic* | `*true \| bool` |if set, installation process purges chart on fail. The wait option will be set automatically if atomic is used |
|*kubeconfig* | `dagger.#Secret` |Kube config file | |*kubeconfig* | `string` |Kube config file |
|*version* | `*"3.5.2" \| string` |Helm version | |*version* | `*"3.5.2" \| string` |Helm version |
|*kubectlVersion* | `*"v1.19.9" \| string` |Kubectl version | |*kubectlVersion* | `*"v1.19.9" \| string` |Kubectl version |

View File

@ -47,7 +47,7 @@ import (
atomic: *true | bool @dagger(input) atomic: *true | bool @dagger(input)
// Kube config file // Kube config file
kubeconfig: dagger.#Secret @dagger(input) kubeconfig: string @dagger(input)
// Helm version // Helm version
version: *"3.5.2" | string @dagger(input) version: *"3.5.2" | string @dagger(input)
@ -86,6 +86,11 @@ import (
dest: "/entrypoint.sh" dest: "/entrypoint.sh"
content: #code content: #code
}, },
op.#WriteFile & {
dest: "/kubeconfig"
content: kubeconfig
mode: 0o600
},
if chart != _|_ { if chart != _|_ {
op.#WriteFile & { op.#WriteFile & {
dest: "/helm/chart" dest: "/helm/chart"
@ -125,7 +130,6 @@ import (
if chartSource != _|_ && chart == _|_ { if chartSource != _|_ && chart == _|_ {
"/helm/chart": from: chartSource "/helm/chart": from: chartSource
} }
"/kubeconfig": secret: kubeconfig
} }
}, },
] ]

View File

@ -62,7 +62,7 @@ import (
version: *"v1.19.9" | string @dagger(input) version: *"v1.19.9" | string @dagger(input)
// Kube config file // Kube config file
kubeconfig: dagger.#Secret @dagger(input) kubeconfig: string @dagger(input)
#code: #""" #code: #"""
kubectl create namespace "$KUBE_NAMESPACE" > /dev/null 2>&1 || true kubectl create namespace "$KUBE_NAMESPACE" > /dev/null 2>&1 || true
@ -77,7 +77,11 @@ import (
dest: "/entrypoint.sh" dest: "/entrypoint.sh"
content: #code content: #code
}, },
op.#WriteFile & {
dest: "/kubeconfig"
content: kubeconfig
mode: 0o600
},
if manifest != _|_ { if manifest != _|_ {
op.#WriteFile & { op.#WriteFile & {
dest: "/source" dest: "/source"
@ -101,7 +105,6 @@ import (
if manifest == _|_ { if manifest == _|_ {
mount: "/source": from: source mount: "/source": from: source
} }
mount: "/kubeconfig": secret: kubeconfig
}, },
] ]
} }

View File

@ -18,7 +18,7 @@ setup() {
"$DAGGER" init "$DAGGER" init
dagger_new_with_plan kubernetes "$TESTDIR"/stdlib/kubernetes/ dagger_new_with_plan kubernetes "$TESTDIR"/stdlib/kubernetes/
run "$DAGGER" input -e "kubernetes" secret kubeconfig -f ~/.kube/config run "$DAGGER" input -e "kubernetes" text kubeconfig -f ~/.kube/config
assert_success assert_success
run "$DAGGER" up -e "kubernetes" run "$DAGGER" up -e "kubernetes"
@ -40,7 +40,7 @@ setup() {
"$DAGGER" init "$DAGGER" init
dagger_new_with_plan helm "$TESTDIR"/stdlib/kubernetes/helm dagger_new_with_plan helm "$TESTDIR"/stdlib/kubernetes/helm
run "$DAGGER" input -e "helm" secret kubeconfig -f ~/.kube/config run "$DAGGER" input -e "helm" text kubeconfig -f ~/.kube/config
assert_success assert_success
cp -R "$TESTDIR"/stdlib/kubernetes/helm/testdata/mychart "$DAGGER_WORKSPACE"/testdata cp -R "$TESTDIR"/stdlib/kubernetes/helm/testdata/mychart "$DAGGER_WORKSPACE"/testdata

View File

@ -8,7 +8,7 @@ import (
// We assume that a kinD cluster is running locally // 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/ // To deploy a local KinD cluster, follow this link : https://kind.sigs.k8s.io/docs/user/quick-start/
kubeconfig: dagger.#Secret @dagger(input) kubeconfig: string @dagger(input)
// Deploy user local chart // Deploy user local chart
TestHelmSimpleChart: { TestHelmSimpleChart: {

View File

@ -26,6 +26,12 @@ import (
content: #getHelmPods content: #getHelmPods
}, },
op.#WriteFile & {
dest: "/kubeconfig"
content: kubeconfig
mode: 0o600
},
op.#Exec & { op.#Exec & {
always: true always: true
args: [ args: [
@ -40,7 +46,6 @@ import (
KUBECONFIG: "/kubeconfig" KUBECONFIG: "/kubeconfig"
KUBE_NAMESPACE: namespace KUBE_NAMESPACE: namespace
} }
mount: "/kubeconfig": secret: kubeconfig
}, },
] ]
} }

View File

@ -2,14 +2,13 @@ package main
import ( import (
"encoding/yaml" "encoding/yaml"
"dagger.io/dagger"
"dagger.io/kubernetes" "dagger.io/kubernetes"
"dagger.io/random" "dagger.io/random"
) )
// We assume that a kinD cluster is running locally // 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/ // To deploy a local KinD cluster, follow this link : https://kind.sigs.k8s.io/docs/user/quick-start/
kubeconfig: dagger.#Secret @dagger(input) kubeconfig: string @dagger(input)
TestKubeApply: { TestKubeApply: {
suffix: random.#String & { suffix: random.#String & {

View File

@ -27,6 +27,12 @@ import (
from: kubernetes.#Kubectl from: kubernetes.#Kubectl
}, },
op.#WriteFile & {
dest: "/kubeconfig"
content: kubeconfig
mode: 0o600
},
op.#WriteFile & { op.#WriteFile & {
dest: "/getPods.sh" dest: "/getPods.sh"
content: #GetPods content: #GetPods
@ -47,7 +53,6 @@ import (
KUBECONFIG: "/kubeconfig" KUBECONFIG: "/kubeconfig"
KUBE_NAMESPACE: namespace KUBE_NAMESPACE: namespace
} }
mount: "/kubeconfig": secret: kubeconfig
}, },
op.#WriteFile & { op.#WriteFile & {
@ -69,7 +74,6 @@ import (
KUBECONFIG: "/kubeconfig" KUBECONFIG: "/kubeconfig"
KUBE_NAMESPACE: namespace KUBE_NAMESPACE: namespace
} }
mount: "/kubeconfig": secret: kubeconfig
}, },
] ]
} }