Skip to content
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
6 changes: 6 additions & 0 deletions pkg/controller/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ func (c *Controller) Apply(ctx context.Context, command Command) error {
return err
}

if c.Config.Vars == nil {
c.Config.Vars = make(map[string]string)
}
c.Config.Vars["COMMIT_SHA"] = c.Config.CI.SHA

ntf, err := c.getApplyNotifier(ctx)
if err != nil {
return err
Expand All @@ -39,6 +44,7 @@ func (c *Controller) Apply(ctx context.Context, command Command) error {
// Execute command once
cmd := exec.CommandContext(ctx, command.Cmd, command.Args...) //nolint:gosec
cmd.Stdin = os.Stdin
cmd.Env = append(os.Environ(), "COMMIT_SHA="+c.Config.CI.SHA)
stdout := &bytes.Buffer{}
stderr := &bytes.Buffer{}
combinedOutput := &bytes.Buffer{}
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ func (c *Controller) getPlanNotifier(ctx context.Context) ([]notifier.Notifier,
planMessage = envMessage
}

useThreads := true
var useThreads bool
if c.Config.Slack.UseThreads != nil {
useThreads = *c.Config.Slack.UseThreads
}

if s, ok := os.LookupEnv("SLACK_USE_THREADS"); ok {
parsed, err := strconv.ParseBool(s)
if err != nil {
Expand All @@ -165,7 +165,7 @@ func (c *Controller) getPlanNotifier(ctx context.Context) ([]notifier.Notifier,
}

notifyOnPlanError := c.Config.Slack.NotifyOnPlanError
if envNotifyOnPlanError := os.Getenv("SLACK_NOTIFY_ON_PLAN_ERROR"); envNotifyOnPlanError != "" {
if envNotifyOnPlanError := os.Getenv("SLACK_NOTIFY_ON_PLAN_ERROR"); envNotifyOnPlanError != "false" {
parsed, err := strconv.ParseBool(envNotifyOnPlanError)
if err != nil {
return nil, fmt.Errorf("invalid SLACK_NOTIFY_ON_PLAN_ERROR value %q: %w", envNotifyOnPlanError, err)
Expand All @@ -174,7 +174,7 @@ func (c *Controller) getPlanNotifier(ctx context.Context) ([]notifier.Notifier,
}

notifyOnApplyError := c.Config.Slack.NotifyOnApplyError
if envNotifyOnApplyError := os.Getenv("SLACK_NOTIFY_ON_APPLY_ERROR"); envNotifyOnApplyError != "" {
if envNotifyOnApplyError := os.Getenv("SLACK_NOTIFY_ON_APPLY_ERROR"); envNotifyOnApplyError != "false" {
parsed, err := strconv.ParseBool(envNotifyOnApplyError)
if err != nil {
return nil, fmt.Errorf("invalid SLACK_NOTIFY_ON_APPLY_ERROR value %q: %w", envNotifyOnApplyError, err)
Expand Down
6 changes: 6 additions & 0 deletions pkg/controller/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ func (c *Controller) Plan(ctx context.Context, command Command) error {
return err
}

if c.Config.Vars == nil {
c.Config.Vars = make(map[string]string)
}
c.Config.Vars["COMMIT_SHA"] = c.Config.CI.SHA

ntf, err := c.getPlanNotifier(ctx)
if err != nil {
return err
Expand All @@ -40,6 +45,7 @@ func (c *Controller) Plan(ctx context.Context, command Command) error {
// Execute command once
cmd := exec.CommandContext(ctx, command.Cmd, command.Args...) //nolint:gosec
cmd.Stdin = os.Stdin
cmd.Env = append(os.Environ(), "COMMIT_SHA="+c.Config.CI.SHA)
stdout := &bytes.Buffer{}
stderr := &bytes.Buffer{}
combinedOutput := &bytes.Buffer{}
Expand Down
Loading