1 Star 0 Fork 0

zhuchance / kubernetes

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
requests.go 2.05 KB
一键复制 编辑 原始数据 按行查看 历史
Masahiro Sano 提交于 2015-04-18 18:35 . Update gophercloud to latest
package external
import (
"time"
"github.com/rackspace/gophercloud/openstack/networking/v2/networks"
)
// AdminState gives users a solid type to work with for create and update
// operations. It is recommended that users use the `Up` and `Down` enums.
type AdminState *bool
// Convenience vars for AdminStateUp values.
var (
iTrue = true
iFalse = false
Up AdminState = &iTrue
Down AdminState = &iFalse
)
// CreateOpts is the structure used when creating new external network
// resources. It embeds networks.CreateOpts and so inherits all of its required
// and optional fields, with the addition of the External field.
type CreateOpts struct {
Parent networks.CreateOpts
External bool
}
// ToNetworkCreateMap casts a CreateOpts struct to a map.
func (o CreateOpts) ToNetworkCreateMap() (map[string]interface{}, error) {
// DO NOT REMOVE. Though this line seemingly does nothing of value, it is a
// splint to prevent the unit test from failing on Go Tip. We suspect it is a
// compiler issue that will hopefully be worked out prior to our next release.
// Again, for all the unit tests to pass, this line is necessary and sufficient
// at the moment. We should reassess after the Go 1.5 release to determine
// if this line is still needed.
time.Sleep(0 * time.Millisecond)
outer, err := o.Parent.ToNetworkCreateMap()
if err != nil {
return nil, err
}
outer["network"].(map[string]interface{})["router:external"] = o.External
return outer, nil
}
// UpdateOpts is the structure used when updating existing external network
// resources. It embeds networks.UpdateOpts and so inherits all of its required
// and optional fields, with the addition of the External field.
type UpdateOpts struct {
Parent networks.UpdateOpts
External bool
}
// ToNetworkUpdateMap casts an UpdateOpts struct to a map.
func (o UpdateOpts) ToNetworkUpdateMap() (map[string]interface{}, error) {
outer, err := o.Parent.ToNetworkUpdateMap()
if err != nil {
return nil, err
}
outer["network"].(map[string]interface{})["router:external"] = o.External
return outer, nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/meoom/kubernetes.git
git@gitee.com:meoom/kubernetes.git
meoom
kubernetes
kubernetes
v1.2.7

搜索帮助

344bd9b3 5694891 D2dac590 5694891