本文整理汇总了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)
}
}