Skip to content

Commit 9b477ab

Browse files
committed
Add failing test for version constraint in a file we fail to parse
1 parent 5335987 commit 9b477ab

File tree

3 files changed

+82
-1
lines changed

3 files changed

+82
-1
lines changed

.github/workflows/test-version.yaml

+27-1
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ jobs:
888888
with:
889889
persist-credentials: false
890890

891-
- name: Test terraform-version
891+
- name: Test tofu-version
892892
uses: ./tofu-version
893893
id: tofu-version
894894
env:
@@ -907,3 +907,29 @@ jobs:
907907
echo "::error:: Terraform version not selected"
908908
exit 1
909909
fi
910+
911+
hard_parse:
912+
runs-on: ubuntu-24.04
913+
name: Get version constraint from hard to parse file
914+
steps:
915+
- name: Checkout
916+
uses: actions/checkout@v4
917+
with:
918+
persist-credentials: false
919+
920+
- name: Test terraform-version
921+
uses: ./terraform-version
922+
id: terraform-version
923+
with:
924+
path: tests/workflows/test-version/hard-parse
925+
926+
- name: Check the version
927+
env:
928+
DETECTED_TERRAFORM_VERSION: ${{ steps.tofu-version.outputs.terraform }}
929+
run: |
930+
echo "The terraform version was $DETECTED_TERRAFORM_VERSION"
931+
932+
if [[ "$DETECTED_TERRAFORM_VERSION" != "1.10.4" ]]; then
933+
echo "::error:: Terraform constraint not parsed correctly"
934+
exit 1
935+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
terraform {
2+
3+
}
4+
5+
terraform {
6+
required_version = "1.10.4"
7+
}
8+
9+
locals {
10+
cloud_run_services = [
11+
{
12+
service_name = "service-1",
13+
output_topics = [
14+
{
15+
name = "topic-1",
16+
version = "v1"
17+
}
18+
]
19+
}
20+
]
21+
}
22+
23+
24+
module "pubsub" {
25+
for_each = {
26+
for service in local.cloud_run_services : service.service_name => service
27+
}
28+
source = "./module"
29+
topics = [
30+
for entity in each.value.output_topics : {
31+
topic_name = entity.version != "" ? format("Topic-%s-%s", entity.name, entity.version) : format("Topic-%s", entity.name)
32+
subscription_name = entity.version != "" ? format("Sub-%s-%s", entity.name, entity.version) : format("Sub-%s", entity.name)
33+
}
34+
]
35+
}
36+
37+
38+
variable "not" {}
39+
40+
variable "should-be-sensitive" {
41+
sensitive=true
42+
}
43+
44+
variable "not-again" {
45+
sensitive = false
46+
}
47+
48+
variable also_sensitive {
49+
sensitive = "true"
50+
}
51+
52+
terraform {
53+
backend "s3" {}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
variable "topics" {}

0 commit comments

Comments
 (0)