func (cfg *Config) checkEmail(b *cbpb.Build) error {
	if cfg.emailHostname == "" {
		return errors.New("EMAIL_HOSTNAME not set")
	}
	if cfg.emailPort <= 0 {
		return errors.New("EMAIL_PORT not set")
	}
	if cfg.emailFrom == nil {
		return errors.New("EMAIL_FROM not set")
	}
	if len(cfg.emailRecipients) == 0 {
		return errors.New("EMAIL_RECIPIENTS not set")
	}
	if len(cfg.emailBuildTriggerIDs) > 0 || len(cfg.emailBuildTriggerNames) > 0 {
		name := buildSub(b, triggerNameSub, "")
		_, idOk := cfg.emailBuildTriggerIDs[b.BuildTriggerId]
		_, nameOk := cfg.emailBuildTriggerNames[name]

		checkGlobs := func() bool {
			for p := range cfg.emailBuildTriggerNames {
				if m, err := filepath.Match(p, name); err == nil && m {
					return true
				}
			}
			return false
		}

		if !idOk && !nameOk && !checkGlobs() {
			return fmt.Errorf("trigger %v (%q) not matched by EMAIL_BUILD_TRIGGER_IDS or "+
				"EMAIL_BUILD_TRIGGER_NAMES", b.BuildTriggerId, name)
		}
	}
	if _, ok := cfg.emailBuildStatuses[b.Status.String()]; !ok {
		return fmt.Errorf("status %q not matched by EMAIL_BUILD_STATUSES", b.Status)
	}
	return nil
}
// checkEmail returns nil if an email notification should be sent for b
// per cfg and a descriptive error otherwise.
checkEmail returns nil if an email notification should be sent for b
per cfg and a descriptive error otherwise.
// checkEmail returns nil if an email notification should be sent for b // per cfg and a descriptive error otherwise .
func (cfg *Config) checkEmail(b *cbpb.Build) error {
	if cfg.emailHostname == "" {
		return errors.New("EMAIL_HOSTNAME not set")
	}
	if cfg.emailPort <= 0 {
		return errors.New("EMAIL_PORT not set")
	}
	if cfg.emailFrom == nil {
		return errors.New("EMAIL_FROM not set")
	}
	if len(cfg.emailRecipients) == 0 {
		return errors.New("EMAIL_RECIPIENTS not set")
	}
	if len(cfg.emailBuildTriggerIDs) > 0 || len(cfg.emailBuildTriggerNames) > 0 {
		name := buildSub(b, triggerNameSub, "")
		_, idOk := cfg.emailBuildTriggerIDs[b.BuildTriggerId]
		_, nameOk := cfg.emailBuildTriggerNames[name]
		checkGlobs := func() bool {
			for p := range cfg.emailBuildTriggerNames {
				if m, err := filepath.Match(p, name); err == nil && m {
					return true
				}
			}
			return false
		}
		if !idOk && !nameOk && !checkGlobs() {
			return fmt.Errorf("trigger %v (%q) not matched by EMAIL_BUILD_TRIGGER_IDS or "+
				"EMAIL_BUILD_TRIGGER_NAMES", b.BuildTriggerId, name)
		}
	}
	if _, ok := cfg.emailBuildStatuses[b.Status.String()]; !ok {
		return fmt.Errorf("status %q not matched by EMAIL_BUILD_STATUSES", b.Status)
	}
	return nil
}
func ( cfg * Config ) checkEmail ( b * cbpb . Build ) error { if cfg . emailHostname == " " { return errors . New ( " " ) } if cfg . emailPort <= 0 { return errors . New ( " " ) } if cfg . emailFrom == nil { return errors . New ( " " ) } if len ( cfg . emailRecipients ) == 0 { return errors . New ( " " ) } if len ( cfg . emailBuildTriggerIDs ) > 0 || len ( cfg . emailBuildTriggerNames ) > 0 { name := buildSub ( b , triggerNameSub , " " ) _ , idOk := cfg . emailBuildTriggerIDs [ b . BuildTriggerId ] _ , nameOk := cfg . emailBuildTriggerNames [ name ] checkGlobs := func ( ) bool { for p := range cfg . emailBuildTriggerNames { if m , err := filepath . Match ( p , name ) ; err == nil && m { return true } } return false } if ! idOk && ! nameOk && ! checkGlobs ( ) { return fmt . Errorf ( " " + " " , b . BuildTriggerId , name ) } } if _ , ok := cfg . emailBuildStatuses [ b . Status . String ( ) ] ; ! ok { return fmt . Errorf ( " " , b . Status ) } return nil }
checkEmail returns nil if an email notification should be sent for b
per cfg and a descriptive error otherwise.
checkEmail returns nil if an email notification should be sent for b per cfg and a descriptive error otherwise .