// validateDefaults checks ServiceAccountRuleDefaults proto.
439391
func validateDefaults(ctx *validation.Context, title string, d *admin.ServiceAccountRuleDefaults) {
	ctx.Enter(title)
	defer ctx.Exit()
	validateScopes(ctx, "allowed_scope", d.AllowedScope)
	validateMaxGrantValidityDuration(ctx, d.MaxGrantValidityDuration)
}
777914
func (s *IdentityV2) CheckAndSetDefaults() error {
	s.Kind = services.KindIdentity
	s.Version = services.V2
	if err := s.Metadata.CheckAndSetDefaults(); err != nil {
		return trace.Wrap(err)
	}
	if len(s.Spec.Key) == 0 {
		return trace.BadParameter("missing parameter Key")
	}
	if len(s.Spec.SSHCert) == 0 {
		return trace.BadParameter("missing parameter SSHCert")
	}
	if len(s.Spec.TLSCert) == 0 {
		return trace.BadParameter("missing parameter TLSCert")
	}
	if len(s.Spec.TLSCACerts) == 0 {
		return trace.BadParameter("missing parameter TLSCACerts")
	}
	if len(s.Spec.SSHCACerts) == 0 {
		return trace.BadParameter("missing parameter SSH CA bytes")
	}
	return nil
}
786915
func (c *Config) CheckDefaults() error {
	if c.ServiceName == "" {
		return trace.BadParameter("required parameter ServiceName missing")
	}
	if c.Username == "" {
		return trace.BadParameter("required parameter Username missing")
	}
	if c.Stdin == nil {
		return trace.BadParameter("required parameter Stdin missing")
	}
	if c.Stdout == nil {
		return trace.BadParameter("required parameter Stdout missing")
	}
	if c.Stderr == nil {
		return trace.BadParameter("required parameter Stderr missing")
	}

	return nil
}
400551
func (p *PreferRecent) CheckAndSetDefaults() error {
	if p.MaxTTL == 0 {
		p.MaxTTL = defaults.CacheTTL
	}
	return nil
}
347694
func ValidateDevNonce(db sqlx.Queryer, joinEUI, devEUI lorawan.EUI64, nonce lorawan.DevNonce, joinType lorawan.JoinType) error {
	var count int
	err := sqlx.Get(db, &count, `
		select
			count(*)
		from
			device_activation
		where
			dev_eui = $1
			and join_eui = $2
			and dev_nonce = $3
			and join_req_type = $4`,
		devEUI,
		joinEUI,
		nonce,
		joinType,
	)
	if err != nil {
		return handlePSQLError(err, "select error")
	}

	if count != 0 {
		return ErrAlreadyExists
	}

	return nil
}
285702
func (cfg *Config) CheckAndSetDefaults() error {
	if cfg.ID == "" {
		return trace.BadParameter("missing parameter ID")
	}
	if cfg.ClusterName == "" {
		return trace.BadParameter("missing parameter ClusterName")
	}
	if cfg.ClientTLS == nil {
		return trace.BadParameter("missing parameter ClientTLS")
	}
	if cfg.Listener == nil {
		return trace.BadParameter("missing parameter Listener")
	}
	if cfg.DataDir == "" {
		return trace.BadParameter("missing parameter DataDir")
	}
	if cfg.Context == nil {
		cfg.Context = context.TODO()
	}
	if cfg.PollingPeriod == 0 {
		cfg.PollingPeriod = defaults.HighResPollingPeriod
	}
	if cfg.Limiter == nil {
		var err error
		cfg.Limiter, err = limiter.NewLimiter(limiter.LimiterConfig{})
		if err != nil {
			return trace.Wrap(err)
		}
	}
	if cfg.Clock == nil {
		cfg.Clock = clockwork.NewRealClock()
	}
	if cfg.Component == "" {
		cfg.Component = teleport.Component(teleport.ComponentProxy, teleport.ComponentServer)
	}
	return nil
}
1178600
func (af *aggFunction) CalculateDefaultValue(schema Schema, ctx context.Context) (types.Datum, bool) {
	return types.Datum{}, false
}
503305
func (g *GenOpts) EnsureDefaults() error {
	if g.defaultsEnsured {
		return nil
	}
	DefaultSectionOpts(g)
	if g.LanguageOpts == nil {
		g.LanguageOpts = GoLangOpts()
	}
	// set defaults for flattening options
	g.FlattenOpts = &analysis.FlattenOpts{
		Minimal:      true,
		Verbose:      true,
		RemoveUnused: false,
		Expand:       false,
	}
	g.defaultsEnsured = true
	return nil
}
1229506
func (c *TelemetryConfig) MergeDefaults(defaults *TelemetryConfig) {
	if defaults == nil {
		return
	}
	cfgPtrVal := reflect.ValueOf(c)
	cfgVal := cfgPtrVal.Elem()
	otherVal := reflect.ValueOf(*defaults)
	for i := 0; i < cfgVal.NumField(); i++ {
		f := cfgVal.Field(i)
		if !f.IsValid() || !f.CanSet() {
			continue
		}
		// See if the current value is a zero-value, if _not_ skip it
		//
		// No built in way to check for zero-values for all types so only
		// implementing this for the types we actually have for now. Test failure
		// should catch the case where we add new types later.
		switch f.Kind() {
		case reflect.Slice:
			if !f.IsNil() {
				continue
			}
		case reflect.Int, reflect.Int64: // time.Duration == int64
			if f.Int() != 0 {
				continue
			}
		case reflect.String:
			if f.String() != "" {
				continue
			}
		case reflect.Bool:
			if f.Bool() != false {
				continue
			}
		default:
			// Needs implementing, should be caught by tests.
			continue
		}

		// It's zero, copy it from defaults
		f.Set(otherVal.Field(i))
	}
}
215814
func ValidateServiceUpdate(service, oldService *core.Service) field.ErrorList {
	allErrs := ValidateObjectMetaUpdate(&service.ObjectMeta, &oldService.ObjectMeta, field.NewPath("metadata"))

	// ClusterIP should be immutable for services using it (every type other than ExternalName)
	// which do not have ClusterIP assigned yet (empty string value)
	if service.Spec.Type != core.ServiceTypeExternalName {
		if oldService.Spec.Type != core.ServiceTypeExternalName && oldService.Spec.ClusterIP != "" {
			allErrs = append(allErrs, ValidateImmutableField(service.Spec.ClusterIP, oldService.Spec.ClusterIP, field.NewPath("spec", "clusterIP"))...)
		}
	}

	allErrs = append(allErrs, ValidateService(service)...)
	return allErrs
}
305716
func ValidateUsages(usages []string) error {
	validUsages := sets.NewString(api.KnownTokenUsages...)
	invalidUsages := sets.NewString()
	for _, usage := range usages {
		if !validUsages.Has(usage) {
			invalidUsages.Insert(usage)
		}
	}
	if len(invalidUsages) > 0 {
		return fmt.Errorf("invalid bootstrap token usage string: %s, valid usage options: %s", strings.Join(invalidUsages.List(), ","), strings.Join(api.KnownTokenUsages, ","))
	}
	return nil
}
740704
func FilterValidatedEmails(authorizedMails []user.AuthorizationMap, verifiedMails []user.EmailAddress) []user.AuthorizationMap {
	var e []user.AuthorizationMap
	for _, authorizedMail := range authorizedMails {
		for _, verifiedMail := range verifiedMails {
			if authorizedMail.RealLabel == verifiedMail.Label {
				e = append(e, authorizedMail)
				break
			}
		}
	}
	return e
}
173544
func (s *Fleet) SetEnableDefaultInternetAccess(v bool) *Fleet {
	s.EnableDefaultInternetAccess = &v
	return s
}
780321
func (s *DescribeEngineDefaultParametersOutput) SetEngineDefaults(v *EngineDefaults) *DescribeEngineDefaultParametersOutput {
	s.EngineDefaults = v
	return s
}
150273
func ValidateStatefulSet(statefulSet *apps.StatefulSet) field.ErrorList {
	allErrs := apivalidation.ValidateObjectMeta(&statefulSet.ObjectMeta, true, ValidateStatefulSetName, field.NewPath("metadata"))
	allErrs = append(allErrs, ValidateStatefulSetSpec(&statefulSet.Spec, field.NewPath("spec"))...)
	return allErrs
}
1086234
func (s *ImageBuilder) SetEnableDefaultInternetAccess(v bool) *ImageBuilder {
	s.EnableDefaultInternetAccess = &v
	return s
}
624082
func (r *Rule) CheckAndSetDefaults() error {
	if len(r.Resources) == 0 {
		return trace.BadParameter("missing resources to match")
	}
	if len(r.Verbs) == 0 {
		return trace.BadParameter("missing verbs")
	}
	if len(r.Where) != 0 {
		parser, err := GetWhereParserFn()(&Context{})
		if err != nil {
			return trace.Wrap(err)
		}
		_, err = parser.Parse(r.Where)
		if err != nil {
			return trace.BadParameter("could not parse 'where' rule: %q, error: %v", r.Where, err)
		}
	}
	if len(r.Actions) != 0 {
		parser, err := GetActionsParserFn()(&Context{})
		if err != nil {
			return trace.Wrap(err)
		}
		for i, action := range r.Actions {
			_, err = parser.Parse(action)
			if err != nil {
				return trace.BadParameter("could not parse action %v %q, error: %v", i, action, err)
			}
		}
	}
	return nil
}