Skip to content

Commit

Permalink
feat: 🎸 skip notify user if the namespace contains SKIP file (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaskaransarkaria committed Mar 14, 2024
1 parent 4a78f94 commit d4c18d5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pkg/environment/environmentApply.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Options struct {
AllNamespaces bool
EnableApplySkip, RedactedEnv, SkipProdDestroy bool
BatchApplyIndex, BatchApplySize int
OnlySkipFileChanged bool
}

// RequiredEnvVars is used to store values such as TF_VAR_ , github and pingdom tokens
Expand Down Expand Up @@ -160,6 +161,13 @@ func (a *Apply) Apply() error {
}
if isMerged {
repos, err := a.GithubClient.GetChangedFiles(a.Options.PRNumber)

a.Options.OnlySkipFileChanged = false

if len(repos) == 1 {
a.Options.OnlySkipFileChanged = strings.Contains(*repos[0].Filename, "APPLY_PIPELINE_SKIP_THIS_NAMESPACE")
}

if err != nil {
return err
}
Expand Down Expand Up @@ -485,7 +493,9 @@ func (a *Apply) applyNamespace() error {
if util.IsYamlFileExists(repoPath) {
outputKubectl, err := applier.applyKubectl()
if err != nil {
notifyUserApplyFailed(a.Options.PRNumber, applier.RequiredEnvVars.SlackBotToken, applier.RequiredEnvVars.SlackWebhookUrl, a.Options.BuildUrl)
if !a.Options.OnlySkipFileChanged {
notifyUserApplyFailed(a.Options.PRNumber, applier.RequiredEnvVars.SlackBotToken, applier.RequiredEnvVars.SlackWebhookUrl, a.Options.BuildUrl)
}
return err
}

Expand All @@ -503,7 +513,9 @@ func (a *Apply) applyNamespace() error {
if err == nil && exists {
outputTerraform, err := applier.applyTerraform()
if err != nil {
notifyUserApplyFailed(a.Options.PRNumber, applier.RequiredEnvVars.SlackBotToken, applier.RequiredEnvVars.SlackWebhookUrl, a.Options.BuildUrl)
if !a.Options.OnlySkipFileChanged {
notifyUserApplyFailed(a.Options.PRNumber, applier.RequiredEnvVars.SlackBotToken, applier.RequiredEnvVars.SlackWebhookUrl, a.Options.BuildUrl)
}
return err
}
fmt.Println("\nOutput of terraform:")
Expand Down

0 comments on commit d4c18d5

Please sign in to comment.