// NewDefaultMasterArgs creates MasterArgs with sub-objects created and default values set.
768955
func NewDefaultMasterArgs() *MasterArgs {
	config := &MasterArgs{
		MasterAddr:       flagtypes.Addr{Value: "localhost:8443", DefaultScheme: "https", DefaultPort: 8443, AllowPrefix: true}.Default(),
		EtcdAddr:         flagtypes.Addr{Value: "0.0.0.0:4001", DefaultScheme: "https", DefaultPort: 4001}.Default(),
		MasterPublicAddr: flagtypes.Addr{Value: "localhost:8443", DefaultScheme: "https", DefaultPort: 8443, AllowPrefix: true}.Default(),
		DNSBindAddr:      flagtypes.Addr{Value: "0.0.0.0:8053", DefaultScheme: "tcp", DefaultPort: 8053, AllowPrefix: true}.Default(),

		ConfigDir: &flag.StringFlag{},

		ListenArg:          options.NewDefaultListenArg(),
		ImageFormatArgs:    options.NewDefaultImageFormatArgs(),
		KubeConnectionArgs: options.NewDefaultKubeConnectionArgs(),
		NetworkArgs:        options.NewDefaultMasterNetworkArgs(),
	}

	return config
}
618964
func NewArgs(initialArgs ...KeyValuePair) Args {
	args := Args{fields: map[string]map[string]bool{}}
	for _, arg := range initialArgs {
		args.Add(arg.Key, arg.Value)
	}
	return args
}
829871
func NewDefaultConfig() *Config {
	return &Config{
		BaseURL:            env.GetOrDefaultString(baseURLEnvVar, defaultBaseURL),
		TTL:                env.GetOrDefaultInt(ttlEnvVar, minTTL),
		PropagationTimeout: env.GetOrDefaultSecond(propagationTimeoutEnvVar, 120*time.Second),
		PollingInterval:    env.GetOrDefaultSecond(pollingIntervalEnvVar, 2*time.Second),
		HTTPClient: &http.Client{
			Timeout: env.GetOrDefaultSecond(httpTimeoutEnvVar, 30*time.Second),
		},
	}
}
913366
func setDefaultHermesValues(h *Hermes) error {
	defaultTextDirection := TDLeftToRight
	defaultHermes := Hermes{
		Theme:         new(Default),
		TextDirection: defaultTextDirection,
		Product: Product{
			Name:        "Hermes",
			Copyright:   "Copyright © 2019 Hermes. All rights reserved.",
			TroubleText: "If you’re having trouble with the button '{ACTION}', copy and paste the URL below into your web browser.",
		},
	}
	// Merge the given hermes engine configuration with default one
	// Default one overrides all zero values
	err := mergo.Merge(h, defaultHermes)
	if err != nil {
		return err
	}
	if h.TextDirection != TDLeftToRight && h.TextDirection != TDRightToLeft {
		h.TextDirection = defaultTextDirection
	}
	return nil
}
105829
func NewCreateTargetArgs(url string) *CreateTargetArgs {
	args := new(CreateTargetArgs)
	args.URL = url
	return args
}
1128372
func NewDefaultArgs() *ArgType {
	fkMode := FkModeSmart

	return &ArgType{
		Suffix:              ".xo.go",
		Int32Type:           "int",
		Uint32Type:          "uint",
		ForeignKeyMode:      &fkMode,
		QueryParamDelimiter: "%%",
		NameConflictSuffix:  "Val",

		// KnownTypeMap is the collection of known Go types.
		KnownTypeMap: map[string]bool{
			"bool":        true,
			"string":      true,
			"byte":        true,
			"rune":        true,
			"int":         true,
			"int16":       true,
			"int32":       true,
			"int64":       true,
			"uint":        true,
			"uint8":       true,
			"uint16":      true,
			"uint32":      true,
			"uint64":      true,
			"float32":     true,
			"float64":     true,
			"Slice":       true,
			"StringSlice": true,
		},

		// ShortNameTypeMap is the collection of Go style short names for types, mainly
		// used for use with declaring a func receiver on a type.
		ShortNameTypeMap: map[string]string{
			"bool":        "b",
			"string":      "s",
			"byte":        "b",
			"rune":        "r",
			"int":         "i",
			"int16":       "i",
			"int32":       "i",
			"int64":       "i",
			"uint":        "u",
			"uint8":       "u",
			"uint16":      "u",
			"uint32":      "u",
			"uint64":      "u",
			"float32":     "f",
			"float64":     "f",
			"Slice":       "s",
			"StringSlice": "ss",
		},
	}
}
292204
func (args MasterArgs) BuildSerializeableMasterConfig() (*configapi.MasterConfig, error) {
	masterPublicAddr, err := args.GetMasterPublicAddress()
	if err != nil {
		return nil, err
	}
	assetPublicAddr, err := args.GetAssetPublicAddress()
	if err != nil {
		return nil, err
	}
	dnsBindAddr, err := args.GetDNSBindAddress()
	if err != nil {
		return nil, err
	}

	listenServingInfo := servingInfoForAddr(&args.ListenArg.ListenAddr)

	// always include the all-in-one server's web console as an allowed CORS origin
	// always include localhost as an allowed CORS origin
	// always include master public address as an allowed CORS origin
	corsAllowedOrigins := sets.NewString(args.CORSAllowedOrigins...)
	corsAllowedOrigins.Insert(
		makeHostMatchRegex(assetPublicAddr.Host),
		makeHostMatchRegex(masterPublicAddr.Host),
		makeHostMatchRegex("localhost"),
		makeHostMatchRegex("127.0.0.1"),
	)

	etcdAddress, err := args.GetEtcdAddress()
	if err != nil {
		return nil, err
	}

	builtInEtcd := !args.EtcdAddr.Provided
	var etcdConfig *configapi.EtcdConfig
	if builtInEtcd {
		etcdConfig, err = args.BuildSerializeableEtcdConfig()
		if err != nil {
			return nil, err
		}
	}

	kubernetesMasterConfig, err := args.BuildSerializeableKubeMasterConfig()
	if err != nil {
		return nil, err
	}

	oauthConfig, err := args.BuildSerializeableOAuthConfig()
	if err != nil {
		return nil, err
	}

	kubeletClientInfo := admin.DefaultMasterKubeletClientCertInfo(args.ConfigDir.Value())

	etcdClientInfo := admin.DefaultMasterEtcdClientCertInfo(args.ConfigDir.Value())

	dnsServingInfo := servingInfoForAddr(&dnsBindAddr)

	config := &configapi.MasterConfig{
		ServingInfo: configapi.HTTPServingInfo{
			ServingInfo: listenServingInfo,
		},
		CORSAllowedOrigins: corsAllowedOrigins.List(),
		MasterPublicURL:    masterPublicAddr.String(),

		KubernetesMasterConfig: *kubernetesMasterConfig,
		EtcdConfig:             etcdConfig,

		AuthConfig: configapi.MasterAuthConfig{
			RequestHeader: &configapi.RequestHeaderAuthenticationOptions{
				ClientCA:            admin.DefaultCertFilename(args.ConfigDir.Value(), admin.FrontProxyCAFilePrefix),
				ClientCommonNames:   []string{bootstrappolicy.AggregatorUsername},
				UsernameHeaders:     []string{"X-Remote-User"},
				GroupHeaders:        []string{"X-Remote-Group"},
				ExtraHeaderPrefixes: []string{"X-Remote-Extra-"}},
		},

		AggregatorConfig: configapi.AggregatorConfig{
			ProxyClientInfo: admin.DefaultAggregatorClientCertInfo(args.ConfigDir.Value()).CertLocation,
		},

		OAuthConfig: oauthConfig,

		DNSConfig: &configapi.DNSConfig{
			BindAddress: dnsServingInfo.BindAddress,
			BindNetwork: dnsServingInfo.BindNetwork,

			AllowRecursiveQueries: true,
		},

		MasterClients: configapi.MasterClients{
			OpenShiftLoopbackKubeConfig: admin.DefaultKubeConfigFilename(args.ConfigDir.Value(), bootstrappolicy.MasterUnqualifiedUsername),
		},

		EtcdClientInfo: configapi.EtcdConnectionInfo{
			URLs: []string{etcdAddress.String()},
		},

		KubeletClientInfo: configapi.KubeletConnectionInfo{
			Port: ports.KubeletPort,
		},

		ImageConfig: configapi.ImageConfig{
			Format: args.ImageFormatArgs.ImageTemplate.Format,
			Latest: args.ImageFormatArgs.ImageTemplate.Latest,
		},

		ImagePolicyConfig: configapi.ImagePolicyConfig{},

		ProjectConfig: configapi.ProjectConfig{
			DefaultNodeSelector:    "",
			ProjectRequestMessage:  "",
			ProjectRequestTemplate: "",

			// Allocator defaults on
			SecurityAllocator: &configapi.SecurityAllocator{},
		},

		NetworkConfig: configapi.MasterNetworkConfig{
			NetworkPluginName: args.NetworkArgs.NetworkPluginName,
			ClusterNetworks: []configapi.ClusterNetworkEntry{
				{
					CIDR:             args.NetworkArgs.ClusterNetworkCIDR,
					HostSubnetLength: args.NetworkArgs.HostSubnetLength,
				},
			},
			ServiceNetworkCIDR: args.NetworkArgs.ServiceNetworkCIDR,
		},

		VolumeConfig: configapi.MasterVolumeConfig{
			DynamicProvisioningEnabled: true,
		},

		ControllerConfig: configapi.ControllerConfig{
			ServiceServingCert: configapi.ServiceServingCert{
				Signer: &configapi.CertInfo{},
			},
		},
	}

	config.ServingInfo.ServerCert = admin.DefaultMasterServingCertInfo(args.ConfigDir.Value())
	config.ServingInfo.ClientCA = admin.DefaultAPIClientCAFile(args.ConfigDir.Value())

	if oauthConfig != nil {
		s := admin.DefaultCABundleFile(args.ConfigDir.Value())
		oauthConfig.MasterCA = &s
	}

	config.KubeletClientInfo.CA = admin.DefaultRootCAFile(args.ConfigDir.Value())
	config.KubeletClientInfo.ClientCert = kubeletClientInfo.CertLocation
	config.ServiceAccountConfig.MasterCA = admin.DefaultCABundleFile(args.ConfigDir.Value())

	// Only set up ca/cert info for etcd connections if we're self-hosting etcd
	if builtInEtcd {
		config.EtcdClientInfo.CA = admin.DefaultRootCAFile(args.ConfigDir.Value())
		config.EtcdClientInfo.ClientCert = etcdClientInfo.CertLocation
	}

	// We're responsible for generating all the managed service accounts
	config.ServiceAccountConfig.ManagedNames = []string{
		bootstrappolicy.DefaultServiceAccountName,
		bootstrappolicy.BuilderServiceAccountName,
		bootstrappolicy.DeployerServiceAccountName,
	}
	// We also need the private key file to give to the token generator
	config.ServiceAccountConfig.PrivateKeyFile = admin.DefaultServiceAccountPrivateKeyFile(args.ConfigDir.Value())
	// We also need the public key file to give to the authenticator
	config.ServiceAccountConfig.PublicKeyFiles = []string{
		admin.DefaultServiceAccountPublicKeyFile(args.ConfigDir.Value()),
	}

	internal, err := applyDefaults(config, legacyconfigv1.LegacySchemeGroupVersion)
	if err != nil {
		return nil, err
	}
	config = internal.(*configapi.MasterConfig)

	// When creating a new config, use Protobuf
	configapi.SetProtobufClientDefaults(config.MasterClients.OpenShiftLoopbackClientConnectionOverrides)

	return config, nil
}
816348
func addDefaultHelpSubcommands(commands []cli.Command) {
	for i := range commands {
		cmd := &commands[i]
		if cmd.Subcommands != nil {
			cmd.Subcommands = append(cmd.Subcommands, defaultSubcommandHelp)
			addDefaultHelpSubcommands(cmd.Subcommands)
		}
	}
}
133306
func NewDefaultSma() (indicator *Sma, err error) {
	timePeriod := 10
	return NewSma(timePeriod, gotrade.UseClosePrice)
}
678538
func NewDefaultWrapper(message string) Wrapper {
	spinner := NewDefaultSpinner(message)
	interactiveMode := OutputDeviceIsTerminal()
	return NewWrapper(spinner, interactiveMode)
}
1143720
func NewDefaultManager(network, address string, logger log.Logger) *Manager {
	return NewManager(net.Dial, network, address, time.After, logger)
}
1159091
func buildDefaultMessage(t reflect.Type) (dm defaultMessage) {
	sprop := GetProperties(t)
	for _, prop := range sprop.Prop {
		fi, ok := sprop.decoderTags.get(prop.Tag)
		if !ok {
			// XXX_unrecognized
			continue
		}
		ft := t.Field(fi).Type

		sf, nested, err := fieldDefault(ft, prop)
		switch {
		case err != nil:
			log.Print(err)
		case nested:
			dm.nested = append(dm.nested, fi)
		case sf != nil:
			sf.index = fi
			dm.scalars = append(dm.scalars, *sf)
		}
	}

	return dm
}
489127
func NewDefaultConfig() *Config {
	return &Config{
		TTL:                env.GetOrDefaultInt("VULTR_TTL", dns01.DefaultTTL),
		PropagationTimeout: env.GetOrDefaultSecond("VULTR_PROPAGATION_TIMEOUT", dns01.DefaultPropagationTimeout),
		PollingInterval:    env.GetOrDefaultSecond("VULTR_POLLING_INTERVAL", dns01.DefaultPollingInterval),
		HTTPClient: &http.Client{
			Timeout: env.GetOrDefaultSecond("VULTR_HTTP_TIMEOUT", 0),
			// from Vultr Client
			Transport: &http.Transport{
				TLSNextProto: make(map[string]func(string, *tls.Conn) http.RoundTripper),
			},
		},
	}
}
312924
func NewDefaultClientConfigLoadingRules() *ClientConfigLoadingRules {
	chain := []string{}

	envVarFiles := os.Getenv(RecommendedConfigPathEnvVar)
	if len(envVarFiles) != 0 {
		fileList := filepath.SplitList(envVarFiles)
		// prevent the same path load multiple times
		chain = append(chain, deduplicate(fileList)...)

	} else {
		chain = append(chain, RecommendedHomeFile)
	}

	return &ClientConfigLoadingRules{
		Precedence:     chain,
		MigrationRules: currentMigrationRules(),
	}
}
1322507
func NewDefaultFactory(opts Options) (Factory, error) {
	client, err := Create(opts)
	if err != nil {
		return nil, err
	}

	return &defaultFactory{
		client: client,
	}, nil
}
228256
func (a *ArgClause) Default(values ...string) *ArgClause {
	a.defaultValues = values
	return a
}
452094
func NewDefaultIDGenerator() *IDGenerator {
	globalmachineID.RLock()
	defer globalmachineID.RUnlock()
	if globalmachineID.set {
		return NewIDGenerator(WithMachineID(globalmachineID.id))
	}
	return NewIDGenerator()
}