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

Warning admonition #79

Merged
merged 24 commits into from
Jun 19, 2024
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
19 changes: 19 additions & 0 deletions .github/workflows/test-changes-exists-drift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,32 @@ jobs:
}

Plan: 1 to add, 0 to change, 0 to destroy.

Warning: Test warning summary

with data.validation_warning.warn[0],
on main.tf line 20, in data "validation_warning" "warn":
20: data "validation_warning" "warn" {

Test warning details
```

</details>




> [!WARNING]
> ```
> Warning: Test warning summary
>
> with data.validation_warning.warn[0],
> on main.tf line 20, in data "validation_warning" "warn":
> 20: data "validation_warning" "warn" {
>
> Test warning details
> ```


<details><summary>Metadata</summary>

Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/test-changes-exists.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,29 @@ jobs:
}

Plan: 1 to add, 0 to change, 0 to destroy.

Warning: Test warning summary

with data.validation_warning.warn[0],
on main.tf line 20, in data "validation_warning" "warn":
20: data "validation_warning" "warn" {

Test warning details
```

</details>


> [!WARNING]
> ```
> Warning: Test warning summary
>
> with data.validation_warning.warn[0],
> on main.tf line 20, in data "validation_warning" "warn":
> 20: data "validation_warning" "warn" {
>
> Test warning details
> ```


teardown:
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/test-infra-cost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,30 @@ jobs:
}

Plan: 1 to add, 0 to change, 0 to destroy.

Warning: Test warning summary

with data.validation_warning.warn[0],
on main.tf line 20, in data "validation_warning" "warn":
20: data "validation_warning" "warn" {

Test warning details
```

</details>


> [!WARNING]
> ```
> Warning: Test warning summary
>
> with data.validation_warning.warn[0],
> on main.tf line 20, in data "validation_warning" "warn":
> 20: data "validation_warning" "warn" {
>
> Test warning details
> ```


<details><summary>Infracost Estimate: monthly cost will not change</summary>

Expand All @@ -145,6 +164,8 @@ jobs:
```

</details>



teardown:
runs-on: ubuntu-latest
Expand Down
20 changes: 13 additions & 7 deletions config/summary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ templates:
deletion_warning: |
{{if .HasDestroy}}
> [!CAUTION]
**Terraform will delete resources!**
This plan contains resource delete operations. Please check the plan result very carefully.
> **Terraform will delete resources!**
> This plan contains resource delete operations. Please check the plan result very carefully.
{{end}}

change_inside_terraform: |
Expand All @@ -115,18 +115,24 @@ templates:
{{end}}
warning: |
{{if .Warning}}
## :warning: Warnings :warning:
{{wrapCode .Warning}}
> [!WARNING]
> ```
{{- range ( .Warning | splitList "\n") }}
> {{ . | avoidHTMLEscape -}}
{{- end}}
> ```
{{end}}

error_messages: |
{{ if eq .ExitCode 1 }}
---
{{wrapCode .Result }}
{{end}}
{{if .ErrorMessages}}
## :warning: Errors
{{range .ErrorMessages}}
* {{. -}}
> [!CAUTION]
> :warning: Errors
{{- range .ErrorMessages}}
> * {{. -}}
{{- end}}{{end}}

infracost: |
Expand Down
11 changes: 11 additions & 0 deletions tests/components/terraform/foobar/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,14 @@ resource "random_id" "foo" {
locals {
failure = var.enabled && var.enable_failure ? file("Failed because failure mode is enabled") : null
}

data "validation_warning" "warn" {
count = var.enable_warning ? 1 : 0
condition = true
summary = "Test warning summary"
details = "Test warning details"
}

provider "validation" {
# Configuration options
}
8 changes: 7 additions & 1 deletion tests/components/terraform/foobar/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ variable "enable_failure" {
type = bool
default = false
description = "Always fail"
}
}

variable "enable_warning" {
type = bool
default = false
description = "Enable warning"
}
8 changes: 8 additions & 0 deletions tests/components/terraform/foobar/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
validation = {
source = "tlkamp/validation"
version = "1.1.1"
}
}
}
1 change: 1 addition & 0 deletions tests/stacks/catalog/foobar-changes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ components:
example: blue
enabled: true
enable_failure: false
enable_warning: true
Loading