本文整理汇总了Golang中github.com/scalingdata/gcfg.ReadInto函数的典型用法代码示例。如果您正苦于以下问题:Golang ReadInto函数的具体用法?Golang ReadInto怎么用?Golang ReadInto使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReadInto函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: newOVirtCloud
func newOVirtCloud(config io.Reader) (*OVirtCloud, error) {
if config == nil {
return nil, fmt.Errorf("missing configuration file for ovirt cloud provider")
}
oVirtConfig := OVirtApiConfig{}
/* defaults */
oVirtConfig.Connection.Username = "[email protected]"
if err := gcfg.ReadInto(&oVirtConfig, config); err != nil {
return nil, err
}
if oVirtConfig.Connection.ApiEntry == "" {
return nil, fmt.Errorf("missing ovirt uri in cloud provider configuration")
}
request, err := url.Parse(oVirtConfig.Connection.ApiEntry)
if err != nil {
return nil, err
}
request.Path = path.Join(request.Path, "vms")
request.User = url.UserPassword(oVirtConfig.Connection.Username, oVirtConfig.Connection.Password)
request.RawQuery = url.Values{"search": {oVirtConfig.Filters.VmsQuery}}.Encode()
return &OVirtCloud{VmsRequest: request}, nil
}
开发者ID:previousnext,项目名称:kube-ingress,代码行数:29,代码来源:ovirt.go
示例2: ReadConfiguration
func ReadConfiguration(reader io.Reader, config *Config) error {
wrapper := configWrapper{Default: *config}
wrapper.Default.ResyncPeriod = 0
buffer := readSection(reader, "default")
err := gcfg.ReadInto(&wrapper, bytes.NewReader(buffer.Bytes()))
if err != nil {
return err
}
if wrapper.Default.ResyncPeriod != 0 {
wrapper.Default.ResyncPeriod = wrapper.Default.ResyncPeriod * time.Second
} else {
wrapper.Default.ResyncPeriod = config.ResyncPeriod
}
if clusterIp := wrapper.Default.ClusterIpRange; clusterIp != "" {
if _, _, err := net.ParseCIDR(clusterIp); err != nil {
return err
}
}
*config = wrapper.Default
return nil
}
开发者ID:michaelkuty,项目名称:contrail-kubernetes,代码行数:25,代码来源:config.go
示例3: readConfig
func readConfig(config io.Reader) (Config, error) {
if config == nil {
err := fmt.Errorf("no OpenStack cloud provider config file given")
return Config{}, err
}
var cfg Config
err := gcfg.ReadInto(&cfg, config)
return cfg, err
}
开发者ID:mataihang,项目名称:kubernetes,代码行数:10,代码来源:openstack.go
示例4: Read
func (c *Config) Read(configReader io.Reader) error {
wrapper := &ConfigWrapper{Scheduler: *c}
if configReader != nil {
if err := gcfg.ReadInto(wrapper, configReader); err != nil {
return err
}
*c = wrapper.Scheduler
}
return nil
}
开发者ID:qinguoan,项目名称:vulcan,代码行数:10,代码来源:config.go
示例5: readConfig
func readConfig(configReader io.Reader) (*Config, error) {
config := createDefaultConfig()
wrapper := &ConfigWrapper{Mesos_Cloud: *config}
if configReader != nil {
if err := gcfg.ReadInto(wrapper, configReader); err != nil {
return nil, err
}
config = &(wrapper.Mesos_Cloud)
}
return config, nil
}
开发者ID:johndmulhausen,项目名称:kubernetes,代码行数:11,代码来源:config.go
示例6: readConfig
func readConfig(configFile string) (openStackConfig, error) {
var config *os.File
config, err := os.Open(configFile)
if err != nil {
return openStackConfig{}, err
}
defer config.Close()
if config == nil {
err := fmt.Errorf("no OpenStack cloud provider config file given")
return openStackConfig{}, err
}
var cfg openStackConfig
err = gcfg.ReadInto(&cfg, config)
return cfg, err
}
开发者ID:thed00de,项目名称:hypernetes,代码行数:17,代码来源:cinder_client.go
示例7: ReadConfiguration
func (c *Config) ReadConfiguration(global *network.Config, reader io.Reader) error {
if global != nil && c.ServiceSubnet == DefaultServiceSubnet {
c.ServiceSubnet = global.ClusterIpRange
}
if reader == nil {
return nil
}
wrapper := configWrapper{OpenContrail: *c}
if err := gcfg.ReadInto(&wrapper, reader); err != nil {
return err
}
if err := wrapper.OpenContrail.Validate(); err != nil {
return err
}
*c = wrapper.OpenContrail
return nil
}
开发者ID:michaelkuty,项目名称:contrail-kubernetes,代码行数:19,代码来源:config.go
示例8: newGCECloud
// newGCECloud creates a new instance of GCECloud.
func newGCECloud(config io.Reader) (*GCECloud, error) {
projectID, zone, err := getProjectAndZone()
if err != nil {
return nil, err
}
// TODO: if we want to use this on a machine that doesn't have the http://metadata server
// e.g. on a user's machine (not VM) somewhere, we need to have an alternative for
// instance id lookup.
instanceID, err := getInstanceID()
if err != nil {
return nil, err
}
externalID, err := getCurrentExternalID()
if err != nil {
return nil, err
}
networkName, err := getNetworkName()
if err != nil {
return nil, err
}
networkURL := gceNetworkURL(projectID, networkName)
tokenSource := google.ComputeTokenSource("")
if config != nil {
var cfg Config
if err := gcfg.ReadInto(&cfg, config); err != nil {
glog.Errorf("Couldn't read config: %v", err)
return nil, err
}
if cfg.Global.ProjectID != "" {
projectID = cfg.Global.ProjectID
}
if cfg.Global.NetworkName != "" {
if strings.Contains(cfg.Global.NetworkName, "/") {
networkURL = cfg.Global.NetworkName
} else {
networkURL = gceNetworkURL(cfg.Global.ProjectID, cfg.Global.NetworkName)
}
}
if cfg.Global.TokenURL != "" {
tokenSource = newAltTokenSource(cfg.Global.TokenURL, cfg.Global.TokenBody)
}
}
client := oauth2.NewClient(oauth2.NoContext, tokenSource)
svc, err := compute.New(client)
if err != nil {
return nil, err
}
containerSvc, err := container.New(client)
if err != nil {
return nil, err
}
return &GCECloud{
service: svc,
containerService: containerSvc,
projectID: projectID,
zone: zone,
instanceID: instanceID,
externalID: externalID,
networkURL: networkURL,
}, nil
}
开发者ID:pyk,项目名称:kubernetes,代码行数:62,代码来源:gce.go
注:本文中的github.com/scalingdata/gcfg.ReadInto函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论