// applyDefaults updates config with defaults from config policy
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
		}
	}
}
596092
func (s *UpdateStageInput) SetDefaultRouteSettings(v *RouteSettings) *UpdateStageInput {
	s.DefaultRouteSettings = v
	return s
}
473342
func (s *Config) CheckAndSetDefaults() error {
	if s.Directory == "" {
		return trace.BadParameter("missing parameter Directory")
	}
	if !utils.IsDir(s.Directory) {
		return trace.BadParameter("path %q does not exist or is not a directory", s.Directory)
	}
	return nil
}
1219082
func (c *defaultsCommand) getDefaults(client defaultsCommandAPI, ctx *cmd.Context) error {
	cloudName := c.cloudName
	if client.BestAPIVersion() < 6 {
		cloudName = ""
	}
	attrs, err := client.ModelDefaults(cloudName)
	if err != nil {
		return err
	}

	valueForRegion := func(region string, regions []config.RegionDefaultValue) (config.RegionDefaultValue, bool) {
		for _, r := range regions {
			if r.Name == region {
				return r, true
			}
		}
		return config.RegionDefaultValue{}, false
	}

	// Filter by region if necessary.
	if c.regionName != "" {
		for attrName, attr := range attrs {
			if regionDefault, ok := valueForRegion(c.regionName, attr.Regions); !ok {
				delete(attrs, attrName)
			} else {
				attrForRegion := attr
				attrForRegion.Regions = []config.RegionDefaultValue{regionDefault}
				attrs[attrName] = attrForRegion
			}
		}
	}

	if c.key != "" {
		if value, ok := attrs[c.key]; ok {
			attrs = config.ModelDefaultAttributes{
				c.key: value,
			}
		} else {
			msg := fmt.Sprintf("there are no default model values for %q", c.key)
			if c.regionName != "" {
				msg += fmt.Sprintf(" in region %q", c.regionName)
			}
			return errors.New(msg)
		}
	}
	if c.regionName != "" && len(attrs) == 0 {
		return errors.New(fmt.Sprintf(
			"there are no default model values in region %q", c.regionName))
	}

	// If c.keys is empty, write out the whole lot.
	return c.out.Write(ctx, attrs)
}
642619
func Defaults(puts []config.Put) error {
	for i := range puts {
		defaults(&puts[i])
	}
	return nil
}
789364
func (c *Config) CheckAndSetDefaults() error {
	if c.FileSystem == nil {
		c.FileSystem = &localFileSystem{}
	}

	if c.User == "" {
		return trace.BadParameter("missing User parameter")
	}

	return nil
}
1281349
func (m *ModelManagerAPI) SetModelDefaults(args params.SetModelDefaults) (params.ErrorResults, error) {
	results := params.ErrorResults{Results: make([]params.ErrorResult, len(args.Config))}
	if err := m.check.ChangeAllowed(); err != nil {
		return results, errors.Trace(err)
	}
	for i, arg := range args.Config {
		results.Results[i].Error = common.ServerError(
			m.setModelDefaults(arg),
		)
	}
	return results, nil
}
499631
func NewDefault() (c *Config, err error) {
	c = &Config{}
	err = c.LoadDefaultConfig()
	if err != nil {
		c = nil
		return
	}
	return
}
434392
func (*Builder) WithDefaults(build config.Build) config.Build {
	if build.Main == "" {
		build.Main = "."
	}
	if len(build.Goos) == 0 {
		build.Goos = []string{"linux", "darwin"}
	}
	if len(build.Goarch) == 0 {
		build.Goarch = []string{"amd64", "386"}
	}
	if len(build.Goarm) == 0 {
		build.Goarm = []string{"6"}
	}
	if len(build.Ldflags) == 0 {
		build.Ldflags = []string{"-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}"}
	}
	if len(build.Targets) == 0 {
		build.Targets = matrix(build)
	}
	return build
}
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
}
51757
func (r *Route) SetDefaults() {
	if r.Memory == 0 {
		r.Memory = 128
	}

	if r.Type == TypeNone {
		r.Type = TypeSync
	}

	if r.Format == "" {
		r.Format = FormatDefault
	}

	if r.MaxConcurrency == 0 {
		r.MaxConcurrency = 1
	}

	if r.Headers == nil {
		r.Headers = http.Header{}
	}

	if r.Config == nil {
		r.Config = map[string]string{}
	}

	if r.Timeout == 0 {
		r.Timeout = defaultRouteTimeout
	}

	//if r.IdleTimeout == 0 {
	//	r.IdleTimeout = htfnScaleDownTimeout
	//}
}
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
}
211871
func SetupDefaultConfig(uidConfig *Config) *Config {

	defaultConfig := DefaultConfig()

	if uidConfig.ReleasePath == "" {
		uidConfig.ReleasePath = defaultConfig.ReleasePath
	}
	if uidConfig.StoredPath == "" {
		uidConfig.StoredPath = defaultConfig.StoredPath
	}
	if uidConfig.EventMetadataExtractor == nil {
		uidConfig.EventMetadataExtractor = defaultConfig.EventMetadataExtractor
	}

	return uidConfig
}
1189224
func allDefaults() schema.Defaults {
	d := schema.Defaults{}
	configDefaults := ConfigDefaults()
	for attr, val := range configDefaults {
		d[attr] = val
	}
	for attr, val := range alwaysOptional {
		if _, ok := d[attr]; !ok {
			d[attr] = val
		}
	}
	return d
}
450097
func (o *Config) defaults() *Config {
	if o.OutputDir == "" {
		o.OutputDir = "."
	}
	if o.InputFiles == nil {
		o.InputFiles = []string{"-"}
	}
	if o.OutputFiles == nil {
		o.OutputFiles = []string{"-"}
	}
	if o.LDelim == "" {
		o.LDelim = "{{"
	}
	if o.RDelim == "" {
		o.RDelim = "}}"
	}
	return o
}
865875
func NewDefaultConfig() (*Config, error) {
	c := newConfig()

	err := normalize(c)
	if err != nil {
		return nil, err
	}

	return c, nil
}
1303814
func (s *UpdateStackInput) SetDefaultOs(v string) *UpdateStackInput {
	s.DefaultOs = &v
	return s
}