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,8 +364,11 @@ func main() {
|
|||
if *flExechookBackoff < time.Second {
|
||||
handleError(log, true, "ERROR: --exechook-backoff must be at least 1s")
|
||||
}
|
||||
|
||||
if *flOneTime {
|
||||
exechookChannel = make(chan bool, 1)
|
||||
}
|
||||
}
|
||||
|
||||
if *flWebhookURL != "" {
|
||||
if *flWebhookStatusSuccess < -1 {
|
||||
|
|
@ -377,8 +380,11 @@ func main() {
|
|||
if *flWebhookBackoff < time.Second {
|
||||
handleError(log, true, "ERROR: --webhook-backoff must be at least 1s")
|
||||
}
|
||||
|
||||
if *flOneTime {
|
||||
webhookChannel = make(chan bool, 1)
|
||||
}
|
||||
}
|
||||
|
||||
if *flPassword != "" && *flPasswordFile != "" {
|
||||
handleError(log, false, "ERROR: only one of --password and --password-file may be specified")
|
||||
|
|
@ -630,12 +636,16 @@ func main() {
|
|||
}
|
||||
|
||||
if initialSync {
|
||||
// Determine if git-sync should terminate for one of several reasons
|
||||
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 {
|
||||
|
|
@ -643,12 +653,10 @@ func main() {
|
|||
if !webhookChannelFinishedSuccessfully {
|
||||
log.Error(nil, "webhook completed with error")
|
||||
}
|
||||
exitCode = 1
|
||||
}
|
||||
|
||||
// Determine if git-sync should terminate
|
||||
if *flOneTime {
|
||||
log.DeleteErrorFile()
|
||||
os.Exit(0)
|
||||
os.Exit(exitCode)
|
||||
}
|
||||
if isHash, err := git.RevIsHash(ctx); err != nil {
|
||||
log.Error(err, "can't tell if rev is a git hash, exiting", "rev", git.rev)
|
||||
|
|
|
|||
Loading…
Reference in New Issue