Skip to content

Commit 4cac846

Browse files
justusharclaude
andcommitted
fix(controller): wire localfile notifier for plan command
`getApplyNotifier` already had a branch that swaps in the localfile notifier when `--output <path>` is provided. `getPlanNotifier` was missing the same branch — running `tfnotify --output X plan -- …` would skip every notifier path and exit with `no notifier specified at all`. Mirror the apply path: when `Output != ""`, build the localfile client, append it to the notifier list, and return early. `--output` now works symmetrically for plan and apply. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e831057 commit 4cac846

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

pkg/controller/controller.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,31 @@ func (c *Controller) getPlanNotifier(ctx context.Context) ([]notifier.Notifier,
222222
labels = a
223223
}
224224

225+
if c.Config.Output != "" {
226+
// Write output to file instead of github comment (plan path).
227+
// Mirrors the apply path; without this, `tfnotify --output X plan`
228+
// drops the notifier entirely and the caller hits
229+
// "no notifier specified at all".
230+
client, err := localfile.NewClient(&localfile.Config{
231+
OutputFile: c.Config.Output,
232+
Parser: c.Parser,
233+
UseRawOutput: c.Config.Terraform.UseRawOutput,
234+
CI: c.Config.CI.Link,
235+
Template: c.Template,
236+
ParseErrorTemplate: c.ParseErrorTemplate,
237+
Vars: c.Config.Vars,
238+
EmbeddedVarNames: c.Config.EmbeddedVarNames,
239+
Templates: c.Config.Templates,
240+
Masks: c.Config.Masks,
241+
DisableLabel: c.Config.Terraform.Plan.DisableLabel,
242+
}, nil)
243+
if err != nil {
244+
return nil, err
245+
}
246+
notifiers = append(notifiers, client.Notify)
247+
return notifiers, nil
248+
}
249+
225250
if !c.Config.Terraform.Plan.DisableLabel || c.Config.Output == "" {
226251
client, err := github.NewClient(ctx, &github.Config{
227252
BaseURL: c.Config.GHEBaseURL,

0 commit comments

Comments
 (0)