// Init makes sure a remote driver is registered when a network driver
// plugin is activated.
491992
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
	newPluginHandler := func(name string, client *plugins.Client) {
		// negotiate driver capability with client
		d := newDriver(name, client)
		c, err := d.(*driver).getCapabilities()
		if err != nil {
			logrus.Errorf("error getting capability for %s due to %v", name, err)
			return
		}
		if err = dc.RegisterDriver(name, d, *c); err != nil {
			logrus.Errorf("error registering driver for %s due to %v", name, err)
		}
	}

	// Unit test code is unaware of a true PluginStore. So we fall back to v1 plugins.
	handleFunc := plugins.Handle
	if pg := dc.GetPluginGetter(); pg != nil {
		handleFunc = pg.Handle
		activePlugins := pg.GetAllManagedPluginsByCap(driverapi.NetworkPluginEndpointType)
		for _, ap := range activePlugins {
			client, err := getPluginClient(ap)
			if err != nil {
				return err
			}
			newPluginHandler(ap.Name(), client)
		}
	}
	handleFunc(driverapi.NetworkPluginEndpointType, newPluginHandler)

	return nil
}
544668
func (p *Plugin) Init() error {
	// Read fileDB configuration file
	var err error
	p.config, err = p.getFileDBConfig()
	if err != nil || p.disabled {
		return err
	}

	// Register decoders
	decoders := []decoder.API{decoder.NewJSONDecoder(), decoder.NewYAMLDecoder()}
	if p.client, err = NewClient(p.config.ConfigPaths, p.config.StatusPath, decoders, filesystem.NewFsHandler(), p.Log); err != nil {
		return err
	}

	p.protoWrapper = kvproto.NewProtoWrapper(p.client, &keyval.SerializerJSON{})

	return nil
}
48206
func (r *RemoteStatus) Init(ctx context.Context, log logger.Logger, config libkbfs.Config, rs RemoteStatusUpdater) {
	r.failingServices = map[string]error{}
	r.callbacks = rs
	// A time in the far past that is not IsZero
	r.failingSince.Add(time.Second)
	go r.loop(ctx, log, config)
}
956397
func (c *ConnWriter) Init(config map[string]interface{}) error {
	conf, err := json.Marshal(config)
	if err != nil {
		return err
	}
	return json.Unmarshal(conf, c)
}
794623
func (p *Plugin) Init() error {
	if p.Cfg != nil {
		if p.Config == nil {
			p.Config = NewConf()
		}

		_, err := p.Cfg.LoadValue(p.Config)
		if err != nil {
			return err
		}
		p.Log.Debugf("logs config: %+v", p.Config)

		// Handle default log level. Prefer value from environmental variable
		defaultLogLvl := os.Getenv("INITIAL_LOGLVL")
		if defaultLogLvl == "" {
			defaultLogLvl = p.Config.DefaultLevel
		}
		if defaultLogLvl != "" {
			if err := p.LogRegistry.SetLevel("default", defaultLogLvl); err != nil {
				p.Log.Warnf("setting default log level failed: %v", err)
			} else {
				// All loggers created up to this point were created with initial log level set (defined
				// via INITIAL_LOGLVL env. variable with value 'info' by default), so at first, let's set default
				// log level for all of them.
				for loggerName := range p.LogRegistry.ListLoggers() {
					logger, exists := p.LogRegistry.Lookup(loggerName)
					if !exists {
						continue
					}
					logger.SetLevel(logging.ParseLogLevel(defaultLogLvl))
				}
			}
		}

		// Handle config file log levels
		for _, logCfgEntry := range p.Config.Loggers {
			// Put log/level entries from configuration file to the registry.
			if err := p.LogRegistry.SetLevel(logCfgEntry.Name, logCfgEntry.Level); err != nil {
				// Intentionally just log warn & not propagate the error (it is minor thing to interrupt startup)
				p.Log.Warnf("setting log level %s for logger %s failed: %v",
					logCfgEntry.Level, logCfgEntry.Name, err)
			}
		}
		if len(p.Config.Hooks) > 0 {
			p.Log.Info("configuring log hooks")
			for hookName, hookConfig := range p.Config.Hooks {
				if err := p.addHook(hookName, hookConfig); err != nil {
					p.Log.Warnf("configuring log hook %s failed: %v", hookName, err)
				}
			}
		}
	}

	return nil
}
12533
func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (graphdriver.Driver, error) {
	deviceSet, err := NewDeviceSet(home, true, options, uidMaps, gidMaps)
	if err != nil {
		return nil, err
	}

	if err := mount.MakePrivate(home); err != nil {
		return nil, err
	}

	d := &Driver{
		DeviceSet: deviceSet,
		home:      home,
		uidMaps:   uidMaps,
		gidMaps:   gidMaps,
	}

	return graphdriver.NewNaiveDiffDriver(d, uidMaps, gidMaps), nil
}
1324003
func (p *Plugin) Init() error {
	p.registrations = make(map[string]*registration)
	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
}
799717
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
	var err error
	c := driverapi.Capability{
		DataScope:         datastore.GlobalScope,
		ConnectivityScope: datastore.GlobalScope,
	}

	d := &driver{
		networks: networkTable{},
		config:   config,
	}

	d.vxlanIdm, err = idm.New(nil, "vxlan-id", 0, vxlanIDEnd)
	if err != nil {
		return fmt.Errorf("failed to initialize vxlan id manager: %v", err)
	}

	return dc.RegisterDriver(networkType, d, c)
}
1222587
func init() {
	// Register the driver.
	notifier := &chainntnfs.NotifierDriver{
		NotifierType: notifierType,
		New:          createNewNotifier,
	}

	if err := chainntnfs.RegisterNotifier(notifier); err != nil {
		panic(fmt.Sprintf("failed to register notifier driver '%s': %v",
			notifierType, err))
	}
}
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
}
57084
func Init(params map[string]string) (volume.VolumeDriver, error) {
	return &driver{
		volume.IONotSupported,
		volume.BlockNotSupported,
		volume.SnapshotNotSupported,
		common.NewDefaultStoreEnumerator(Name, kvdb.Instance()),
		volume.StatsNotSupported,
		volume.CredsNotSupported,
		volume.CloudBackupNotSupported,
		volume.CloudMigrateNotSupported,
	}, nil
}
627929
func (engine *Engine) Init() {
	engine.RelTagIdentifier = `rel`
	engine.AliasTagIdentifier = `alias`
	engine.TLogger = NewTLogger(engine.logger)
}
825760
func Init(dc driverapi.DriverCallback, config map[string]interface{}) error {
	c := driverapi.Capability{
		DataScope:         datastore.GlobalScope,
		ConnectivityScope: datastore.GlobalScope,
	}

	d := &driver{
		networks: networkTable{},
		config:   config,
	}

	if data, ok := config[netlabel.GlobalKVClient]; ok {
		var err error
		dsc, ok := data.(discoverapi.DatastoreConfigData)
		if !ok {
			return types.InternalErrorf("incorrect data in datastore configuration: %v", data)
		}
		d.store, err = datastore.NewDataStoreFromConfig(dsc)
		if err != nil {
			return types.InternalErrorf("failed to initialize data store: %v", err)
		}
	}

	if data, ok := config[netlabel.LocalKVClient]; ok {
		var err error
		dsc, ok := data.(discoverapi.DatastoreConfigData)
		if !ok {
			return types.InternalErrorf("incorrect data in datastore configuration: %v", data)
		}
		d.localStore, err = datastore.NewDataStoreFromConfig(dsc)
		if err != nil {
			return types.InternalErrorf("failed to initialize local data store: %v", err)
		}
	}

	d.restoreHNSNetworks()

	return dc.RegisterDriver(networkType, d, c)
}
72589
func init() {
	// Register the driver.
	driver := &lnwallet.WalletDriver{
		WalletType: walletType,
		New:        createNewWallet,
		BackEnds:   chain.BackEnds,
	}

	if err := lnwallet.RegisterWallet(driver); err != nil {
		panic(fmt.Sprintf("failed to register wallet driver '%s': %v",
			walletType, err))
	}
}
999238
func (d *VppDriver) Init(info *core.InstanceInfo) error {
	log.Infof("Initializing vppdriver")

	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
}