Skip to content

Commit 681320c

Browse files
fix: remove title option
BREAKING CHANGE: `--title` option and template variable "title" are removed
1 parent 516a399 commit 681320c

13 files changed

+82
-133
lines changed

COMPARED_WITH_TFNOTIFY.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ tfcmt posts only one comment whose template is `when_destroy.template`.
117117
label: "destroy"
118118
label_color: "d93f0b" # red
119119
template: |
120-
{{ .Title }}
120+
## Plan Result
121121
122122
[CI link]( {{ .Link }} )
123123
@@ -133,8 +133,6 @@ tfcmt posts only one comment whose template is `when_destroy.template`.
133133
</pre></code></details>
134134
```
135135
136-
And the default title of destroy warning is changed to `## :warning: Resource Deletion will happen :warning:`.
137-
138136
### Feature: Add template variables of changed resource paths
139137
140138
[#39](https://github.com/suzuki-shunsuke/tfcmt/pull/39)
@@ -194,7 +192,7 @@ terraform:
194192
plan:
195193
when_parse_error:
196194
template: |
197-
{{ .Title }} <sup>[CI link]( {{ .Link }} )</sup>
195+
## Plan Result <sup>[CI link]( {{ .Link }} )</sup>
198196
199197
:warning: It failed to parse the result. :warning:
200198
@@ -205,7 +203,7 @@ terraform:
205203
apply:
206204
when_parse_error:
207205
template: |
208-
{{ .Title }} <sup>[CI link]( {{ .Link }} )</sup>
206+
## Apply Result <sup>[CI link]( {{ .Link }} )</sup>
209207
210208
:warning: It failed to parse the result. :warning:
211209

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: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ type Config struct {
5858
// PullRequest represents GitHub Pull Request metadata
5959
type PullRequest struct {
6060
Revision string
61-
Title string
62-
Message string
6361
Number int
64-
DestroyWarningTitle string
6562
DestroyWarningMessage string
6663
}
6764

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)