Skip to content

Commit

Permalink
migrate argocd to imagetest (#2372)
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Wolf <josh@wolfs.io>
  • Loading branch information
joshrwolf committed Mar 19, 2024
1 parent d96f59b commit 3d600a9
Showing 1 changed file with 59 additions and 48 deletions.
107 changes: 59 additions & 48 deletions images/argocd/tests/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
oci = { source = "chainguard-dev/oci" }
helm = { source = "hashicorp/helm" }
oci = { source = "chainguard-dev/oci" }
imagetest = { source = "chainguard-dev/imagetest" }
}
}

Expand All @@ -18,57 +18,68 @@ data "oci_string" "ref" {
input = each.value
}

resource "helm_release" "argocd" {
name = "argocd"
data "imagetest_inventory" "this" {}

repository = "https://argoproj.github.io/argo-helm"
chart = "argo-cd"
resource "imagetest_harness_k3s" "this" {
name = "cert-manager"
inventory = data.imagetest_inventory.this
}

namespace = "argocd"
create_namespace = true
module "install" {
source = "../../../tflib/imagetest/helm"

# The argocd helm chart installs CRDs from the `templates/` directory,
# and the default value (`false`) conflicts with the providers
# assumption of them being in `crds/`
skip_crds = true
chart = "argo-cd"
namespace = "argocd"
repo = "https://argoproj.github.io/argo-helm"

values = [
jsonencode({
image = {
tag = data.oci_string.ref["server"].pseudo_tag
repository = data.oci_string.ref["server"].registry_repo
values = {
config = {
params = {
}
repoServer = {
image = {
tag = data.oci_string.ref["repo-server"].pseudo_tag
repository = data.oci_string.ref["repo-server"].registry_repo
}
}
image = {
tag = data.oci_string.ref["server"].pseudo_tag
repository = data.oci_string.ref["server"].registry_repo
}
repoServer = {
image = {
tag = data.oci_string.ref["repo-server"].pseudo_tag
repository = data.oci_string.ref["repo-server"].registry_repo
}
# redis-ha = {
# enabled = true
# # image = {
# # repository = "cgr.dev/chainguard/redis"
# # tag = "latest"
# # }
# haproxy = {
# image = {
# repository = "k3d-k3d.localhost:5005/cg/haproxy"
# tag = "2.8@sha256:d9a67188af5cb89f5398399f704e75079a25e241481d22205de38637bd9052c0"
# }
#
# containerSecurityContext = {
# capabilities = {
# add = ["NET_BIND_SERVICE"]
# }
# }
# }
# }
}),
]
}
}
}

# module "helm_cleanup" {
# source = "../../../tflib/helm-cleanup"
# name = helm_release.argocd.id
# namespace = helm_release.argocd.namespace
# }
resource "imagetest_feature" "basic" {
harness = imagetest_harness_k3s.this
name = "Basic"
description = "Basic functionality of the argocd helm chart."

steps = [
{
name = "Helm install"
cmd = module.install.install_cmd
},
{
name = "Deploy the guestbook"
cmd = <<EOF
apk add argo-cd
args="--port-forward --port-forward-namespace=argocd"
password=$(kubectl get secrets -n argocd argocd-initial-admin-secret -ojsonpath='{.data.password}' | base64 -d -)
argocd login $args --password $password --username admin
argocd app create guestbook $args \
--repo https://github.com/argoproj/argocd-example-apps.git \
--path guestbook \
--dest-server https://kubernetes.default.svc \
--dest-namespace default
argocd app sync guestbook $args --timeout "120"
argocd app wait guestbook $args --timeout "120"
EOF
},
]

labels = {
type = "k8s"
}
}

0 comments on commit 3d600a9

Please sign in to comment.