Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 git pull err that was preventing pulling on every apply #651

Merged
merged 1 commit into from
Oct 22, 2024
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
14 changes: 9 additions & 5 deletions pkg/environment/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ func (a *Apply) ApplyBatch() error {
func (a *Apply) applyNamespaceDirs(chunkFolder []string) error {
erroredNs := []string{}

err := util.GetLatestGitPull()
if err != nil {
return err
}

done := make(chan bool)
defer close(done)

Expand Down Expand Up @@ -232,6 +227,15 @@ func (a *Apply) runApply(done <-chan bool, dirStream <-chan string) <-chan strin
ns := strings.Split(dir, "/")
namespace := ns[2]

pullErr := util.GetLatestGitPull()
if pullErr != nil {
if strings.Contains(pullErr.Error(), "index.lock") {
fmt.Printf("ignoring git lock error during parallel run\n")
} else {
return pullErr.Error()
}
}

err := a.applyNamespace(namespace)
if err != nil {
return "Error in namespace: " + namespace + "\n" + err.Error()
Expand Down
8 changes: 3 additions & 5 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,20 @@ func GetLatestGitPull() error {
fmt.Println("Executing git reset")
resetErr := reset.Run()
if resetErr != nil {
fmt.Println(fmt.Sprint(resetErr) + ": " + stderr.String())
return resetErr
return errors.New(resetErr.Error() + ": " + stderr.String())
}

fmt.Println("Executing git pull")
err := pull.Run()
if err != nil {
fmt.Println(fmt.Sprint(err) + ": " + stderr.String())
return err
return errors.New(fmt.Sprint(err) + ": " + stderr.String())
}

return nil
}

// Redacted reads bytes of data for any sensitive strings and print REDACTED
// This functiion is used to prevent slack webhooks URLS from being output in pipeline logs
// This function is used to prevent slack webhooks URLS from being output in pipeline logs
func Redacted(w io.Writer, output string, redact bool) {
re := regexp2.MustCompile(`^.*https://hooks\.slack\.com.*$`, 0)
scanner := bufio.NewScanner(strings.NewReader(output))
Expand Down
Loading