// init local config
519876
func (c *Conf) initConfig() {
	if c.Exist() {
		return
	}

	err := os.MkdirAll(c.dirPath, 0755)
	if err != nil {
		panic(err)
	}

	_, err = os.Create(c.Path())
	if err != nil {
		panic(err)
	}

	bc := map[string]string{
		"init": "true",
	}
	b, err := json.Marshal(bc)
	if err != nil {
		panic(err)
	}

	err = ioutil.WriteFile(c.Path(), b, 0666)
	if err != nil {
		panic(err)
	}
}
626840
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
	c := driverapi.Capability{
		DataScope:         datastore.LocalScope,
		ConnectivityScope: datastore.GlobalScope,
	}
	d := &driver{
		networks: networkTable{},
	}
	d.initStore(config)

	return dc.RegisterDriver(ipvlanType, d, c)
}
464487
func (d *ConsulStateDriver) Init(instInfo *core.InstanceInfo) error {
	var err error
	var endpoint *url.URL

	if instInfo == nil || instInfo.DbURL == "" {
		return errors.New("no consul config found")
	}
	endpoint, err = url.Parse(instInfo.DbURL)
	if err != nil {
		return err
	}
	if endpoint.Scheme == "consul" {
		endpoint.Scheme = "http"
	} else if endpoint.Scheme != "http" && endpoint.Scheme != "https" {
		return fmt.Errorf("invalid consul URL scheme %q", endpoint.Scheme)
	}
	cfg := api.Config{
		Address: endpoint.Host,
	}

	d.Client, err = api.NewClient(&cfg)

	return err
}
238799
func (d *driver) Init(ctx types.Context, config gofig.Config) error {
	d.config = config

	fields := log.Fields{}

	d.accessKey = d.getAccessKey()
	fields["accessKey"] = d.accessKey

	d.tag = d.getTag()
	fields["tag"] = d.tag

	d.secGroups = d.getSecurityGroups()
	fields["securityGroups"] = d.secGroups

	d.disableSessionCache = d.getDisableSessionCache()
	fields["disableSessionCache"] = d.disableSessionCache

	if v := d.getRegion(); v != "" {
		d.region = &v
		fields["region"] = v
	}
	if v := d.getEndpoint(); v != "" {
		d.endpoint = &v
		fields["endpoint"] = v
	}
	d.endpointFormat = d.getEndpointFormat()
	fields["endpointFormat"] = d.endpointFormat
	maxRetries := d.getMaxRetries()
	d.maxRetries = &maxRetries
	fields["maxRetries"] = maxRetries

	d.maxAttempts = d.config.GetInt(efs.ConfigStatusMaxAttempts)
	fields["maxStatusAttempts"] = d.maxAttempts

	statusDelayStr := d.config.GetString(efs.ConfigStatusInitDelay)
	statusDelay, err := time.ParseDuration(statusDelayStr)
	if err != nil {
		return err
	}
	d.statusDelay = statusDelay.Nanoseconds()
	fields["statusDelay"] = fmt.Sprintf(
		"%v", time.Duration(d.statusDelay)*time.Nanosecond)

	statusTimeoutStr := d.config.GetString(efs.ConfigStatusTimeout)
	d.statusTimeout, err = time.ParseDuration(statusTimeoutStr)
	if err != nil {
		return err
	}
	fields["statusTimeout"] = d.statusTimeout

	ctx.WithFields(fields).Info("storage driver initialized")
	return nil
}
1092683
func (plugin *ExamplePlugin) Init() (err error) {
	plugin.Log.Info("Loading plugin config ", plugin.PluginConfig.GetConfigName())

	if plugin.Conf == nil {
		plugin.Conf = &Conf{Field1: "some default value"}
	}

	found, err := plugin.PluginConfig.LoadValue(plugin.Conf)
	if err != nil {
		plugin.Log.Error("Error loading config", err)
	} else if found {
		plugin.Log.Info("Loaded plugin config - found external configuration ", plugin.PluginConfig.GetConfigName())
	} else {
		plugin.Log.Info("Loaded plugin config - default")
	}
	plugin.Log.Info("Plugin Config ", plugin.Conf)

	time.Sleep(plugin.Conf.Sleep)
	close(plugin.exampleFinished)

	return nil
}
1290285
func (d *driver) Init(context types.Context, config gofig.Config) error {
	d.config = config

	d.keyFile = d.config.GetString(gcepd.ConfigKeyfile)
	if d.keyFile != "" {
		if !gotil.FileExists(d.keyFile) {
			return goof.Newf("keyfile at %s does not exist", d.keyFile)
		}
		pID, err := d.extractProjectID()
		if err != nil || pID == nil || *pID == "" {
			return goof.New("Unable to set project ID from keyfile")
		}
		d.projectID = pID
		context.Info("Will authenticate using local JSON credentials")
	} else {
		// We are using application default credentials
		defCreds, err := google.FindDefaultCredentials(
			context, compute.ComputeScope)
		if err != nil {
			return goof.WithError(
				"Unable to get application default credentials",
				err)
		}
		d.projectID = &defCreds.ProjectID
		if *d.projectID == "" {
			return goof.New(
				"Unable to get project ID from default creds")
		}
		d.tokenSource = defCreds.TokenSource
		context.Info("Will authenticate using app default credentials")
	}

	d.zone = d.config.GetString(gcepd.ConfigZone)
	if d.zone != "" {
		context.Infof("All access is restricted to zone: %s", d.zone)
	}

	d.defaultDiskType = config.GetString(gcepd.ConfigDefaultDiskType)

	switch d.defaultDiskType {
	case gcepd.DiskTypeSSD, gcepd.DiskTypeStandard:
		// noop
	case "":
		d.defaultDiskType = gcepd.DefaultDiskType
	default:
		return goof.Newf(
			"Invalid GCE disk type: %s", d.defaultDiskType)
	}

	d.tag = config.GetString(gcepd.ConfigTag)
	if d.tag != "" && !tagRegex.MatchString(d.tag) {
		return goof.New("Invalid GCE tag format")
	}

	d.maxAttempts = d.config.GetInt(gcepd.ConfigStatusMaxAttempts)

	statusDelayStr := d.config.GetString(gcepd.ConfigStatusInitDelay)
	statusDelay, err := time.ParseDuration(statusDelayStr)
	if err != nil {
		return err
	}
	d.statusDelay = statusDelay.Nanoseconds()

	statusTimeoutStr := d.config.GetString(gcepd.ConfigStatusTimeout)
	d.statusTimeout, err = time.ParseDuration(statusTimeoutStr)
	if err != nil {
		return err
	}

	d.convUnderscore = d.config.GetBool(gcepd.ConfigConvertUnderscores)

	context.Info("storage driver initialized")
	return nil
}
201560
func (p *Plugin) Init() (err error) {
	if p.session != nil {
		return nil // skip initialization
	}

	// Retrieve config
	var cfg Config
	found, err := p.Cfg.LoadValue(&cfg)
	// need to be strict about config presence for ETCD
	if !found {
		p.Log.Info("cassandra client config not found ", p.Cfg.GetConfigName(),
			" - skip loading this plugin")
		return nil
	}
	if err != nil {
		return err
	}

	// Init session
	p.clientConfig, err = ConfigToClientConfig(&cfg)
	if err != nil {
		return err
	}

	if p.session == nil && p.clientConfig != nil {
		session, err := CreateSessionFromConfig(p.clientConfig)
		if err != nil {
			return err
		}

		p.session = gockle.NewSession(session)
	}

	return nil
}
759667
func (p *NetPlugin) Init(pluginConfig Config) error {
	var err error
	if pluginConfig.Instance.HostLabel == "" {
		return core.Errorf("empty host-label passed")
	}

	// initialize state driver
	p.StateDriver, err = utils.GetStateDriver()
	if err != nil {
		p.StateDriver, err = utils.NewStateDriver(pluginConfig.Drivers.State, &pluginConfig.Instance)
		if err != nil {
			return err
		}
	}
	defer func() {
		if err != nil {
			utils.ReleaseStateDriver()
		}
	}()

	// set state driver in instance info
	pluginConfig.Instance.StateDriver = p.StateDriver
	err = InitGlobalSettings(p.StateDriver, &pluginConfig.Instance)
	if err != nil {
		return err
	}

	// initialize network driver
	p.NetworkDriver, err = utils.NewNetworkDriver(pluginConfig.Drivers.Network, &pluginConfig.Instance)
	if err != nil {
		return err
	}
	p.PluginConfig = pluginConfig

	defer func() {
		if err != nil {
			p.NetworkDriver.Deinit()
		}
	}()

	return nil
}
840460
func (m *Module) Init(c *service.Config) {
	c.Setup = func() error {
		m.HTTPRouter = httprouter.New()
		m.ErrorHandler = func(rw http.ResponseWriter, req *http.Request, err error) {
			_ = m.HandleError(rw, req, err)
		}
		m.ErrorPage = func(rw http.ResponseWriter, req *http.Request, status int) {
			http.Error(rw, fmt.Sprint(status), status)
		}

		// root handler
		m.Root = http.NewServeMux()
		m.Root.Handle("/", m.HTTPRouter)
		m.Middleware = middleware.NewServer(m.Root.ServeHTTP)
		m.Config.ReadConfig(&m.config)
		return nil
	}

	c.Start = func() {
		laddr := m.laddr()
		m.Logger.Infof("listening on %s", laddr)
		m.server = &http.Server{Addr: laddr, Handler: m.Middleware}
		go m.server.ListenAndServe()
	}

	c.Stop = func() {
		m.Shutdown(context.Background())
	}
}
1010817
func (c *configCommand) Init(args []string) error {
	if len(args) == 0 || len(strings.Split(args[0], "=")) > 1 {
		return errors.New("no application name specified")
	}

	if err := c.validateGeneration(); err != nil {
		return errors.Trace(err)
	}

	// If there are arguments provided to reset, we turn it into a slice of
	// strings and verify them. If there is one or more valid keys to reset and
	// no other errors initializing the command, c.resetDefaults will be called
	// in c.Run.
	if err := c.parseResetKeys(); err != nil {
		return errors.Trace(err)
	}

	c.applicationName = args[0]
	args = args[1:]

	switch len(args) {
	case 0:
		return c.handleZeroArgs()
	case 1:
		return c.handleOneArg(args)
	default:
		return c.handleArgs(args)
	}
}
189163
func (m *Module) Init(c *service.Config) {
	c.Start = func() {
		for _, p := range m.oauthConfigs {
			m.register(p)
		}
	}
}
688542
func Init(filepath string, section string) (Config, error) {
	if section == "" {
		section = defaultSection
	} else {
		section = strings.ToUpper(section)
	}

	_, exists := os.LookupEnv("AKAMAI_" + section + "_HOST")
	if !exists && section == defaultSection {
		_, exists := os.LookupEnv("AKAMAI_HOST")

		if exists {
			return InitEnv("")
		}
	}

	if exists {
		return InitEnv(section)
	}

	c, err := InitEdgeRc(filepath, strings.ToLower(section))

	if err == nil {
		return c, nil
	}

	if section != defaultSection {
		_, ok := os.LookupEnv("AKAMAI_HOST")
		if ok {
			return InitEnv("")
		}
	}

	return c, fmt.Errorf("Unable to create instance using environment or .edgerc file")
}
244295
func (c *kregistry) Init(opts ...registry.Option) error {
	return configure(c, opts...)
}
329818
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
	d := newDriver()
	if err := d.configure(config); err != nil {
		return err
	}

	c := driverapi.Capability{
		DataScope:         datastore.LocalScope,
		ConnectivityScope: datastore.LocalScope,
	}
	return dc.RegisterDriver(networkType, d, c)
}
1317301
func (c *ConsoleWriter) Init(config map[string]interface{}) error {
	if config == nil {
		return nil
	}
	if l, ok := config["level"]; ok {
		if l2, ok2 := l.(int); ok2 {
			c.Level = l2
		} else {
			return errors.New("consloe config-level's type is incorrect!")
		}
	}
	if w, ok := config["writer"]; ok {
		if w2, ok2 := w.(io.Writer); ok2 {
			c.lg = log.New(w2, "", log.LstdFlags)
		}
	}
	return nil
}
1335363
func (c *Client) init() error {
	c.HTTPClient = cleanhttp.DefaultClient()
	tlsConfig := &tls.Config{}
	if os.Getenv(atlasTLSNoVerifyEnvVar) != "" {
		tlsConfig.InsecureSkipVerify = true
	}
	err := rootcerts.ConfigureTLS(tlsConfig, &rootcerts.Config{
		CAFile: os.Getenv(atlasCAFileEnvVar),
		CAPath: os.Getenv(atlasCAPathEnvVar),
	})
	if err != nil {
		return err
	}
	t := cleanhttp.DefaultTransport()
	t.TLSClientConfig = tlsConfig
	c.HTTPClient.Transport = t
	return nil
}
706820
func (p *Parser) Init(options interface{}) error {
	p.conf = *options.(*Options)
	lineParser, err := NewSyslogLineParser(p.conf.Mode, p.conf.ProcessList)
	if err != nil {
		return err
	}
	p.lineParser = lineParser
	return nil
}