This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/stdlib/argocd/argocd.cue
Tom Chauveau 0fe8b14e78 Improve ArgoCD and fix CI
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
2021-09-10 09:10:21 -07:00

66 lines
1.3 KiB
CUE

// ArgoCD client operations
package argocd
import (
"alpha.dagger.io/alpine"
"alpha.dagger.io/dagger"
"alpha.dagger.io/dagger/op"
)
// ArgoCD configuration
#Config: {
// ArgoCD CLI binary version
version: *"v2.0.5" | dagger.#Input & {string}
// ArgoCD server
server: dagger.#Input & {string}
// ArgoCD project
project: *"default" | dagger.#Input & {string}
// Username
username: dagger.#Input & {string}
// Password
password: dagger.#Input & {dagger.#Secret}
}
// Re-usable CLI component
#CLI: {
config: #Config
#up: [
op.#Load & {
from: alpine.#Image & {
package: bash: "=~5.1"
package: jq: "=~1.6"
package: curl: true
}
},
// Install the ArgoCD CLI
op.#Exec & {
args: ["sh", "-c",
#"""
curl -sSL -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/download/$VERSION/argocd-linux-amd64 &&
chmod +x /usr/local/bin/argocd
"""#,
]
env: VERSION: config.version
},
// Login to ArgoCD server
op.#Exec & {
args: ["sh", "-c", #"""
argocd login "$ARGO_SERVER" --username "$ARGO_USERNAME" --password $(cat /run/secrets/password) --insecure
"""#,
]
env: {
ARGO_SERVER: config.server
ARGO_USERNAME: config.username
}
mount: "/run/secrets/password": secret: config.password
},
]
}