本文整理匯總了Golang中github.com/docker/libnetwork/config.ParseConfig函數的典型用法代碼示例。如果您正苦於以下問題:Golang ParseConfig函數的具體用法?Golang ParseConfig怎麽用?Golang ParseConfig使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ParseConfig函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: parseConfig
func parseConfig(cfgFile string) (*config.Config, error) {
if strings.Trim(cfgFile, " ") == "" {
cfgFile = os.Getenv(cfgFileEnv)
if strings.Trim(cfgFile, " ") == "" {
cfgFile = defaultCfgFile
}
}
return config.ParseConfig(cfgFile)
}
示例2: parseConfig
func (d *dnetConnection) parseConfig(cfgFile string) (*config.Config, error) {
if strings.Trim(cfgFile, " ") == "" {
cfgFile = os.Getenv(cfgFileEnv)
if strings.Trim(cfgFile, " ") == "" {
cfgFile = defaultCfgFile
}
}
if err := d.parseOrchestrationConfig(cfgFile); err != nil {
return nil, err
}
return config.ParseConfig(cfgFile)
}
示例3: initConfig
func (c *controller) initConfig(configFile string) error {
cfgFile := configFile
if strings.Trim(cfgFile, " ") == "" {
cfgFile = os.Getenv(cfgFileEnv)
if strings.Trim(cfgFile, " ") == "" {
cfgFile = defaultCfgFile
}
}
cfg, err := config.ParseConfig(cfgFile)
if err != nil {
return ErrInvalidConfigFile(cfgFile)
}
c.Lock()
c.cfg = cfg
c.Unlock()
return nil
}
示例4: TestBadDiscovery
func TestBadDiscovery(t *testing.T) {
_, err := net.Dial("tcp", "discovery-stage.hub.docker.com:80")
if err != nil {
t.Skip("Skipping Discovery test which need connectivity to discovery-stage.hub.docker.com")
}
hd := NewHostDiscovery()
cfg := &config.Config{}
cfg.Cluster.Discovery = ""
err = hd.StartDiscovery(&cfg.Cluster, func(hosts []net.IP) {}, func(hosts []net.IP) {})
if err == nil {
t.Fatal("Invalid discovery configuration must fail")
}
cfg, err = config.ParseConfig("libnetwork.toml")
if err != nil {
t.Fatal(err)
}
cfg.Cluster.Address = "invalid"
err = hd.StartDiscovery(&cfg.Cluster, func(hosts []net.IP) {}, func(hosts []net.IP) {})
if err == nil {
t.Fatal("Invalid discovery address configuration must fail")
}
}
示例5: TestDiscovery
func TestDiscovery(t *testing.T) {
_, err := net.Dial("tcp", "discovery-stage.hub.docker.com:80")
if err != nil {
t.Skip("Skipping Discovery test which need connectivity to discovery-stage.hub.docker.com")
}
hd := NewHostDiscovery()
config, err := config.ParseConfig("libnetwork.toml")
if err != nil {
t.Fatal(err)
}
err = hd.StartDiscovery(&config.Cluster, func(hosts []net.IP) {}, func(hosts []net.IP) {})
if err != nil {
t.Fatal(err)
}
time.Sleep(time.Duration(config.Cluster.Heartbeat*2) * time.Second)
hosts, err := hd.Fetch()
if err != nil {
t.Fatal(err)
}
found := false
for _, ip := range hosts {
if ip.Equal(net.ParseIP(config.Cluster.Address)) {
found = true
}
}
if !found {
t.Fatalf("Expecting hosts. But none discovered ")
}
err = hd.StopDiscovery()
if err != nil {
t.Fatal(err)
}
}