// ShouldTrigger decides whether a given application should be triggered or not.
ShouldTrigger decides whether a given application should be triggered or not.
// ShouldTrigger decides whether a given application should be triggered or not .
func (d *OnOutOfSyncDeterminer) ShouldTrigger(ctx context.Context, app *model.Application, appCfg *config.GenericDeploymentSpec) (bool, error) {
	if *appCfg.Trigger.OnOutOfSync.Disabled {
		return false, nil
	}
	ref := app.MostRecentlyTriggeredDeployment
	if ref == nil {
		return true, nil
	}
	resp, err := d.client.GetDeployment(ctx, &pipedservice.GetDeploymentRequest{
		Id: ref.DeploymentId,
	})
	if err != nil {
		return false, err
	}
	deployment := resp.Deployment
	if !model.IsCompletedDeployment(deployment.Status) {
		return false, nil
	}
	if time.Since(time.Unix(deployment.CompletedAt, 0)) < appCfg.Trigger.OnOutOfSync.MinWindow.Duration() {
		return false, nil
	}
	return true, nil
}
func ( d * OnOutOfSyncDeterminer ) ShouldTrigger ( ctx context . Context , app * model . Application , appCfg * config . GenericDeploymentSpec ) ( bool , error ) { if * appCfg . Trigger . OnOutOfSync . Disabled { return false , nil } ref := app . MostRecentlyTriggeredDeployment if ref == nil { return true , nil } resp , err := d . client . GetDeployment ( ctx , & pipedservice . GetDeploymentRequest { Id : ref . DeploymentId , } ) if err != nil { return false , err } deployment := resp . Deployment if ! model . IsCompletedDeployment ( deployment . Status ) { return false , nil } if time . Since ( time . Unix ( deployment . CompletedAt , 0 ) ) < appCfg . Trigger . OnOutOfSync . MinWindow . Duration ( ) { return false , nil } return true , nil }
ShouldTrigger decides whether a given application should be triggered or not.
ShouldTrigger decides whether a given application should be triggered or not .
// Find the most recently triggered deployment. // Nil means it seems the application has been added recently // and no deployment was triggered yet. // Check if it was already completed or not. // Not yet completed means the application is deploying currently, // so no need to trigger a new deployment for it. // Check the elapsed time since the last deployment.