fix: execute hook check only on --one-time
Execute hook check only if --one-time is true and corrected log spelling of webhook and exechook
This commit is contained in:
parent
a362b4a5f4
commit
d2a4320e6c
|
|
@ -364,7 +364,10 @@ func main() {
|
||||||
if *flExechookBackoff < time.Second {
|
if *flExechookBackoff < time.Second {
|
||||||
handleError(log, true, "ERROR: --exechook-backoff must be at least 1s")
|
handleError(log, true, "ERROR: --exechook-backoff must be at least 1s")
|
||||||
}
|
}
|
||||||
exechookChannel = make(chan bool, 1)
|
|
||||||
|
if *flOneTime {
|
||||||
|
exechookChannel = make(chan bool, 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if *flWebhookURL != "" {
|
if *flWebhookURL != "" {
|
||||||
|
|
@ -377,7 +380,10 @@ func main() {
|
||||||
if *flWebhookBackoff < time.Second {
|
if *flWebhookBackoff < time.Second {
|
||||||
handleError(log, true, "ERROR: --webhook-backoff must be at least 1s")
|
handleError(log, true, "ERROR: --webhook-backoff must be at least 1s")
|
||||||
}
|
}
|
||||||
webhookChannel = make(chan bool, 1)
|
|
||||||
|
if *flOneTime {
|
||||||
|
webhookChannel = make(chan bool, 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if *flPassword != "" && *flPasswordFile != "" {
|
if *flPassword != "" && *flPasswordFile != "" {
|
||||||
|
|
@ -630,25 +636,27 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if initialSync {
|
if initialSync {
|
||||||
// Wait for hooks to complete at least once, if not nil, before checking whether to stop program
|
// Determine if git-sync should terminate for one of several reasons
|
||||||
// Assumes that if hook channels are not nil, they will have at least one value before getting closed
|
|
||||||
if exechookChannel != nil {
|
|
||||||
exechookChannelFinishedSuccessfully := <-exechookChannel
|
|
||||||
if !exechookChannelFinishedSuccessfully {
|
|
||||||
log.Error(nil, "exec hook completed with error")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if webhookChannel != nil {
|
|
||||||
webhookChannelFinishedSuccessfully := <-webhookChannel
|
|
||||||
if !webhookChannelFinishedSuccessfully {
|
|
||||||
log.Error(nil, "web hook completed with error")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine if git-sync should terminate
|
|
||||||
if *flOneTime {
|
if *flOneTime {
|
||||||
|
// Wait for hooks to complete at least once, if not nil, before checking whether to stop program
|
||||||
|
// Assumes that if hook channels are not nil, they will have at least one value before getting closed
|
||||||
|
exitCode := 0 // if all hooks succeeded, exit code is 0, else set to 1
|
||||||
|
if exechookChannel != nil {
|
||||||
|
exechookChannelFinishedSuccessfully := <-exechookChannel
|
||||||
|
if !exechookChannelFinishedSuccessfully {
|
||||||
|
log.Error(nil, "exechook completed with error")
|
||||||
|
exitCode = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if webhookChannel != nil {
|
||||||
|
webhookChannelFinishedSuccessfully := <-webhookChannel
|
||||||
|
if !webhookChannelFinishedSuccessfully {
|
||||||
|
log.Error(nil, "webhook completed with error")
|
||||||
|
}
|
||||||
|
exitCode = 1
|
||||||
|
}
|
||||||
log.DeleteErrorFile()
|
log.DeleteErrorFile()
|
||||||
os.Exit(0)
|
os.Exit(exitCode)
|
||||||
}
|
}
|
||||||
if isHash, err := git.RevIsHash(ctx); err != nil {
|
if isHash, err := git.RevIsHash(ctx); err != nil {
|
||||||
log.Error(err, "can't tell if rev is a git hash, exiting", "rev", git.rev)
|
log.Error(err, "can't tell if rev is a git hash, exiting", "rev", git.rev)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue