// applyDefaultOptions returns a new FieldOptions object
// with default values if o does not contain a valid type.
766704
func applyDefaultOptions(o FieldOptions) FieldOptions {
	if o.Type == "" {
		return FieldOptions{
			Type:      DefaultFieldType,
			CacheType: DefaultCacheType,
			CacheSize: DefaultCacheSize,
		}
	}
	return o
}
497372
func (a *Agent) applyProxyDefaults(proxy *structs.ConnectManagedProxy) error {
	// Set the default exec mode
	if proxy.ExecMode == structs.ProxyExecModeUnspecified {
		mode, err := structs.NewProxyExecMode(a.config.ConnectProxyDefaultExecMode)
		if err != nil {
			return err
		}

		proxy.ExecMode = mode
	}
	if proxy.ExecMode == structs.ProxyExecModeUnspecified {
		proxy.ExecMode = structs.ProxyExecModeDaemon
	}

	// Set the default command to the globally configured default
	if len(proxy.Command) == 0 {
		switch proxy.ExecMode {
		case structs.ProxyExecModeDaemon:
			proxy.Command = a.config.ConnectProxyDefaultDaemonCommand

		case structs.ProxyExecModeScript:
			proxy.Command = a.config.ConnectProxyDefaultScriptCommand
		}
	}

	// If there is no globally configured default we need to get the
	// default command so we can do "consul connect proxy"
	if len(proxy.Command) == 0 {
		command, err := defaultProxyCommand(a.config)
		if err != nil {
			return err
		}

		proxy.Command = command
	}

	return nil
}
158378
func getDefaultOpts(header http.Header, copySource bool, metadata map[string]string) (opts ObjectOptions, err error) {
	var clientKey [32]byte
	var sse encrypt.ServerSide

	if copySource {
		if crypto.SSECopy.IsRequested(header) {
			clientKey, err = crypto.SSECopy.ParseHTTP(header)
			if err != nil {
				return
			}
			if sse, err = encrypt.NewSSEC(clientKey[:]); err != nil {
				return
			}
			return ObjectOptions{ServerSideEncryption: encrypt.SSECopy(sse), UserDefined: metadata}, nil
		}
		return
	}

	if crypto.SSEC.IsRequested(header) {
		clientKey, err = crypto.SSEC.ParseHTTP(header)
		if err != nil {
			return
		}
		if sse, err = encrypt.NewSSEC(clientKey[:]); err != nil {
			return
		}
		return ObjectOptions{ServerSideEncryption: sse, UserDefined: metadata}, nil
	}
	if crypto.S3.IsRequested(header) || (metadata != nil && crypto.S3.IsEncrypted(metadata)) {
		return ObjectOptions{ServerSideEncryption: encrypt.NewSSE(), UserDefined: metadata}, nil
	}
	return ObjectOptions{UserDefined: metadata}, nil
}
1255284
func (c *Client) applyOptions(opts ...ClientOption) error {
	for _, f := range opts {
		if err := f(c); err != nil {
			return err
		}
	}
	return nil
}
209826
func (l *Logger) SetDefaults(d map[string]interface{}) error {
	for key := range d {
		if !IsValidKey(key) {
			return ErrInvalidKey
		}
	}

	l.defaults.Store(d)
	return nil
}
359036
func (s *EncryptionAlgorithmOptions) SetDefaultValue(v string) *EncryptionAlgorithmOptions {
	s.DefaultValue = &v
	return s
}
1063441
func DefaultOptions() EncoderOptions {
	opt := EncoderOptions{}
	opt.Eol = "\n"
	opt.BracesSameLine = false
	opt.EmitRootBraces = true
	opt.QuoteAlways = false
	opt.IndentBy = "  "
	opt.AllowMinusZero = false
	opt.UnknownAsNull = false
	return opt
}
78784
func (s *DoubleOptions) SetDefaultValue(v float64) *DoubleOptions {
	s.DefaultValue = &v
	return s
}
803287
func (s *PolicyAttributeTypeDescription) SetDefaultValue(v string) *PolicyAttributeTypeDescription {
	s.DefaultValue = &v
	return s
}
736307
func (qo *queryOptions) applyQueryOptions(options ...QueryOption) {
	for _, option := range options {
		option(qo)
	}
}
707968
func (w *Waiter) ApplyOptions(opts ...WaiterOption) {
	for _, fn := range opts {
		fn(w)
	}
}
935976
func SetDefaultString(in string) stringRuleOpt {
	return func(i *rpc.StringRule) {
		i.Default = in
		i.HasDefault = true
	}
}
1027268
func applyOptions(opts ...Option) options {
	options := options{
		logger: zap.NewNop(),
		tmpl:   _defaultTmpl,
	}
	for _, opt := range opts {
		opt.apply(&options)
	}
	return options
}
543409
func (c Config) applyDefaults(cp ConfigPolicy) {
	for key, val := range cp.getDefaults() {
		if _, exist := c[key]; !exist {
			// set default cfg retrieve from config policy
			c[key] = val
		}
	}
}
1303814
func (s *UpdateStackInput) SetDefaultOs(v string) *UpdateStackInput {
	s.DefaultOs = &v
	return s
}
862930
func (s *OptionSetting) SetDefaultValue(v string) *OptionSetting {
	s.DefaultValue = &v
	return s
}
831708
func (c *compilerContext) setDefaults(positive, negative, policy string) {
	if positive == "" || negative == "" || policy == "" {
		panic("The defaults should never be empty. This is a programmer error.")
	}

	c.defaultPositive = positive
	c.defaultNegative = negative
	c.defaultPolicy = policy
}