當前位置: 首頁>>代碼示例>>Golang>>正文


Golang config.Config類代碼示例

本文整理匯總了Golang中github.com/docker/libnetwork/config.Config的典型用法代碼示例。如果您正苦於以下問題:Golang Config類的具體用法?Golang Config怎麽用?Golang Config使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Config類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: New

// New creates a new instance of network controller.
func New(cfgOptions ...config.Option) (NetworkController, error) {
	var cfg *config.Config
	if len(cfgOptions) > 0 {
		cfg = &config.Config{}
		cfg.ProcessOptions(cfgOptions...)
	}
	c := &controller{
		cfg:       cfg,
		networks:  networkTable{},
		sandboxes: sandboxTable{},
		drivers:   driverTable{}}
	if err := initDrivers(c); err != nil {
		return nil, err
	}

	if cfg != nil {
		if err := c.initDataStore(); err != nil {
			// Failing to initalize datastore is a bad situation to be in.
			// But it cannot fail creating the Controller
			log.Debugf("Failed to Initialize Datastore due to %v. Operating in non-clustered mode", err)
		}
		if err := c.initDiscovery(); err != nil {
			// Failing to initalize discovery is a bad situation to be in.
			// But it cannot fail creating the Controller
			log.Debugf("Failed to Initialize Discovery : %v", err)
		}
	}

	return c, nil
}
開發者ID:chenchun,項目名稱:libnetwork,代碼行數:31,代碼來源:controller.go

示例2: New

// New creates a new instance of network controller.
func New(cfgOptions ...config.Option) (NetworkController, error) {
	var cfg *config.Config
	if len(cfgOptions) > 0 {
		cfg = &config.Config{
			Daemon: config.DaemonCfg{
				DriverCfg: make(map[string]interface{}),
			},
		}
		cfg.ProcessOptions(cfgOptions...)
	}
	c := &controller{
		id:          stringid.GenerateRandomID(),
		cfg:         cfg,
		networks:    networkTable{},
		sandboxes:   sandboxTable{},
		drivers:     driverTable{},
		ipamDrivers: ipamTable{}}
	if err := initDrivers(c); err != nil {
		return nil, err
	}

	if cfg != nil {
		if err := c.initGlobalStore(); err != nil {
			// Failing to initalize datastore is a bad situation to be in.
			// But it cannot fail creating the Controller
			log.Debugf("Failed to Initialize Datastore due to %v. Operating in non-clustered mode", err)
		}
		if err := c.initLocalStore(); err != nil {
			log.Debugf("Failed to Initialize LocalDatastore due to %v.", err)
		}
	}

	if err := initIpams(c, c.localStore, c.globalStore); err != nil {
		return nil, err
	}

	if cfg != nil {
		if err := c.restoreFromGlobalStore(); err != nil {
			log.Debugf("Failed to restore from global Datastore due to %v", err)
		}
		if err := c.initDiscovery(cfg.Cluster.Watcher); err != nil {
			// Failing to initalize discovery is a bad situation to be in.
			// But it cannot fail creating the Controller
			log.Debugf("Failed to Initialize Discovery : %v", err)
		}
		if err := c.restoreFromLocalStore(); err != nil {
			log.Debugf("Failed to restore from local Datastore due to %v", err)
		}
	}

	if err := c.startExternalKeyListener(); err != nil {
		return nil, err
	}

	return c, nil
}
開發者ID:c0b,項目名稱:libnetwork,代碼行數:57,代碼來源:controller.go

示例3: New

// New creates a new instance of network controller.
func New(cfgOptions ...config.Option) (NetworkController, error) {
	var cfg *config.Config
	cfg = &config.Config{
		Daemon: config.DaemonCfg{
			DriverCfg: make(map[string]interface{}),
		},
		Scopes: make(map[string]*datastore.ScopeCfg),
	}

	if len(cfgOptions) > 0 {
		cfg.ProcessOptions(cfgOptions...)
	}
	cfg.LoadDefaultScopes(cfg.Daemon.DataDir)

	c := &controller{
		id:          stringid.GenerateRandomID(),
		cfg:         cfg,
		sandboxes:   sandboxTable{},
		drivers:     driverTable{},
		ipamDrivers: ipamTable{},
		svcDb:       make(map[string]svcMap),
	}

	if err := c.initStores(); err != nil {
		return nil, err
	}

	if cfg != nil && cfg.Cluster.Watcher != nil {
		if err := c.initDiscovery(cfg.Cluster.Watcher); err != nil {
			// Failing to initalize discovery is a bad situation to be in.
			// But it cannot fail creating the Controller
			log.Errorf("Failed to Initialize Discovery : %v", err)
		}
	}

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

	if err := initIpams(c, c.getStore(datastore.LocalScope),
		c.getStore(datastore.GlobalScope)); err != nil {
		return nil, err
	}

	c.sandboxCleanup()
	c.cleanupLocalEndpoints()

	if err := c.startExternalKeyListener(); err != nil {
		return nil, err
	}

	return c, nil
}
開發者ID:maaquib,項目名稱:docker,代碼行數:54,代碼來源:controller.go


注:本文中的github.com/docker/libnetwork/config.Config類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。