代码拉取完成,页面将自动刷新
package nodetemplate
import (
"github.com/rancher/norman/httperror"
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/convert"
"github.com/rancher/norman/types/values"
"github.com/rancher/rancher/pkg/configfield"
)
const (
Amazonec2driver = "amazonec2"
Azuredriver = "azure"
Vmwaredriver = "vmwarevsphere"
DigitalOceandriver = "digitalocean"
)
var drivers = map[string]bool{
Amazonec2driver: true,
Azuredriver: true,
DigitalOceandriver: true,
Vmwaredriver: true,
}
func Validator(request *types.APIContext, schema *types.Schema, data map[string]interface{}) error {
driver := configfield.GetDriver(data)
if driver == "" {
return httperror.NewAPIError(httperror.MissingRequired, "a Config field must be set")
}
credID := convert.ToString(values.GetValueN(data, "cloudCredentialId"))
if credID == "" {
if _, ok := drivers[driver]; ok {
return httperror.NewAPIError(httperror.MissingRequired, "Cloud Credential must be set")
}
}
if data != nil {
data["driver"] = driver
}
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。