From 733cac09d34317f2ed40062b91b6c0a9c5141248 Mon Sep 17 00:00:00 2001 From: Tom Chauveau Date: Fri, 10 Sep 2021 16:29:29 +0200 Subject: [PATCH] `argocd.#Sync` now retrieve status Signed-off-by: Tom Chauveau --- docs/reference/argocd.md | 40 ++++++++++++++++++++++------------ stdlib/argocd/sync.cue | 7 +++++- stdlib/argocd/tests/argocd.cue | 1 + stdlib/universe.bats | 5 +++++ 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/docs/reference/argocd.md b/docs/reference/argocd.md index 8c819934..c29bb096 100644 --- a/docs/reference/argocd.md +++ b/docs/reference/argocd.md @@ -106,20 +106,32 @@ Sync an application to its targer state ### argocd.#Sync Inputs -| Name | Type | Description | -| ------------- |:-------------: |:-------------: | -|*config.version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version | -|*config.server* | `string` |ArgoCD server | -|*config.project* | `*"default" \| string` |ArgoCD project | -|*config.token* | `dagger.#Secret` |ArgoCD authentication token | -|*application* | `string` |ArgoCD application | -|*image.config.version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version | -|*image.config.server* | `string` |ArgoCD server | -|*image.config.project* | `*"default" \| string` |ArgoCD project | -|*image.config.token* | `dagger.#Secret` |ArgoCD authentication token | -|*wait* | `*false \| bool` |Wait the application to sync correctly | -|*env.APPLICATION* | `string` |- | +| Name | Type | Description | +| ------------- |:-------------: |:-------------: | +|*config.version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version | +|*config.server* | `string` |ArgoCD server | +|*config.project* | `*"default" \| string` |ArgoCD project | +|*config.token* | `dagger.#Secret` |ArgoCD authentication token | +|*application* | `string` |ArgoCD application | +|*wait* | `*false \| bool` |Wait the application to sync correctly | +|*ctr.image.config.version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version | +|*ctr.image.config.server* | `string` |ArgoCD server | +|*ctr.image.config.project* | `*"default" \| string` |ArgoCD project | +|*ctr.image.config.token* | `dagger.#Secret` |ArgoCD authentication token | +|*ctr.env.APPLICATION* | `string` |- | +|*status.config.version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version | +|*status.config.server* | `string` |ArgoCD server | +|*status.config.project* | `*"default" \| string` |ArgoCD project | +|*status.config.token* | `dagger.#Secret` |ArgoCD authentication token | +|*status.name* | `string` |ArgoCD application | ### argocd.#Sync Outputs -_No output._ +| Name | Type | Description | +| ------------- |:-------------: |:-------------: | +|*status.outputs.health* | `string` |Application health | +|*status.outputs.sync* | `string` |Application sync state | +|*status.outputs.namespace* | `string` |Namespace | +|*status.outputs.server* | `string` |Server | +|*status.outputs.urls* | `string` |Comma separated list of application URLs | +|*status.outputs.state* | `string` |Last operation state message | diff --git a/stdlib/argocd/sync.cue b/stdlib/argocd/sync.cue index 69a75bcf..718aada4 100644 --- a/stdlib/argocd/sync.cue +++ b/stdlib/argocd/sync.cue @@ -16,7 +16,7 @@ import ( // Wait the application to sync correctly wait: dagger.#Input & {*false | bool} - os.#Container & { + ctr: os.#Container & { image: #CLI & { "config": config } @@ -33,4 +33,9 @@ import ( env: WAIT_FLAG: "wait" } } + + status: #Status & { + config: ctr.image.config + name: application + } } diff --git a/stdlib/argocd/tests/argocd.cue b/stdlib/argocd/tests/argocd.cue index b172cd5f..bfd1d71e 100644 --- a/stdlib/argocd/tests/argocd.cue +++ b/stdlib/argocd/tests/argocd.cue @@ -34,4 +34,5 @@ TestApp: #App & { TestArgoCDStatus: #Sync & { config: TestApp.config application: TestApp.name + wait: true } diff --git a/stdlib/universe.bats b/stdlib/universe.bats index ad751934..dafd0f54 100644 --- a/stdlib/universe.bats +++ b/stdlib/universe.bats @@ -237,4 +237,9 @@ setup() { # Kill Pid pgrep kubectl && pkill kubectl + + # Check output + run dagger -e argocd query TestArgoCDStatus.status.outputs.health -f json + assert_success + assert_output "\"Healthy\"" }