Skip to content

Commit

Permalink
Warning admonition (#79)
Browse files Browse the repository at this point in the history
* Warning admonition

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Addede debug warning

* Update test-changes-exists-drift.yml
  • Loading branch information
goruha authored Jun 19, 2024
1 parent 54abf42 commit 97217cc
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 8 deletions.
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

0 comments on commit 97217cc

Please sign in to comment.