-
Notifications
You must be signed in to change notification settings - Fork 42
/
constants.go
192 lines (166 loc) · 5.25 KB
/
constants.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
package updateruns
import (
"encoding/json"
"fmt"
"strings"
)
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.
type ManagedClusterUpgradeType string
const (
ManagedClusterUpgradeTypeFull ManagedClusterUpgradeType = "Full"
ManagedClusterUpgradeTypeNodeImageOnly ManagedClusterUpgradeType = "NodeImageOnly"
)
func PossibleValuesForManagedClusterUpgradeType() []string {
return []string{
string(ManagedClusterUpgradeTypeFull),
string(ManagedClusterUpgradeTypeNodeImageOnly),
}
}
func (s *ManagedClusterUpgradeType) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseManagedClusterUpgradeType(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseManagedClusterUpgradeType(input string) (*ManagedClusterUpgradeType, error) {
vals := map[string]ManagedClusterUpgradeType{
"full": ManagedClusterUpgradeTypeFull,
"nodeimageonly": ManagedClusterUpgradeTypeNodeImageOnly,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := ManagedClusterUpgradeType(input)
return &out, nil
}
type NodeImageSelectionType string
const (
NodeImageSelectionTypeConsistent NodeImageSelectionType = "Consistent"
NodeImageSelectionTypeLatest NodeImageSelectionType = "Latest"
)
func PossibleValuesForNodeImageSelectionType() []string {
return []string{
string(NodeImageSelectionTypeConsistent),
string(NodeImageSelectionTypeLatest),
}
}
func (s *NodeImageSelectionType) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseNodeImageSelectionType(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseNodeImageSelectionType(input string) (*NodeImageSelectionType, error) {
vals := map[string]NodeImageSelectionType{
"consistent": NodeImageSelectionTypeConsistent,
"latest": NodeImageSelectionTypeLatest,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := NodeImageSelectionType(input)
return &out, nil
}
type UpdateRunProvisioningState string
const (
UpdateRunProvisioningStateCanceled UpdateRunProvisioningState = "Canceled"
UpdateRunProvisioningStateFailed UpdateRunProvisioningState = "Failed"
UpdateRunProvisioningStateSucceeded UpdateRunProvisioningState = "Succeeded"
)
func PossibleValuesForUpdateRunProvisioningState() []string {
return []string{
string(UpdateRunProvisioningStateCanceled),
string(UpdateRunProvisioningStateFailed),
string(UpdateRunProvisioningStateSucceeded),
}
}
func (s *UpdateRunProvisioningState) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseUpdateRunProvisioningState(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseUpdateRunProvisioningState(input string) (*UpdateRunProvisioningState, error) {
vals := map[string]UpdateRunProvisioningState{
"canceled": UpdateRunProvisioningStateCanceled,
"failed": UpdateRunProvisioningStateFailed,
"succeeded": UpdateRunProvisioningStateSucceeded,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := UpdateRunProvisioningState(input)
return &out, nil
}
type UpdateState string
const (
UpdateStateCompleted UpdateState = "Completed"
UpdateStateFailed UpdateState = "Failed"
UpdateStateNotStarted UpdateState = "NotStarted"
UpdateStateRunning UpdateState = "Running"
UpdateStateSkipped UpdateState = "Skipped"
UpdateStateStopped UpdateState = "Stopped"
UpdateStateStopping UpdateState = "Stopping"
)
func PossibleValuesForUpdateState() []string {
return []string{
string(UpdateStateCompleted),
string(UpdateStateFailed),
string(UpdateStateNotStarted),
string(UpdateStateRunning),
string(UpdateStateSkipped),
string(UpdateStateStopped),
string(UpdateStateStopping),
}
}
func (s *UpdateState) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseUpdateState(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}
func parseUpdateState(input string) (*UpdateState, error) {
vals := map[string]UpdateState{
"completed": UpdateStateCompleted,
"failed": UpdateStateFailed,
"notstarted": UpdateStateNotStarted,
"running": UpdateStateRunning,
"skipped": UpdateStateSkipped,
"stopped": UpdateStateStopped,
"stopping": UpdateStateStopping,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}
// otherwise presume it's an undefined value and best-effort it
out := UpdateState(input)
return &out, nil
}