stdlib: argocd app support
Signed-off-by: Kevin Poirot <kevin@vazee.fr>
This commit is contained in:
parent
f29de14a2f
commit
f8f39ca75b
@ -1,6 +1,8 @@
|
|||||||
# Index
|
# Index
|
||||||
|
|
||||||
- [alpine](./alpine.md) - Base package for Alpine Linux
|
- [alpine](./alpine.md) - Base package for Alpine Linux
|
||||||
|
- [argocd](./argocd/README.md) - ArgoCD client operations
|
||||||
|
- [argocd/app](./argocd/app.md) - ArgoCD applications
|
||||||
- [aws](./aws/README.md) - AWS base package
|
- [aws](./aws/README.md) - AWS base package
|
||||||
- [aws/cloudformation](./aws/cloudformation.md) - AWS CloudFormation
|
- [aws/cloudformation](./aws/cloudformation.md) - AWS CloudFormation
|
||||||
- [aws/ecr](./aws/ecr.md) - Amazon Elastic Container Registry (ECR)
|
- [aws/ecr](./aws/ecr.md) - Amazon Elastic Container Registry (ECR)
|
||||||
|
45
docs/reference/argocd/README.md
Normal file
45
docs/reference/argocd/README.md
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: argocd
|
||||||
|
---
|
||||||
|
|
||||||
|
# alpha.dagger.io/argocd
|
||||||
|
|
||||||
|
ArgoCD client operations
|
||||||
|
|
||||||
|
```cue
|
||||||
|
import "alpha.dagger.io/argocd"
|
||||||
|
```
|
||||||
|
|
||||||
|
## argocd.#CLI
|
||||||
|
|
||||||
|
Re-usable CLI component
|
||||||
|
|
||||||
|
### argocd.#CLI 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 |
|
||||||
|
|
||||||
|
### argocd.#CLI Outputs
|
||||||
|
|
||||||
|
_No output._
|
||||||
|
|
||||||
|
## argocd.#Config
|
||||||
|
|
||||||
|
ArgoCD configuration
|
||||||
|
|
||||||
|
### argocd.#Config Inputs
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ------------- |:-------------: |:-------------: |
|
||||||
|
|*version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version |
|
||||||
|
|*server* | `string` |ArgoCD server |
|
||||||
|
|*project* | `*"default" \| string` |ArgoCD project |
|
||||||
|
|*token* | `dagger.#Secret` |ArgoCD authentication token |
|
||||||
|
|
||||||
|
### argocd.#Config Outputs
|
||||||
|
|
||||||
|
_No output._
|
72
docs/reference/argocd/app.md
Normal file
72
docs/reference/argocd/app.md
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
---
|
||||||
|
sidebar_label: app
|
||||||
|
---
|
||||||
|
|
||||||
|
# alpha.dagger.io/argocd/app
|
||||||
|
|
||||||
|
ArgoCD applications
|
||||||
|
|
||||||
|
```cue
|
||||||
|
import "alpha.dagger.io/argocd/app"
|
||||||
|
```
|
||||||
|
|
||||||
|
## app.#Application
|
||||||
|
|
||||||
|
Get an application
|
||||||
|
|
||||||
|
### app.#Application 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 |
|
||||||
|
|*name* | `string` |ArgoCD application |
|
||||||
|
|
||||||
|
### app.#Application Outputs
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ------------- |:-------------: |:-------------: |
|
||||||
|
|*outputs.health* | `string` |Application health |
|
||||||
|
|*outputs.sync* | `string` |Application sync state |
|
||||||
|
|*outputs.namespace* | `string` |Namespace |
|
||||||
|
|*outputs.server* | `string` |Server |
|
||||||
|
|*outputs.urls* | `string` |Comma separated list of application URLs |
|
||||||
|
|*outputs.state* | `string` |Last operation state message |
|
||||||
|
|
||||||
|
## app.#Synchronization
|
||||||
|
|
||||||
|
Sync an application to its target state
|
||||||
|
|
||||||
|
### app.#Synchronization 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 |
|
||||||
|
|
||||||
|
### app.#Synchronization Outputs
|
||||||
|
|
||||||
|
_No output._
|
||||||
|
|
||||||
|
## app.#SynchronizedApplication
|
||||||
|
|
||||||
|
Wait for an application to reach a synced and healthy state
|
||||||
|
|
||||||
|
### app.#SynchronizedApplication 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 |
|
||||||
|
|
||||||
|
### app.#SynchronizedApplication Outputs
|
||||||
|
|
||||||
|
_No output._
|
2
stdlib/.dagger/env/argocd/.gitignore
vendored
Normal file
2
stdlib/.dagger/env/argocd/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# dagger state
|
||||||
|
state/**
|
26
stdlib/.dagger/env/argocd/values.yaml
vendored
Normal file
26
stdlib/.dagger/env/argocd/values.yaml
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
plan:
|
||||||
|
package: ./argocd/tests
|
||||||
|
name: argocd
|
||||||
|
inputs:
|
||||||
|
TestConfig.argocdConfig.token:
|
||||||
|
secret: ENC[AES256_GCM,data:/iN8Xv5Gsr3E6NphR6+SyVLI2vvyWKED3b28,iv:ZZYKy3L5n4izaw/UM+2TaEFMlXCuBgewqY8LxS3ckuo=,tag:OeBGkvNSyO1wXHld6e0oVQ==,type:str]
|
||||||
|
sops:
|
||||||
|
kms: []
|
||||||
|
gcp_kms: []
|
||||||
|
azure_kv: []
|
||||||
|
hc_vault: []
|
||||||
|
age:
|
||||||
|
- recipient: age1ajcyrzr7xlhfpge6pd0zruqpggp4624hhrkslxytyvjgks5rzsrs8y95av
|
||||||
|
enc: |
|
||||||
|
-----BEGIN AGE ENCRYPTED FILE-----
|
||||||
|
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBGcGVyeENBZWl6VmZ5NEVo
|
||||||
|
QTB4QjlXeS8wRnpXOFIvU294M25ieUVZR0RjCjFMbkRQdlRqYjJZNDNubVZ3d0d6
|
||||||
|
TjNUaVJOVzBkM0pBUUswdVZLMTV1R3MKLS0tIHUzMEpjempnemsvY0dFVnZ0cThh
|
||||||
|
NFRwMyt0NUR5b1ViTlRxcnNHUTR0UXMKqpP24y8fPz5/tkx0YBGC7huylg1xIv2Q
|
||||||
|
MAjqMAk6tjZMX1va9VTTu2aaWwlZCBX6WE23gaIYuVCpbqGyp1B/WQ==
|
||||||
|
-----END AGE ENCRYPTED FILE-----
|
||||||
|
lastmodified: "2021-08-13T19:52:35Z"
|
||||||
|
mac: ENC[AES256_GCM,data:gjNL1Tkf96MSABBuvr6itPh5HjfESefMF2yPyqluR73BvcIIC1zimYmy2laAVjPzxN9JmqCmZJ9v1iQ99BKB8WJ40sHlztl1f7gCcnwiBYWuV+8YfvMYhdyZrmWNlhhIt8hHMcloNR2/DnH8hIJZVjF1dNmSyIqnMv6bM5oaQhA=,iv:ZzpW6bzbzvbrH/PKLhBFRk+D70opxdl2AnvXXium204=,tag:gMAw8d2Qg2upptV0xXeQ9w==,type:str]
|
||||||
|
pgp: []
|
||||||
|
encrypted_suffix: secret
|
||||||
|
version: 3.7.1
|
109
stdlib/argocd/app/app.cue
Normal file
109
stdlib/argocd/app/app.cue
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
// ArgoCD applications
|
||||||
|
package app
|
||||||
|
|
||||||
|
import (
|
||||||
|
"alpha.dagger.io/argocd"
|
||||||
|
"alpha.dagger.io/dagger"
|
||||||
|
"alpha.dagger.io/dagger/op"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get an application
|
||||||
|
#Application: {
|
||||||
|
config: argocd.#Config
|
||||||
|
|
||||||
|
// ArgoCD application
|
||||||
|
name: dagger.#Input & {string}
|
||||||
|
|
||||||
|
// ArgoCD CLI output
|
||||||
|
outputs: {
|
||||||
|
// Application health
|
||||||
|
health: dagger.#Output & {string}
|
||||||
|
|
||||||
|
// Application sync state
|
||||||
|
sync: dagger.#Output & {string}
|
||||||
|
|
||||||
|
// Namespace
|
||||||
|
namespace: dagger.#Output & {string}
|
||||||
|
|
||||||
|
// Server
|
||||||
|
server: dagger.#Output & {string}
|
||||||
|
|
||||||
|
// Comma separated list of application URLs
|
||||||
|
urls: dagger.#Output & {string}
|
||||||
|
|
||||||
|
// Last operation state message
|
||||||
|
state: dagger.#Output & {string}
|
||||||
|
}
|
||||||
|
|
||||||
|
outputs: #up: [
|
||||||
|
op.#Load & {
|
||||||
|
from: argocd.#CLI & {
|
||||||
|
"config": config
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
op.#Exec & {
|
||||||
|
args: ["sh", "-c",
|
||||||
|
#"""
|
||||||
|
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
|
||||||
|
},
|
||||||
|
|
||||||
|
op.#Export & {
|
||||||
|
source: "/output.json"
|
||||||
|
format: "json"
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sync an application to its target state
|
||||||
|
#Synchronization: {
|
||||||
|
config: argocd.#Config
|
||||||
|
|
||||||
|
// ArgoCD application
|
||||||
|
application: dagger.#Input & {string}
|
||||||
|
|
||||||
|
#up: [
|
||||||
|
op.#Load & {
|
||||||
|
from: argocd.#CLI & {
|
||||||
|
"config": config
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
op.#Exec & {
|
||||||
|
args: [
|
||||||
|
"sh", "-c", #"""
|
||||||
|
argocd app sync "$APPLICATION"
|
||||||
|
"""#,
|
||||||
|
]
|
||||||
|
env: APPLICATION: application
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for an application to reach a synced and healthy state
|
||||||
|
#SynchronizedApplication: {
|
||||||
|
config: argocd.#Config
|
||||||
|
|
||||||
|
// ArgoCD application
|
||||||
|
application: dagger.#Input & {string}
|
||||||
|
|
||||||
|
#up: [
|
||||||
|
op.#Load & {
|
||||||
|
from: argocd.#CLI & {
|
||||||
|
"config": config
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
op.#Exec & {
|
||||||
|
args: [
|
||||||
|
"sh", "-c", #"""
|
||||||
|
argocd app wait "$APPLICATION"
|
||||||
|
"""#,
|
||||||
|
]
|
||||||
|
env: APPLICATION: application
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
72
stdlib/argocd/argocd.cue
Normal file
72
stdlib/argocd/argocd.cue
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
// 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}
|
||||||
|
|
||||||
|
// ArgoCD authentication token
|
||||||
|
token: dagger.#Secret & dagger.#Input
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
},
|
||||||
|
|
||||||
|
// Write config file
|
||||||
|
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
|
||||||
|
"""#,
|
||||||
|
]
|
||||||
|
mount: "/run/secrets/token": secret: config.token
|
||||||
|
env: SERVER: config.server
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
33
stdlib/argocd/tests/argocd.cue
Normal file
33
stdlib/argocd/tests/argocd.cue
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package app
|
||||||
|
|
||||||
|
import (
|
||||||
|
"alpha.dagger.io/argocd"
|
||||||
|
"alpha.dagger.io/dagger"
|
||||||
|
"alpha.dagger.io/dagger/op"
|
||||||
|
)
|
||||||
|
|
||||||
|
TestConfig: argocdConfig: argocd.#Config & {
|
||||||
|
version: "v2.0.5"
|
||||||
|
server: "dagger-example-argocd-server.tld"
|
||||||
|
token: dagger.#Secret & dagger.#Input
|
||||||
|
}
|
||||||
|
|
||||||
|
TestArgocd: #up: [
|
||||||
|
// Initialize ArgoCD CLI binary
|
||||||
|
op.#Load & {
|
||||||
|
from: argocd.#CLI & {
|
||||||
|
config: TestConfig.argocdConfig
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Check the binary and its version
|
||||||
|
op.#Exec & {
|
||||||
|
args: [
|
||||||
|
"sh", "-c",
|
||||||
|
#"""
|
||||||
|
argocd version --output json | jq -e 'all(.client.Version; startswith("$VERSION"))'
|
||||||
|
"""#,
|
||||||
|
]
|
||||||
|
env: VERSION: TestConfig.argocdConfig.version
|
||||||
|
},
|
||||||
|
]
|
@ -214,3 +214,9 @@ setup() {
|
|||||||
skip "Azure CI infra not implemented yet - manually tested and working"
|
skip "Azure CI infra not implemented yet - manually tested and working"
|
||||||
#dagger -e azure-storage up
|
#dagger -e azure-storage up
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@test "argocd" {
|
||||||
|
skip "ArgoCD CI secrets not yet generated"
|
||||||
|
#dagger -e argocd up
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user