Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to integrated Terraform variable validation #4

Merged
merged 29 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f52ceb6
Implement testing
KyleKotowick Mar 18, 2023
4b33701
Update CICD.yml
KyleKotowick Mar 18, 2023
4de4243
Update CICD.yml
KyleKotowick Mar 26, 2023
37b908d
Update CICD.yml
KyleKotowick Mar 26, 2023
19304ac
Update CICD.yml
KyleKotowick Mar 26, 2023
7acac4d
Update CICD.yml
KyleKotowick Mar 26, 2023
5d2c673
Testing
KyleKotowick Mar 26, 2023
24846b4
Update CICD.yml
KyleKotowick Mar 26, 2023
a8c60f9
Update CICD.yml
KyleKotowick Mar 26, 2023
e584f10
Update CICD.yml
KyleKotowick Mar 26, 2023
e984e92
Update CICD.yml
KyleKotowick Mar 26, 2023
fd465e2
Update main.tf
KyleKotowick Mar 26, 2023
f23f1a6
Update CICD.yml
KyleKotowick Mar 26, 2023
5a0a77f
Update CICD
KyleKotowick Mar 26, 2023
100de72
Update CICD.yml
KyleKotowick Mar 26, 2023
00a8319
Refactor to use new variable validation capabilities
KyleKotowick Jul 7, 2024
bdc74f4
Update CI/CD minimum Terraform version
KyleKotowick Jul 7, 2024
f37120b
Update CICD.yml
KyleKotowick Jul 11, 2024
4d01d62
Update CICD.yml
KyleKotowick Jul 11, 2024
4f2561d
Update CICD.yml
KyleKotowick Jul 11, 2024
47726b4
Update CICD.yml
KyleKotowick Jul 11, 2024
17bc1b7
Update CICD.yml
KyleKotowick Jul 11, 2024
32e3442
Update CICD.yml
KyleKotowick Jul 11, 2024
da3d24f
Update CICD.yml
KyleKotowick Jul 11, 2024
7991f18
Update CICD.yml
KyleKotowick Jul 11, 2024
0037be7
Update CICD.yml
KyleKotowick Jul 11, 2024
1ef9c6d
Update CICD.yml
KyleKotowick Jul 11, 2024
40a0160
Update CICD.yml
KyleKotowick Jul 11, 2024
25723ab
Merge branch 'main' into dev
KyleKotowick Jul 11, 2024
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
14 changes: 7 additions & 7 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
steps:
- name: Generate Matrix
id: matrix
uses: Invicton-Labs/terraform-module-testing/matrix@v0.1.0
uses: Invicton-Labs/terraform-module-testing/matrix@v0.2.0
with:
minimum_tf_version: '0.13.0'
minimum_tf_version: '1.9.0'

- name: Output Matrix
run: |
Expand All @@ -28,23 +28,23 @@ jobs:
steps:
- name: Initialize - Pass
id: init-pass
uses: Invicton-Labs/terraform-module-testing/initialize@v0.1.0
uses: Invicton-Labs/terraform-module-testing/initialize@v0.2.0
with:
tf_path: tests/pass
- name: Run Tests - Pass
id: tests-pass
uses: Invicton-Labs/terraform-module-testing/apply-destroy@v0.1.0
uses: Invicton-Labs/terraform-module-testing/apply-destroy@v0.2.0
with:
tf_path: tests/pass

- name: Initialize - Fail
id: init-fail
uses: Invicton-Labs/terraform-module-testing/initialize@v0.1.0
uses: Invicton-Labs/terraform-module-testing/initialize@v0.2.0
with:
tf_path: tests/fail
- name: Run Tests - Fail
id: tests-fail
uses: Invicton-Labs/terraform-module-testing/apply-failure@v0.1.0
uses: Invicton-Labs/terraform-module-testing/apply-failure@v0.2.0
with:
tf_path: tests/fail

Expand All @@ -56,4 +56,4 @@ jobs:
needs: [Test]
steps:
- name: Mark tests as passed
run: echo "🎉"
run: echo "🎉"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2022 Invicton Labs (https://invictonlabs.com)
Copyright (c) 2021-2024 Invicton Labs (https://invictonlabs.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
13 changes: 0 additions & 13 deletions main.tf

This file was deleted.

12 changes: 11 additions & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
output "error_message" {
description = "The value of the `error_message` input variable."
value = var.error_message
}

output "condition" {
description = "The value of the `condition` input variable."
value = var.condition
}

output "checked" {
description = "Whether the condition has been checked (used for assertion dependencies)."
value = data.cloudinit_config.check.rendered == "" ? true : true
value = var.condition == true ? true : true
}
19 changes: 14 additions & 5 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
variable "condition" {
description = "The condition to ensure is `true`."
type = bool
}

variable "error_message" {
description = "The error message to display if the condition evaluates to `false`."
type = string
nullable = false
}

variable "condition" {
description = "The condition to ensure is `true`."
type = bool
validation {
// We have to use var.error_message != null to force the evaluation to wait
// until var.error_message is known. Otherwise, it can fail during the validation
// phase but won't output the proper error message.
// https://github.com/hashicorp/terraform/issues/35397
condition = var.error_message != null && var.condition == true
error_message = var.error_message
}
}
8 changes: 1 addition & 7 deletions versions.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
terraform {
required_version = ">= 0.13.0"
required_providers {
cloudinit = {
source = "hashicorp/cloudinit"
version = ">= 2.3.1"
}
}
required_version = ">= 1.9.0"
}
Loading