Skip to content

Commit

Permalink
WIP: use OCI functions instead of datasources (#2632)
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Hall <[email protected]>
  • Loading branch information
imjasonh authored May 15, 2024
1 parent 6389cd5 commit b405203
Show file tree
Hide file tree
Showing 180 changed files with 823 additions and 1,015 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/presubmit-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:

- uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3
with:
terraform_version: '1.6.*'
terraform_version: '1.8.*'
terraform_wrapper: false
# Make cosign/crane CLI available to the tests
- uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3.5.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:

- uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v3
with:
terraform_version: "1.6.*"
terraform_version: '1.8.*'
terraform_wrapper: false

- uses: chainguard-dev/actions/setup-chainctl@538d1927b846546b620784754c33e2a1db86e217 # main
Expand Down
18 changes: 10 additions & 8 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 10 additions & 13 deletions images/argo/tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ variable "digests" {
})
}

data "oci_string" "ref" {
for_each = var.digests
input = each.value
}
locals { parsed = { for k, v in var.digests : k => provider::oci::parse(v) } }

data "imagetest_inventory" "this" {}

Expand Down Expand Up @@ -49,23 +46,23 @@ module "helm" {
}
server = {
image = {
registry = join("", [data.oci_string.ref["cli"].registry, ""])
repository = data.oci_string.ref["cli"].repo
tag = data.oci_string.ref["cli"].pseudo_tag
registry = join("", [local.parsed["cli"].registry, ""])
repository = local.parsed["cli"].repo
tag = local.parsed["cli"].pseudo_tag

}
executor = {
image = {
registry = join("", [data.oci_string.ref["exec"].registry, ""])
repository = data.oci_string.ref["exec"].repo
tag = data.oci_string.ref["exec"].pseudo_tag
registry = join("", [local.parsed["exec"].registry, ""])
repository = local.parsed["exec"].repo
tag = local.parsed["exec"].pseudo_tag
}
}
controller = {
image = {
registry = join("", [data.oci_string.ref["worfkflowcontroller"].registry, ""])
repository = data.oci_string.ref["worfkflowcontroller"].repo
tag = data.oci_string.ref["worfkflowcontroller"].pseudo_tag
registry = join("", [local.parsed["worfkflowcontroller"].registry, ""])
repository = local.parsed["worfkflowcontroller"].repo
tag = local.parsed["worfkflowcontroller"].pseudo_tag
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions images/argocd-extension-installer/tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ variable "digest" {
description = "The image digests to run tests over."
}

data "oci_string" "ref" {
input = var.digest
}
locals { parsed = provider::oci::parse(var.digest) }

data "oci_exec_test" "smoke" {
digest = var.digest
Expand Down
13 changes: 5 additions & 8 deletions images/argocd/tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ variable "name" {
default = "argocd"
}

data "oci_string" "ref" {
for_each = var.digests
input = each.value
}
locals { parsed = { for k, v in var.digests : k => provider::oci::parse(v) } }

data "imagetest_inventory" "this" {}

Expand All @@ -42,13 +39,13 @@ module "install" {
}
}
image = {
tag = data.oci_string.ref["server"].pseudo_tag
repository = data.oci_string.ref["server"].registry_repo
tag = local.parsed["server"].pseudo_tag
repository = local.parsed["server"].registry_repo
}
repoServer = {
image = {
tag = data.oci_string.ref["repo-server"].pseudo_tag
repository = data.oci_string.ref["repo-server"].registry_repo
tag = local.parsed["repo-server"].pseudo_tag
repository = local.parsed["repo-server"].registry_repo
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions images/atlantis/tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ variable "digest" {
description = "The image digest to run tests over."
}

data "oci_string" "ref" { input = var.digest }
locals { parsed = provider::oci::parse(var.digest) }

data "oci_exec_test" "version" {
digest = var.digest
Expand All @@ -36,8 +36,8 @@ module "helm" {

values = {
image = {
repository = data.oci_string.ref.registry_repo
tag = data.oci_string.ref.pseudo_tag
repository = local.parsed.registry_repo
tag = local.parsed.pseudo_tag
pullPolicy = "Always"
}
github = {
Expand Down
6 changes: 3 additions & 3 deletions images/aws-for-fluent-bit/tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ variable "digest" {
description = "The image digest to run tests over."
}

data "oci_string" "ref" { input = var.digest }
locals { parsed = provider::oci::parse(var.digest) }

data "oci_exec_test" "startup" {
digest = var.digest
Expand All @@ -34,8 +34,8 @@ module "helm" {

values = {
image = {
repository = data.oci_string.ref.registry_repo
tag = data.oci_string.ref.pseudo_tag
repository = local.parsed.registry_repo
tag = local.parsed.pseudo_tag
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions images/aws-load-balancer-controller/tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ variable "chart_version" {
default = "latest"
}

data "oci_string" "ref" { input = var.digest }
locals { parsed = provider::oci::parse(var.digest) }

data "imagetest_inventory" "this" {}

Expand All @@ -34,8 +34,8 @@ module "helm" {

values = {
image = {
tag = data.oci_string.ref.pseudo_tag
repository = data.oci_string.ref.registry_repo
tag = local.parsed.pseudo_tag
repository = local.parsed.registry_repo
}
clusterName = "k3d-k3s-default"
serviceAccount = {
Expand Down
6 changes: 3 additions & 3 deletions images/bank-vaults/tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ variable "digest" {
description = "The image digest to run tests over."
}

data "oci_string" "ref" { input = var.digest }
locals { parsed = provider::oci::parse(var.digest) }

data "imagetest_inventory" "this" {}

Expand All @@ -36,8 +36,8 @@ module "helm" {
values = {
bankVaults = {
image = {
repository = data.oci_string.ref.registry_repo
tag = data.oci_string.ref.pseudo_tag
repository = local.parsed.registry_repo
tag = local.parsed.pseudo_tag
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions images/cadvisor/tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ variable "digest" {
description = "The image digest to run tests over."
}

data "oci_string" "ref" { input = var.digest }
locals { parsed = provider::oci::parse(var.digest) }

data "imagetest_inventory" "this" {}

Expand All @@ -26,9 +26,9 @@ resource "imagetest_harness_k3s" "this" {
]
envs = {
"NAMESPACE" = "cadvisor"
"IMAGE_REGISTRY" = data.oci_string.ref.registry
"IMAGE_REPOSITORY" = data.oci_string.ref.repo
"IMAGE_TAG" = data.oci_string.ref.pseudo_tag
"IMAGE_REGISTRY" = local.parsed.registry
"IMAGE_REPOSITORY" = local.parsed.repo
"IMAGE_TAG" = local.parsed.pseudo_tag
}
}
}
Expand Down
16 changes: 6 additions & 10 deletions images/calico/kind-tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ variable "refs" {
}
}

data "oci_ref" "refs" {
for_each = var.refs

ref = each.value
}
locals { fetched = { for k, v in var.refs : k => provider::oci::get(v) } }

data "kubectl_file_documents" "docs" {
for_each = toset([
Expand All @@ -38,11 +34,11 @@ data "kubectl_file_documents" "docs" {
])

content = templatefile("${path.module}/manifests/${each.value}.yaml.tpl", {
CNI_IMAGE = data.oci_ref.refs["cni"].ref
NODE_IMAGE = data.oci_ref.refs["node"].ref
KUBE_CONTROLLERS_IMAGE = data.oci_ref.refs["kube_controllers"].ref
TYPHA_IMAGE = data.oci_ref.refs["typha"].ref
CSI_IMAGE = data.oci_ref.refs["csi"].ref
CNI_IMAGE = local.fetched["cni"].full_ref
NODE_IMAGE = local.fetched["node"].full_ref
KUBE_CONTROLLERS_IMAGE = local.fetched["kube_controllers"].full_ref
TYPHA_IMAGE = local.fetched["typha"].full_ref
CSI_IMAGE = local.fetched["csi"].full_ref
})
}

Expand Down
23 changes: 10 additions & 13 deletions images/calico/tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ variable "digests" {
})
}

data "oci_string" "image" {
for_each = var.digests
input = each.value
}
locals { parsed = { for k, v in var.digests : k => provider::oci::parse(v) } }

data "imagetest_inventory" "this" {}

Expand Down Expand Up @@ -64,19 +61,19 @@ metadata:
spec:
images:
- image: calico/node
digest: ${data.oci_string.image["node"].digest}
digest: ${local.parsed["node"].digest}
- image: calico/cni
digest: ${data.oci_string.image["cni"].digest}
digest: ${local.parsed["cni"].digest}
- image: calico/kube-controllers
digest: ${data.oci_string.image["kube-controllers"].digest}
digest: ${local.parsed["kube-controllers"].digest}
- image: calico/pod2daemon-flexvol
digest: ${data.oci_string.image["pod2daemon"].digest}
digest: ${local.parsed["pod2daemon"].digest}
- image: calico/csi
digest: ${data.oci_string.image["csi"].digest}
digest: ${local.parsed["csi"].digest}
- image: calico/typha
digest: ${data.oci_string.image["typha"].digest}
digest: ${local.parsed["typha"].digest}
- image: calico/node-driver-registrar
digest: ${data.oci_string.image["node-driver-registrar"].digest}
digest: ${local.parsed["node-driver-registrar"].digest}
EOm
kubectl apply -f - <<EOm
Expand All @@ -86,8 +83,8 @@ metadata:
name: default
spec:
variant: Calico
registry: ${data.oci_string.image["node"].registry}
imagePath: ${split("/", data.oci_string.image["node"].repo)[0]}
registry: ${local.parsed["node"].registry}
imagePath: ${split("/", local.parsed["node"].repo)[0]}
imagePrefix: calico-
EOm
Expand Down
4 changes: 2 additions & 2 deletions images/cass-config-builder/tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ variable "digest" {
description = "The image digest to run tests over."
}

data "oci_string" "ref" { input = var.digest }
locals { parsed = provider::oci::parse(var.digest) }

data "imagetest_inventory" "this" {}

Expand All @@ -25,7 +25,7 @@ resource "imagetest_harness_k3s" "this" {
}
]
envs = {
"IMAGE_NAME" = data.oci_string.ref.id
"IMAGE_NAME" = var.digest
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions images/cass-operator/tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ variable "digest" {
description = "The image digest to run tests over."
}

data "oci_string" "ref" { input = var.digest }
locals { parsed = provider::oci::parse(var.digest) }

data "imagetest_inventory" "this" {}

Expand All @@ -25,9 +25,9 @@ resource "imagetest_harness_k3s" "this" {
}
]
envs = {
"IMAGE_REGISTRY" = data.oci_string.ref.registry
"IMAGE_REPOSITORY" = data.oci_string.ref.repo
"IMAGE_TAG" = data.oci_string.ref.pseudo_tag
"IMAGE_REGISTRY" = local.parsed.registry
"IMAGE_REPOSITORY" = local.parsed.repo
"IMAGE_TAG" = local.parsed.pseudo_tag
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions images/cassandra-medusa/tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ variable "digest" {

resource "random_pet" "suffix" {}

data "oci_string" "ref" { input = var.digest }
locals { parsed = provider::oci::parse(var.digest) }

data "imagetest_inventory" "this" {}

Expand All @@ -28,11 +28,11 @@ resource "imagetest_harness_k3s" "this" {
]
envs = {
"NAMESPACE" = "k8s-medusa-${random_pet.suffix.id}"
"IMAGE_REGISTRY" = data.oci_string.ref.registry
"IMAGE_REPOSITORY" = split("/", data.oci_string.ref.repo)[0]
"NAME" = split("/", data.oci_string.ref.repo)[1]
"IMAGE_REGISTRY" = local.parsed.registry
"IMAGE_REPOSITORY" = split("/", local.parsed.repo)[0]
"NAME" = split("/", local.parsed.repo)[1]
"K8SSANDRA_CLUSTER_NAME" = "foo-${random_pet.suffix.id}"
"IMAGE_TAG" = data.oci_string.ref.pseudo_tag
"IMAGE_TAG" = local.parsed.pseudo_tag
}
}
}
Expand Down
Loading

0 comments on commit b405203

Please sign in to comment.