Supports both basicAuth & Token
Signed-off-by: Tom Chauveau <tom.chauveau@epitech.eu>
This commit is contained in:
parent
d34200c9f6
commit
05b165bcc8
@ -16,28 +16,26 @@ Create an ArgoCD application
|
|||||||
|
|
||||||
### argocd.#App Inputs
|
### argocd.#App Inputs
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| ------------- |:-------------: |:-------------: |
|
| ------------- |:-------------: |:-------------: |
|
||||||
|*config.version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version |
|
|*config.version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version |
|
||||||
|*config.server* | `string` |ArgoCD server |
|
|*config.server* | `string` |ArgoCD server |
|
||||||
|*config.project* | `*"default" \| string` |ArgoCD project |
|
|*config.project* | `*"default" \| string` |ArgoCD project |
|
||||||
|*config.username* | `string` |Username |
|
|*config.token* | `dagger.#Secret` |ArgoCD authentication token |
|
||||||
|*config.password* | `dagger.#Secret` |Password |
|
|*name* | `string` |App name |
|
||||||
|*name* | `string` |App name |
|
|*repo* | `string` |Repository url (git or helm) |
|
||||||
|*repo* | `string` |Repository url (git or helm) |
|
|*path* | `string` |Folder to deploy |
|
||||||
|*path* | `string` |Folder to deploy |
|
|*server* | `*"https://kubernetes.default.svc" \| string` |Destination server |
|
||||||
|*server* | `*"https://kubernetes.default.svc" \| string` |Destination server |
|
|*namespace* | `*"default" \| string` |Destination namespace |
|
||||||
|*namespace* | `*"default" \| string` |Destination namespace |
|
|*ctr.image.config.version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version |
|
||||||
|*ctr.image.config.version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version |
|
|*ctr.image.config.server* | `string` |ArgoCD server |
|
||||||
|*ctr.image.config.server* | `string` |ArgoCD server |
|
|*ctr.image.config.project* | `*"default" \| string` |ArgoCD project |
|
||||||
|*ctr.image.config.project* | `*"default" \| string` |ArgoCD project |
|
|*ctr.image.config.token* | `dagger.#Secret` |ArgoCD authentication token |
|
||||||
|*ctr.image.config.username* | `string` |Username |
|
|*ctr.env.APP_NAME* | `string` |- |
|
||||||
|*ctr.image.config.password* | `dagger.#Secret` |Password |
|
|*ctr.env.APP_REPO* | `string` |- |
|
||||||
|*ctr.env.APP_NAME* | `string` |- |
|
|*ctr.env.APP_PATH* | `string` |- |
|
||||||
|*ctr.env.APP_REPO* | `string` |- |
|
|*ctr.env.APP_SERVER* | `*"https://kubernetes.default.svc" \| string` |- |
|
||||||
|*ctr.env.APP_PATH* | `string` |- |
|
|*ctr.env.APP_NAMESPACE* | `*"default" \| string` |- |
|
||||||
|*ctr.env.APP_SERVER* | `*"https://kubernetes.default.svc" \| string` |- |
|
|
||||||
|*ctr.env.APP_NAMESPACE* | `*"default" \| string` |- |
|
|
||||||
|
|
||||||
### argocd.#App Outputs
|
### argocd.#App Outputs
|
||||||
|
|
||||||
@ -49,13 +47,12 @@ Re-usable CLI component
|
|||||||
|
|
||||||
### argocd.#CLI Inputs
|
### argocd.#CLI Inputs
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| ------------- |:-------------: |:-------------: |
|
| ------------- |:-------------: |:-------------: |
|
||||||
|*config.version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version |
|
|*config.version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version |
|
||||||
|*config.server* | `string` |ArgoCD server |
|
|*config.server* | `string` |ArgoCD server |
|
||||||
|*config.project* | `*"default" \| string` |ArgoCD project |
|
|*config.project* | `*"default" \| string` |ArgoCD project |
|
||||||
|*config.username* | `string` |Username |
|
|*config.token* | `dagger.#Secret` |ArgoCD authentication token |
|
||||||
|*config.password* | `dagger.#Secret` |Password |
|
|
||||||
|
|
||||||
### argocd.#CLI Outputs
|
### argocd.#CLI Outputs
|
||||||
|
|
||||||
@ -67,13 +64,12 @@ ArgoCD configuration
|
|||||||
|
|
||||||
### argocd.#Config Inputs
|
### argocd.#Config Inputs
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| ------------- |:-------------: |:-------------: |
|
| ------------- |:-------------: |:-------------: |
|
||||||
|*version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version |
|
|*version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version |
|
||||||
|*server* | `string` |ArgoCD server |
|
|*server* | `string` |ArgoCD server |
|
||||||
|*project* | `*"default" \| string` |ArgoCD project |
|
|*project* | `*"default" \| string` |ArgoCD project |
|
||||||
|*username* | `string` |Username |
|
|*token* | `dagger.#Secret` |ArgoCD authentication token |
|
||||||
|*password* | `dagger.#Secret` |Password |
|
|
||||||
|
|
||||||
### argocd.#Config Outputs
|
### argocd.#Config Outputs
|
||||||
|
|
||||||
@ -85,14 +81,13 @@ Get application's status
|
|||||||
|
|
||||||
### argocd.#Status Inputs
|
### argocd.#Status Inputs
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| ------------- |:-------------: |:-------------: |
|
| ------------- |:-------------: |:-------------: |
|
||||||
|*config.version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version |
|
|*config.version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version |
|
||||||
|*config.server* | `string` |ArgoCD server |
|
|*config.server* | `string` |ArgoCD server |
|
||||||
|*config.project* | `*"default" \| string` |ArgoCD project |
|
|*config.project* | `*"default" \| string` |ArgoCD project |
|
||||||
|*config.username* | `string` |Username |
|
|*config.token* | `dagger.#Secret` |ArgoCD authentication token |
|
||||||
|*config.password* | `dagger.#Secret` |Password |
|
|*name* | `string` |ArgoCD application |
|
||||||
|*name* | `string` |ArgoCD application |
|
|
||||||
|
|
||||||
### argocd.#Status Outputs
|
### argocd.#Status Outputs
|
||||||
|
|
||||||
@ -111,21 +106,19 @@ Sync an application to its targer state
|
|||||||
|
|
||||||
### argocd.#Sync Inputs
|
### argocd.#Sync Inputs
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| ------------- |:-------------: |:-------------: |
|
| ------------- |:-------------: |:-------------: |
|
||||||
|*config.version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version |
|
|*config.version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version |
|
||||||
|*config.server* | `string` |ArgoCD server |
|
|*config.server* | `string` |ArgoCD server |
|
||||||
|*config.project* | `*"default" \| string` |ArgoCD project |
|
|*config.project* | `*"default" \| string` |ArgoCD project |
|
||||||
|*config.username* | `string` |Username |
|
|*config.token* | `dagger.#Secret` |ArgoCD authentication token |
|
||||||
|*config.password* | `dagger.#Secret` |Password |
|
|*application* | `string` |ArgoCD application |
|
||||||
|*application* | `string` |ArgoCD application |
|
|*wait* | `*false \| bool` |Wait the application to sync correctly |
|
||||||
|*wait* | `*false \| bool` |Wait the application to sync correctly |
|
|*ctr.image.config.version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version |
|
||||||
|*ctr.image.config.version* | `*"v2.0.5" \| string` |ArgoCD CLI binary version |
|
|*ctr.image.config.server* | `string` |ArgoCD server |
|
||||||
|*ctr.image.config.server* | `string` |ArgoCD server |
|
|*ctr.image.config.project* | `*"default" \| string` |ArgoCD project |
|
||||||
|*ctr.image.config.project* | `*"default" \| string` |ArgoCD project |
|
|*ctr.image.config.token* | `dagger.#Secret` |ArgoCD authentication token |
|
||||||
|*ctr.image.config.username* | `string` |Username |
|
|*ctr.env.APPLICATION* | `string` |- |
|
||||||
|*ctr.image.config.password* | `dagger.#Secret` |Password |
|
|
||||||
|*ctr.env.APPLICATION* | `string` |- |
|
|
||||||
|
|
||||||
### argocd.#Sync Outputs
|
### argocd.#Sync Outputs
|
||||||
|
|
||||||
|
14
stdlib/.dagger/env/argocd/values.yaml
vendored
14
stdlib/.dagger/env/argocd/values.yaml
vendored
@ -13,14 +13,14 @@ sops:
|
|||||||
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
|
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
|
||||||
enc: |
|
enc: |
|
||||||
-----BEGIN AGE ENCRYPTED FILE-----
|
-----BEGIN AGE ENCRYPTED FILE-----
|
||||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBuV3FTdWpWRjUxSS9hcVU4
|
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBhZEhvaGFiVGVUcWZhcjVj
|
||||||
T094TC9GRkcxQThPMVI3NzVCb2d3Q2cvUFRvClVHT1J6OFRVY1ZTYWQ2eDZmWXN3
|
WmthWWRMMmFXSmRIbzNKUm9IMms0TUltcjBvClE4UHlwcHVGcjVJTHRhNUx1Lyt4
|
||||||
N1VjdC9WNnlBNzRIdFVBN0E4Zm0xUzAKLS0tIEc2VFFSYmRqYUI5VDBDRGtTK2k1
|
UHZlTlBRRnhtMmMzcmFPUGlBTXlVMncKLS0tIFpkSXU1SDUvZTR4MVgxNWxKV3V3
|
||||||
WG5JdHlKYUlnZnZlMVNIRjczSld5ek0KF0z0UqtoGcYFFeOyMwIDAY1pyKosaOii
|
LzM4MENHSVZFNVJza3FhVGkyd0R4d3cKPI6V2o1BR8WVrsAdsuuKOW9Lw32c+KUh
|
||||||
IVqsMSYfj4+vz7mRd8HoXoSiSnuc7mLJek/izsdZtYUTfD/QnTC71Q==
|
WBHXbYucWjPeogNVIZK+/iJs4Pz92fQ1awdj0H47ro3d7I3QfZoeJQ==
|
||||||
-----END AGE ENCRYPTED FILE-----
|
-----END AGE ENCRYPTED FILE-----
|
||||||
lastmodified: "2021-09-09T12:42:58Z"
|
lastmodified: "2021-09-10T09:08:35Z"
|
||||||
mac: ENC[AES256_GCM,data:CMNfY3kBAbDOkyh1s3csD7uGToV/5TubN/0z3NaG0rVOeHzgPx//PUw7jfhBe3iTCe5m7z5jpGwbI9h6+GoANrsPX887/XYvC22JLQ7vqfOqJYOrYY9YbEJnYK+GXthQB7bqn5Yh2+yiNRVk9vHJkXyhqea9/ud32kiKhG2tE3o=,iv:eT3sjgmh4NF1sS+MSsOEZbgvAiWOwep72aM2fDenG0s=,tag:HcKVlnDpn6kQxFdlKSCALg==,type:str]
|
mac: ENC[AES256_GCM,data:RhRtuEL1xqfJ8pvofq91JMKElZY4Pqvb3SY3IhVevotGBAR6UvmKBA6Nfi3VsvbjfAlbA8/Ip+ifHNhuv6iS1kcj+u5Y7E+6esMdXoXlPmry1Jpt8fWu+zeO2t2XiVGsSEw8nLhPyZfMsp0KBoec1I43NUIKQXoPMbUFMMy1rLQ=,iv:Q817XyIlU/0BgUc6tNVZ8f9cz83I/3FbF8wvqaWNtso=,tag:/Ui9/AAT4RnnwfrOw83xew==,type:str]
|
||||||
pgp: []
|
pgp: []
|
||||||
encrypted_suffix: secret
|
encrypted_suffix: secret
|
||||||
version: 3.7.1
|
version: 3.7.1
|
||||||
|
@ -18,11 +18,17 @@ import (
|
|||||||
// ArgoCD project
|
// ArgoCD project
|
||||||
project: *"default" | dagger.#Input & {string}
|
project: *"default" | dagger.#Input & {string}
|
||||||
|
|
||||||
// Username
|
// Basic authentification to login
|
||||||
username: dagger.#Input & {string}
|
basicAuth: {
|
||||||
|
// Username
|
||||||
|
username: dagger.#Input & {string}
|
||||||
|
|
||||||
// Password
|
// Password
|
||||||
password: dagger.#Input & {dagger.#Secret}
|
password: dagger.#Input & {dagger.#Secret}
|
||||||
|
} | *null
|
||||||
|
|
||||||
|
// ArgoCD authentication token
|
||||||
|
token: dagger.#Input & {*null | dagger.#Secret}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-usable CLI component
|
// Re-usable CLI component
|
||||||
@ -49,17 +55,45 @@ import (
|
|||||||
env: VERSION: config.version
|
env: VERSION: config.version
|
||||||
},
|
},
|
||||||
|
|
||||||
// Login to ArgoCD server
|
if config.basicAuth != null && config.token == null {
|
||||||
op.#Exec & {
|
// Login to ArgoCD server
|
||||||
args: ["sh", "-c", #"""
|
op.#Exec & {
|
||||||
argocd login "$ARGO_SERVER" --username "$ARGO_USERNAME" --password $(cat /run/secrets/password) --insecure
|
args: ["sh", "-c", #"""
|
||||||
"""#,
|
argocd login "$ARGO_SERVER" --username "$ARGO_USERNAME" --password $(cat /run/secrets/password) --insecure
|
||||||
]
|
"""#,
|
||||||
env: {
|
]
|
||||||
ARGO_SERVER: config.server
|
env: {
|
||||||
ARGO_USERNAME: config.username
|
ARGO_SERVER: config.server
|
||||||
|
ARGO_USERNAME: config.basicAuth.username
|
||||||
|
}
|
||||||
|
mount: "/run/secrets/password": secret: config.basicAuth.password
|
||||||
}
|
}
|
||||||
mount: "/run/secrets/password": secret: config.password
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
if config.token != null && config.basicAuth == null {
|
||||||
|
// Write config file
|
||||||
|
op.#Exec & {
|
||||||
|
args: ["sh", "-c",
|
||||||
|
#"""
|
||||||
|
mkdir -p ~/.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
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
TestConfig: argocdConfig: #Config & {
|
TestConfig: argocdConfig: #Config & {
|
||||||
version: dagger.#Input & {*"v2.0.5" | string}
|
version: dagger.#Input & {*"v2.0.5" | string}
|
||||||
server: dagger.#Input & {*"dagger-example-argocd-server.tld" | string}
|
server: dagger.#Input & {*"dagger-example-argocd-server.tld" | string}
|
||||||
username: dagger.#Input & {*"admin" | string}
|
basicAuth: {
|
||||||
password: dagger.#Input & {dagger.#Secret}
|
username: dagger.#Input & {*"admin" | string}
|
||||||
|
password: dagger.#Input & {dagger.#Secret}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TestClient: os.#Container & {
|
TestClient: os.#Container & {
|
||||||
@ -19,7 +21,7 @@ TestClient: os.#Container & {
|
|||||||
command: #"""
|
command: #"""
|
||||||
argocd account list | grep "$ARGOCD_USERNAME"
|
argocd account list | grep "$ARGOCD_USERNAME"
|
||||||
"""#
|
"""#
|
||||||
env: ARGOCD_USERNAME: TestConfig.argocdConfig.username
|
env: ARGOCD_USERNAME: TestConfig.argocdConfig.basicAuth.username
|
||||||
}
|
}
|
||||||
|
|
||||||
TestApp: #App & {
|
TestApp: #App & {
|
||||||
|
@ -223,15 +223,15 @@ setup() {
|
|||||||
dagger -e argocd-infra up
|
dagger -e argocd-infra up
|
||||||
|
|
||||||
# Forward port
|
# Forward port
|
||||||
|
# We need to kill subprocess to avoid infinity loop
|
||||||
kubectl port-forward svc/argocd-server -n argocd 8080:443 >/dev/null 2>/dev/null &
|
kubectl port-forward svc/argocd-server -n argocd 8080:443 >/dev/null 2>/dev/null &
|
||||||
sleep 3
|
sleep 3 || (pkill kubectl && exit 1)
|
||||||
|
|
||||||
# Run test
|
# Run test
|
||||||
dagger -e argocd input secret TestConfig.argocdConfig.password "$(kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d)"
|
dagger -e argocd input secret TestConfig.argocdConfig.basicAuth.password "$(kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d)" || (pkill kubectl && exit 1)
|
||||||
dagger -e up
|
dagger -e argocd up || (pkill kubectl && exit 1)
|
||||||
dagger -e argocd input unset TestConfig.argocdConfig.password
|
dagger -e argocd input unset TestConfig.argocdConfig.basicAuth.password || (pkill kubectl && exit 1)
|
||||||
|
|
||||||
# Kill Pid
|
# Kill Pid
|
||||||
pkill kubectl
|
pgrep kubectl && pkill kubectl
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user