-
Notifications
You must be signed in to change notification settings - Fork 44
/
model_hostname_config.go
72 lines (57 loc) · 2.03 KB
/
model_hostname_config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package model
import (
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/utils"
"errors"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/converter"
"strings"
)
type HostnameConfig struct {
// K8S节点名称配置类型, 默认为“privateIp”。 - privateIp: 将节点私有IP作为K8S节点名称 - cceNodeName: 将CCE节点名称作为K8S节点名称 > - 配置为cceNodeName的节点, 其节点名称、K8S节点名称以及虚机名称相同。节点名称不支持修改, 并且在ECS侧修改了虚机名称,同步云服务器时,不会将修改后的虚机名称同步到节点。 > - 配置为cceNodeName的节点,为了避免K8S节点名称冲突,系统会自动在节点名称后添加后缀,后缀的格式为中划线(-)+五位随机字符,随机字符的取值为[a-z0-9]。
Type HostnameConfigType `json:"type"`
}
func (o HostnameConfig) String() string {
data, err := utils.Marshal(o)
if err != nil {
return "HostnameConfig struct{}"
}
return strings.Join([]string{"HostnameConfig", string(data)}, " ")
}
type HostnameConfigType struct {
value string
}
type HostnameConfigTypeEnum struct {
PRIVATE_IP HostnameConfigType
CCE_NODE_NAME HostnameConfigType
}
func GetHostnameConfigTypeEnum() HostnameConfigTypeEnum {
return HostnameConfigTypeEnum{
PRIVATE_IP: HostnameConfigType{
value: "privateIp",
},
CCE_NODE_NAME: HostnameConfigType{
value: "cceNodeName",
},
}
}
func (c HostnameConfigType) Value() string {
return c.value
}
func (c HostnameConfigType) MarshalJSON() ([]byte, error) {
return utils.Marshal(c.value)
}
func (c *HostnameConfigType) UnmarshalJSON(b []byte) error {
myConverter := converter.StringConverterFactory("string")
if myConverter == nil {
return errors.New("unsupported StringConverter type: string")
}
interf, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
if err != nil {
return err
}
if val, ok := interf.(string); ok {
c.value = val
return nil
} else {
return errors.New("convert enum data to string error")
}
}