-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate apko test to imagetest (and more) (#2706)
* migrate apko test to imagetest (and more) Signed-off-by: Jason Hall <jason@chainguard.dev> * undo main.tf Signed-off-by: Jason Hall <jason@chainguard.dev> * review comments Signed-off-by: Jason Hall <jason@chainguard.dev> --------- Signed-off-by: Jason Hall <jason@chainguard.dev>
- Loading branch information
Showing
5 changed files
with
115 additions
and
57 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
terraform { | ||
required_providers { | ||
imagetest = { source = "chainguard-dev/imagetest" } | ||
oci = { source = "chainguard-dev/oci" } | ||
} | ||
} | ||
|
||
variable "digest" { | ||
description = "The image digest to run tests over." | ||
} | ||
|
||
data "imagetest_inventory" "inventory" {} | ||
|
||
// TODO: Run a simple Docker test to verify the image is working. | ||
|
||
resource "imagetest_harness_docker" "docker" { | ||
name = "docker" | ||
inventory = data.imagetest_inventory.inventory | ||
|
||
envs = { | ||
IMAGE_NAME : var.digest | ||
} | ||
} | ||
|
||
resource "imagetest_feature" "test" { | ||
name = "docker-test" | ||
harness = imagetest_harness_docker.docker | ||
|
||
steps = [{ | ||
name = "basic test" | ||
cmd = "docker run --rm $IMAGE_NAME version" | ||
}] | ||
} | ||
|
||
// TODO: Run a simple K8s test to verify the image is working. | ||
|
||
resource "imagetest_harness_k3s" "k3s" { | ||
name = "k3s" | ||
inventory = data.imagetest_inventory.inventory | ||
|
||
sandbox = { | ||
mounts = [ | ||
{ | ||
source = path.module | ||
destination = "/tests" | ||
} | ||
] | ||
} | ||
} | ||
|
||
locals { parsed = provider::oci::parse(var.digest) } | ||
|
||
module "helm" { | ||
source = "../../../tflib/imagetest/helm" | ||
|
||
name = "TODO" | ||
chart = "TODO" | ||
|
||
values = { | ||
image = { | ||
repository = local.parsed["console"].registry_repo | ||
tag = local.parsed["console"].pseudo_tag | ||
} | ||
} | ||
} | ||
|
||
resource "imagetest_feature" "helm" { | ||
name = "helm-test" | ||
description = "Basic Helm test" | ||
harness = imagetest_harness_k3s.k3s | ||
|
||
steps = [ | ||
{ | ||
name = "Helm install" | ||
cmd = module.helm.install_cmd | ||
}, | ||
{ | ||
name = "Verify installation" | ||
cmd = <<EOF | ||
TODO: Add a test here to verify the installation. | ||
EOF | ||
} | ||
] | ||
|
||
labels = { | ||
type = "k8s" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
terraform { | ||
required_providers { | ||
oci = { source = "chainguard-dev/oci" } | ||
imagetest = { source = "chainguard-dev/imagetest" } | ||
} | ||
} | ||
|
||
variable "digest" { | ||
description = "The image digest to run tests over." | ||
} | ||
|
||
data "oci_exec_test" "version" { | ||
digest = var.digest | ||
script = "docker run --rm $IMAGE_NAME version" | ||
data "imagetest_inventory" "inventory" {} | ||
|
||
resource "imagetest_harness_docker" "docker" { | ||
name = "docker" | ||
inventory = data.imagetest_inventory.inventory | ||
|
||
envs = { | ||
IMAGE_NAME : var.digest | ||
} | ||
} | ||
|
||
resource "imagetest_feature" "test" { | ||
name = "test" | ||
harness = imagetest_harness_docker.docker | ||
|
||
steps = [{ | ||
name = "basic test" | ||
cmd = "docker run --rm $IMAGE_NAME version" | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters