Improve ArgoCD and fix CI
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
@@ -25,8 +25,8 @@ import (
|
||||
// Destination namespace
|
||||
namespace: dagger.#Input & {*"default" | string}
|
||||
|
||||
_ctr: os.Container & {
|
||||
from: #CLI & {
|
||||
ctr: os.#Container & {
|
||||
image: #CLI & {
|
||||
"config": config
|
||||
}
|
||||
command: #"""
|
||||
|
@@ -18,8 +18,11 @@ import (
|
||||
// ArgoCD project
|
||||
project: *"default" | dagger.#Input & {string}
|
||||
|
||||
// ArgoCD authentication token
|
||||
token: dagger.#Secret & dagger.#Input
|
||||
// Username
|
||||
username: dagger.#Input & {string}
|
||||
|
||||
// Password
|
||||
password: dagger.#Input & {dagger.#Secret}
|
||||
}
|
||||
|
||||
// Re-usable CLI component
|
||||
@@ -46,27 +49,17 @@ import (
|
||||
env: VERSION: config.version
|
||||
},
|
||||
|
||||
// Write config file
|
||||
// Login to ArgoCD server
|
||||
op.#Exec & {
|
||||
args: ["sh", "-c",
|
||||
#"""
|
||||
mkdir ~/.argocd && cat > ~/.argocd/config << EOF
|
||||
contexts:
|
||||
- name: "$SERVER"
|
||||
server: "$SERVER"
|
||||
user: "$SERVER"
|
||||
current-context: "$SERVER"
|
||||
servers:
|
||||
- grpc-web-root-path: ""
|
||||
server: "$SERVER"
|
||||
users:
|
||||
- auth-token: $(cat /run/secrets/token)
|
||||
name: "$SERVER"
|
||||
EOF
|
||||
"""#,
|
||||
args: ["sh", "-c", #"""
|
||||
argocd login "$ARGO_SERVER" --username "$ARGO_USERNAME" --password $(cat /run/secrets/password) --insecure
|
||||
"""#,
|
||||
]
|
||||
mount: "/run/secrets/token": secret: config.token
|
||||
env: SERVER: config.server
|
||||
env: {
|
||||
ARGO_SERVER: config.server
|
||||
ARGO_USERNAME: config.username
|
||||
}
|
||||
mount: "/run/secrets/password": secret: config.password
|
||||
},
|
||||
]
|
||||
}
|
||||
|
@@ -44,14 +44,12 @@ import (
|
||||
op.#Exec & {
|
||||
args: ["sh", "-c",
|
||||
#"""
|
||||
ls ~/.argocd
|
||||
cat ~/.argocd/config
|
||||
// FIXME JQ failed
|
||||
argocd app get "$APPLICATION" --output json | jq '{health:.status.health.status,sync:.status.sync.status,namespace:.spec.destination.namespace,server:.spec.destination.server,urls:.status.summary.externalURLs|join(","),state:.status.operationState.message}' > /output.json
|
||||
"""#,
|
||||
]
|
||||
env: {
|
||||
APPLICATION: name
|
||||
ARGOCD_OPTS: "--port-forward-namespace argocd"
|
||||
}
|
||||
},
|
||||
|
||||
|
@@ -16,7 +16,7 @@ import (
|
||||
// Wait the application to sync correctly
|
||||
wait: dagger.#Input & {*false | bool}
|
||||
|
||||
_ctr: os.#Container & {
|
||||
ctr: os.#Container & {
|
||||
image: #CLI & {
|
||||
"config": config
|
||||
}
|
||||
|
@@ -6,23 +6,30 @@ import (
|
||||
)
|
||||
|
||||
TestConfig: argocdConfig: #Config & {
|
||||
version: dagger.#Input & {*"v2.0.5" | string}
|
||||
server: dagger.#Input & {*"dagger-example-argocd-server.tld" | string}
|
||||
token: dagger.#Input & {dagger.#Secret}
|
||||
version: dagger.#Input & {*"v2.0.5" | string}
|
||||
server: dagger.#Input & {*"dagger-example-argocd-server.tld" | string}
|
||||
username: dagger.#Input & {*"admin" | string}
|
||||
password: dagger.#Input & {dagger.#Secret}
|
||||
}
|
||||
|
||||
TestArgoCD: os.#Container & {
|
||||
TestClient: os.#Container & {
|
||||
image: #CLI & {
|
||||
config: TestConfig.argocdConfig
|
||||
}
|
||||
always: true
|
||||
command: #"""
|
||||
argocd version --output json | jq -e 'all(.client.Version; startswith("$VERSION"))'
|
||||
argocd account list | grep "$ARGOCD_USERNAME"
|
||||
"""#
|
||||
env: VERSION: TestConfig.argocdConfig.version
|
||||
env: ARGOCD_USERNAME: TestConfig.argocdConfig.username
|
||||
}
|
||||
|
||||
TestArgoCDStatus: #Status & {
|
||||
TestApp: #App & {
|
||||
config: TestConfig.argocdConfig
|
||||
name: "test"
|
||||
name: "daggerci-test"
|
||||
repo: "https://github.com/argoproj/argocd-example-apps.git"
|
||||
path: "guestbook"
|
||||
}
|
||||
|
||||
TestArgoCDStatus: #Sync & {
|
||||
config: TestApp.config
|
||||
application: TestApp.name
|
||||
}
|
||||
|
Reference in New Issue
Block a user