1 Star 0 Fork 0

zhuchance/kubernetes

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
requests.go 1.56 KB
一键复制 编辑 原始数据 按行查看 历史
Masahiro Sano 提交于 2015-04-18 18:35 . Update gophercloud to latest
package stacktemplates
import (
"fmt"
"github.com/rackspace/gophercloud"
)
// Get retreives data for the given stack template.
func Get(c *gophercloud.ServiceClient, stackName, stackID string) GetResult {
var res GetResult
_, res.Err = c.Request("GET", getURL(c, stackName, stackID), gophercloud.RequestOpts{
JSONResponse: &res.Body,
})
return res
}
// ValidateOptsBuilder describes struct types that can be accepted by the Validate call.
// The ValidateOpts struct in this package does.
type ValidateOptsBuilder interface {
ToStackTemplateValidateMap() (map[string]interface{}, error)
}
// ValidateOpts specifies the template validation parameters.
type ValidateOpts struct {
Template map[string]interface{}
TemplateURL string
}
// ToStackTemplateValidateMap assembles a request body based on the contents of a ValidateOpts.
func (opts ValidateOpts) ToStackTemplateValidateMap() (map[string]interface{}, error) {
vo := make(map[string]interface{})
if opts.Template != nil {
vo["template"] = opts.Template
return vo, nil
}
if opts.TemplateURL != "" {
vo["template_url"] = opts.TemplateURL
return vo, nil
}
return vo, fmt.Errorf("One of Template or TemplateURL is required.")
}
// Validate validates the given stack template.
func Validate(c *gophercloud.ServiceClient, opts ValidateOptsBuilder) ValidateResult {
var res ValidateResult
reqBody, err := opts.ToStackTemplateValidateMap()
if err != nil {
res.Err = err
return res
}
_, res.Err = c.Post(validateURL(c), reqBody, &res.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
return res
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/meoom/kubernetes.git
git@gitee.com:meoom/kubernetes.git
meoom
kubernetes
kubernetes
v1.1.4-beta.0

搜索帮助

Cb406eda 1850385 E526c682 1850385