Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,31 +184,31 @@ jobs:
# GKE: set cluster_node_locations
sed -i 's/cluster_node_locations = \[\]/cluster_node_locations = ["europe-west1-b", "europe-west1-c", "europe-west1-d"]/g' gke_zero_cluster.tf || true

- name: "Terraform init"
- name: "OpenTofu init"
working-directory: ./kubestack-starter-${{ matrix.starter }}
run: |
docker run --rm \
-v `pwd`:/infra \
test-image:${{ github.sha }} \
terraform init
tofu init

- name: "Terraform workspace new ops"
- name: "OpenTofu workspace new ops"
working-directory: ./kubestack-starter-${{ matrix.starter }}
run: |
docker run --rm \
-v `pwd`:/infra \
test-image:${{ github.sha }} \
terraform workspace new ops
tofu workspace new ops

- name: "Terraform validate"
- name: "OpenTofu validate"
working-directory: ./kubestack-starter-${{ matrix.starter }}
run: |
docker run --rm \
-v `pwd`:/infra \
test-image:${{ github.sha }} \
terraform validate
tofu validate

- name: "Terraform plan"
- name: "OpenTofu plan"
working-directory: ./kubestack-starter-${{ matrix.starter }}
env:
KBST_AUTH_AWS: ${{ secrets.KBST_AUTH_AWS }}
Expand All @@ -222,7 +222,7 @@ jobs:
-v `pwd`:/infra \
-v /var/run/docker.sock:/var/run/docker.sock \
test-image:${{ github.sha }} \
terraform plan --target module.aks_zero --target module.eks_zero --target module.gke_zero
tofu plan --target module.aks_zero --target module.eks_zero --target module.gke_zero

publish-image:
runs-on: ubuntu-latest
Expand Down
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ BUILD_CACHE_DIST := --cache-to type=registry,mode=max,ref=ghcr.io/kbst/terraform
BUILD_OUTPUT := --output type=registry,push=${DOCKER_PUSH}
BUILD_CACHE := --cache-to type=registry,mode=max,ref=ghcr.io/kbst/terraform-kubestack/dev:buildcache-${DOCKER_TARGET},push=${DOCKER_PUSH}
else
BUILD_PLATFORM :=
BUILD_PLATFORM :=
BUILD_OUTPUT := --output type=docker
endif

Expand Down Expand Up @@ -57,24 +57,24 @@ build:
validate: .init
docker exec \
test-container-$(GIT_SHA) \
entrypoint terraform validate
entrypoint tofu validate

test: validate
docker exec \
test-container-$(GIT_SHA) \
entrypoint terraform apply --target module.aks_zero --target module.eks_zero --target module.gke_zero --input=false --auto-approve
entrypoint tofu apply --target module.aks_zero --target module.eks_zero --target module.gke_zero --input=false --auto-approve
docker exec \
test-container-$(GIT_SHA) \
entrypoint terraform apply --target module.eks_zero_nginx --input=false --auto-approve
entrypoint tofu apply --target module.eks_zero_nginx --input=false --auto-approve
docker exec \
test-container-$(GIT_SHA) \
entrypoint terraform apply --input=false --auto-approve
entrypoint tofu apply --input=false --auto-approve

cleanup: .init
docker exec \
-ti \
test-container-$(GIT_SHA) \
entrypoint terraform destroy --input=false --auto-approve
entrypoint tofu destroy --input=false --auto-approve
$(MAKE) .stop-container

shell: .check-container
Expand Down Expand Up @@ -106,7 +106,7 @@ shell: .check-container
.init: .check-container
docker exec \
test-container-$(GIT_SHA) \
entrypoint terraform init
entrypoint tofu init
docker exec \
test-container-$(GIT_SHA) \
entrypoint terraform workspace select ops
entrypoint tofu workspace select ops
44 changes: 44 additions & 0 deletions common/configuration/tests/custom_envs.tftest.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
variables {
configuration = {
apps_production = {
apps_key1 = "from_apps_production"
apps_key2 = "from_apps_production"
}

apps_staging = {
apps_key1 = "from_apps_staging"
apps_key2 = "from_apps_staging"
}

ops = {
ops_key = "from_ops"
apps_key1 = "from_ops"
}

loc = {}
}

base_key = "apps_production"
}

run "custom_envs" {
assert {
condition = output.merged["apps_production"] == { apps_key1 = "from_apps_production", apps_key2 = "from_apps_production" }
error_message = "apps_production is unchanged"
}

assert {
condition = output.merged["apps_staging"] == { apps_key1 = "from_apps_staging", apps_key2 = "from_apps_staging" }
error_message = "apps_staging overwrites everything from apps_production"
}

assert {
condition = output.merged["ops"] == { apps_key1 = "from_ops", apps_key2 = "from_apps_production", ops_key = "from_ops" }
error_message = "ops inherits from apps_production, overwrites apps_key1 and adds ops_key"
}

assert {
condition = output.merged["loc"] == { apps_key1 = "from_apps_production", apps_key2 = "from_apps_production" }
error_message = "loc inherits everything from apps_production"
}
}
85 changes: 0 additions & 85 deletions common/configuration/tests/custom_envs/test_envs.tf

This file was deleted.

36 changes: 36 additions & 0 deletions common/configuration/tests/default_envs.tftest.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
variables {
configuration = {
apps = {
apps_key1 = "from_apps"
apps_key2 = "from_apps"
}

ops = {
ops_key = "from_ops"
apps_key1 = "from_ops"
}

loc = {
loc_key = "from_loc"
}
}

base_key = "apps"
}

run "default_envs" {
assert {
condition = output.merged["apps"] == { apps_key1 = "from_apps", apps_key2 = "from_apps" }
error_message = "apps is unchanged"
}

assert {
condition = output.merged["ops"] == { apps_key1 = "from_ops", apps_key2 = "from_apps", ops_key = "from_ops" }
error_message = "ops inherits from apps, overwrites apps_key1 and adds ops_key"
}

assert {
condition = output.merged["loc"] == { apps_key1 = "from_apps", apps_key2 = "from_apps", loc_key = "from_loc" }
error_message = "loc inherits from apps and adds loc_key"
}
}
70 changes: 0 additions & 70 deletions common/configuration/tests/default_envs/test_envs.tf

This file was deleted.

Loading
Loading