Skip to content

Commit 37d7863

Browse files
Merge pull request #41 from suzuki-shunsuke/fix/remove-title
fix: remove title and destroy-warning-title options and template variable ".Title"
2 parents 516a399 + 4e6afc5 commit 37d7863

13 files changed

+98
-140
lines changed

COMPARED_WITH_TFNOTIFY.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ tfcmt isn't compatible with tfnotify.
88
* [Remove `fmt` command](#breaking-change-remove-fmt-command)
99
* [Configuration file name is changed](#breaking-change-configuration-file-name-is-changed)
1010
* [Command usage is changed](#breaking-change-command-usage-is-changed)
11-
* [Remove --message option and template variable .Message](#breaking-change-remove---message-option-and-template-variable-message)
11+
* [Remove --message and --destroy-warning-message option and template variable .Message](#breaking-change-remove---message-and---destroy-warning-message-option-and-template-variable-message)
12+
* [Remove --title and --destroy-warning-title options and template variable .Title](#breaking-change-remove---title-and---destroy-warning-title-options-and-template-variable-title)
1213
* [Don't remove duplicate comments](#breaking-change-dont-remove-duplicate-comments)
1314
* [Change the behavior of deletion warning](#breaking-change-change-the-behavior-of-deletion-warning)
1415
* Features
@@ -91,10 +92,19 @@ tfcmt apply -- terraform apply
9192

9293
By this change, tfcmt can handle the standard error output and exit code of the terraform command.
9394

94-
## Breaking Change: Remove --message option and template variable .Message
95+
## Breaking Change: Remove --message and --destroy-warning-message option and template variable .Message
96+
97+
[#40](https://github.com/suzuki-shunsuke/tfcmt/pull/40)
98+
99+
We introduced more general option `-var` and template variable `.Vars`,
100+
so the `--message` and `--destroy-warning-message` options aren't needed.
101+
102+
## Breaking Change: Remove --title and --destroy-warning-title options and template variable .Title
103+
104+
[#41](https://github.com/suzuki-shunsuke/tfcmt/pull/41)
95105

96106
We introduced more general option `-var` and template variable `.Vars`,
97-
so the `--message` option isn't needed.
107+
so the `--title` and `--destroy-warning-title` options aren't needed.
98108

99109
## Breaking Change: Don't remove duplicate comments
100110

@@ -117,7 +127,7 @@ tfcmt posts only one comment whose template is `when_destroy.template`.
117127
label: "destroy"
118128
label_color: "d93f0b" # red
119129
template: |
120-
{{ .Title }}
130+
## Plan Result
121131
122132
[CI link]( {{ .Link }} )
123133
@@ -133,8 +143,6 @@ tfcmt posts only one comment whose template is `when_destroy.template`.
133143
</pre></code></details>
134144
```
135145
136-
And the default title of destroy warning is changed to `## :warning: Resource Deletion will happen :warning:`.
137-
138146
### Feature: Add template variables of changed resource paths
139147
140148
[#39](https://github.com/suzuki-shunsuke/tfcmt/pull/39)
@@ -194,7 +202,7 @@ terraform:
194202
plan:
195203
when_parse_error:
196204
template: |
197-
{{ .Title }} <sup>[CI link]( {{ .Link }} )</sup>
205+
## Plan Result <sup>[CI link]( {{ .Link }} )</sup>
198206
199207
:warning: It failed to parse the result. :warning:
200208
@@ -205,7 +213,7 @@ terraform:
205213
apply:
206214
when_parse_error:
207215
template: |
208-
{{ .Title }} <sup>[CI link]( {{ .Link }} )</sup>
216+
## Apply Result <sup>[CI link]( {{ .Link }} )</sup>
209217
210218
:warning: It failed to parse the result. :warning:
211219

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ The example settings of GitHub and GitHub Enterprise are as follows. Incidentall
6666

6767
Placeholder | Usage
6868
---|---
69-
`{{ .Title }}` | Like `## Plan result`
7069
`{{ .Result }}` | Matched result by parsing like `Plan: 1 to add` or `No changes`
7170
`{{ .Body }}` | The entire of Terraform execution result
7271
`{{ .Link }}` | The link of the build page on CI
@@ -102,7 +101,7 @@ notifier:
102101
terraform:
103102
plan:
104103
template: |
105-
{{ .Title }} <sup>[CI link]( {{ .Link }} )</sup>
104+
## Plan Result <sup>[CI link]( {{ .Link }} )</sup>
106105
{{if .Result}}
107106
<pre><code>{{ .Result }}
108107
</pre></code>
@@ -113,7 +112,7 @@ terraform:
113112
</pre></code></details>
114113
apply:
115114
template: |
116-
{{ .Title }}
115+
## Apply Result
117116
{{if .Result}}
118117
<pre><code>{{ .Result }}
119118
</pre></code>
@@ -133,7 +132,7 @@ terraform:
133132
# ...
134133
plan:
135134
template: |
136-
{{ .Title }} <sup>[CI link]( {{ .Link }} )</sup>
135+
## Plan Result <sup>[CI link]( {{ .Link }} )</sup>
137136
{{if .Result}}
138137
<pre><code>{{ .Result }}
139138
</pre></code>
@@ -159,7 +158,7 @@ terraform:
159158
# ...
160159
plan:
161160
template: |
162-
{{ .Title }} <sup>[CI link]( {{ .Link }} )</sup>
161+
## Plan Result <sup>[CI link]( {{ .Link }} )</sup>
163162
{{if .Result}}
164163
<pre><code>{{ .Result }}
165164
</pre></code>
@@ -196,7 +195,7 @@ terraform:
196195
# ...
197196
plan:
198197
template: |
199-
{{ .Title }} <sup>[CI link]( {{ .Link }} )</sup>
198+
## Plan Result <sup>[CI link]( {{ .Link }} )</sup>
200199
{{if .Result}}
201200
```
202201
{{ .Result }}
@@ -228,7 +227,7 @@ notifier:
228227
terraform:
229228
plan:
230229
template: |
231-
{{ .Title }} <sup>[CI link]( {{ .Link }} )</sup>
230+
## Plan Result <sup>[CI link]( {{ .Link }} )</sup>
232231
{{if .Result}}
233232
<pre><code>{{ .Result }}
234233
</pre></code>
@@ -239,7 +238,7 @@ terraform:
239238
</pre></code></details>
240239
apply:
241240
template: |
242-
{{ .Title }}
241+
## Apply Result
243242
{{if .Result}}
244243
<pre><code>{{ .Result }}
245244
</pre></code>

config/config_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func TestLoadFile(t *testing.T) {
4040
Template: "",
4141
},
4242
Plan: Plan{
43-
Template: "{{ .Title }}\n{{if .Result}}\n<pre><code>{{ .Result }}\n</pre></code>\n{{end}}\n<details><summary>Details (Click me)</summary>\n\n<pre><code>{{ .Body }}\n</pre></code></details>\n",
43+
Template: "## Plan Result\n{{if .Result}}\n<pre><code>{{ .Result }}\n</pre></code>\n{{end}}\n<details><summary>Details (Click me)</summary>\n\n<pre><code>{{ .Body }}\n</pre></code></details>\n",
4444
WhenDestroy: WhenDestroy{},
4545
},
4646
Apply: Apply{
@@ -70,7 +70,7 @@ func TestLoadFile(t *testing.T) {
7070
Template: "",
7171
},
7272
Plan: Plan{
73-
Template: "{{ .Title }}\n{{if .Result}}\n<pre><code>{{ .Result }}\n</pre></code>\n{{end}}\n<details><summary>Details (Click me)</summary>\n\n<pre><code>{{ .Body }}\n</pre></code></details>\n",
73+
Template: "## Plan Result\n{{if .Result}}\n<pre><code>{{ .Result }}\n</pre></code>\n{{end}}\n<details><summary>Details (Click me)</summary>\n\n<pre><code>{{ .Body }}\n</pre></code></details>\n",
7474
WhenAddOrUpdateOnly: WhenAddOrUpdateOnly{
7575
Label: "add-or-update",
7676
},
@@ -112,7 +112,7 @@ func TestLoadFile(t *testing.T) {
112112
Template: "",
113113
},
114114
Plan: Plan{
115-
Template: "{{ .Title }}\n{{if .Result}}\n<pre><code>{{ .Result }}\n</pre></code>\n{{end}}\n<details><summary>Details (Click me)</summary>\n\n<pre><code>{{ .Body }}\n</pre></code></details>\n",
115+
Template: "## Plan Result\n{{if .Result}}\n<pre><code>{{ .Result }}\n</pre></code>\n{{end}}\n<details><summary>Details (Click me)</summary>\n\n<pre><code>{{ .Body }}\n</pre></code></details>\n",
116116
WhenDestroy: WhenDestroy{},
117117
},
118118
Apply: Apply{

example-use-raw-output.tfcmt.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ terraform:
99
use_raw_output: true
1010
plan:
1111
template: |
12-
{{ .Title }}
12+
## Plan Result
1313
{{if .Result}}
1414
<pre><code>{{ .Result }}
1515
</pre></code>

example-with-destroy-and-result-labels.tfcmt.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ notifier:
88
terraform:
99
plan:
1010
template: |
11-
{{ .Title }}
11+
## Plan Result
1212
{{if .Result}}
1313
<pre><code>{{ .Result }}
1414
</pre></code>

example.tfcmt.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ notifier:
88
terraform:
99
plan:
1010
template: |
11-
{{ .Title }}
11+
## Plan Result
1212
{{if .Result}}
1313
<pre><code>{{ .Result }}
1414
</pre></code>

main.go

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,8 @@ func (t *tfcmt) getNotifier(ctx context.Context, ci CI) (notifier.Notifier, erro
109109
Owner: t.config.Notifier.Github.Repository.Owner,
110110
Repo: t.config.Notifier.Github.Repository.Name,
111111
PR: github.PullRequest{
112-
Revision: ci.PR.Revision,
113-
Number: ci.PR.Number,
114-
Title: t.context.String("title"),
115-
DestroyWarningTitle: t.context.String("destroy-warning-title"),
116-
DestroyWarningMessage: t.context.String("destroy-warning-message"),
112+
Revision: ci.PR.Revision,
113+
Number: ci.PR.Number,
117114
},
118115
CI: ci.URL,
119116
Parser: t.parser,
@@ -189,31 +186,11 @@ func main() {
189186
Name: "plan",
190187
Usage: "Run terraform plan and post a comment to GitHub commit or pull request",
191188
Action: cmdPlan,
192-
Flags: []cli.Flag{
193-
&cli.StringFlag{
194-
Name: "title, t",
195-
Usage: "Specify the title to use for notification",
196-
},
197-
&cli.StringFlag{
198-
Name: "destroy-warning-title",
199-
Usage: "Specify the title to use for destroy warning notification",
200-
},
201-
&cli.StringFlag{
202-
Name: "destroy-warning-message",
203-
Usage: "Specify the message to use for destroy warning notification",
204-
},
205-
},
206189
},
207190
{
208191
Name: "apply",
209192
Usage: "Run terraform apply and post a comment to GitHub commit or pull request",
210193
Action: cmdApply,
211-
Flags: []cli.Flag{
212-
&cli.StringFlag{
213-
Name: "title, t",
214-
Usage: "Specify the title to use for notification",
215-
},
216-
},
217194
},
218195
{
219196
Name: "version",

notifier/github/client.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,8 @@ type Config struct {
5757

5858
// PullRequest represents GitHub Pull Request metadata
5959
type PullRequest struct {
60-
Revision string
61-
Title string
62-
Message string
63-
Number int
64-
DestroyWarningTitle string
65-
DestroyWarningMessage string
60+
Revision string
61+
Number int
6662
}
6763

6864
type service struct {

notifier/github/github_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ func newFakeConfig() Config {
131131
PR: PullRequest{
132132
Revision: "abcd",
133133
Number: 1,
134-
Message: "message",
135134
},
136135
Parser: terraform.NewPlanParser(),
137136
Template: terraform.NewPlanTemplate(terraform.DefaultPlanTemplate),

notifier/github/notify.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ func (g *NotifyService) Notify(ctx context.Context, param notifier.ParamExec) (i
102102
}
103103

104104
template.SetValue(terraform.CommonTemplate{
105-
Title: cfg.PR.Title,
106105
Result: result.Result,
107106
Body: body,
108107
Link: cfg.CI,

0 commit comments

Comments
 (0)