-
Notifications
You must be signed in to change notification settings - Fork 683
/
handwritten.enum.go
143 lines (121 loc) · 3.44 KB
/
handwritten.enum.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
// Copyright 2020 Datawire. All rights reserved
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
///////////////////////////////////////////////////////////////////////////
// Important: Run "make generate-fast" to regenerate code after modifying
// this file.
///////////////////////////////////////////////////////////////////////////
package v3alpha1
// This file is support code for enum types. I'm disappointed that
// controller-gen doesn't generate this.
//
// FIXME(lukeshu): Either patch (and PR) controller-gen to generate
// this, or create a separate code-gen tool to generate it.
//
// - Constants for the values of the enum
//
// - For enums that have an 'int' type in Go:
// - A MarshalJSON() method
// - An UnmarshalJSON() method
// - A String() method
import (
"encoding/json"
)
const (
HostState_Initial = HostState(iota)
HostState_Pending
HostState_Ready
HostState_Error
)
var (
hostState_name = map[HostState]string{
0: "Initial",
1: "Pending",
2: "Ready",
3: "Error",
}
hostState_value = map[string]HostState{
"Initial": 0,
"Pending": 1,
"Ready": 2,
"Error": 3,
}
)
func (o HostState) MarshalJSON() ([]byte, error) {
return json.Marshal(o.String())
}
func (o HostState) String() string {
return hostState_name[o]
}
func (o *HostState) UnmarshalJSON(data []byte) error {
if string(data) == "null" {
*o = 0
return nil
}
var str string
if err := json.Unmarshal(data, &str); err != nil {
return err
}
*o = hostState_value[str]
return nil
}
const (
HostPhase_NA = HostPhase(iota)
HostPhase_DefaultsFilled
HostPhase_ACMEUserPrivateKeyCreated
HostPhase_ACMEUserRegistered
HostPhase_ACMECertificateChallenge
)
var (
hostPhase_name = map[HostPhase]string{
HostPhase_NA: "NA",
HostPhase_DefaultsFilled: "DefaultsFilled",
HostPhase_ACMEUserPrivateKeyCreated: "ACMEUserPrivateKeyCreated",
HostPhase_ACMEUserRegistered: "ACMEUserRegistered",
HostPhase_ACMECertificateChallenge: "ACMECertificateChallenge",
}
hostPhase_value = map[string]HostPhase{
"NA": HostPhase_NA,
"DefaultsFilled": HostPhase_DefaultsFilled,
"ACMEUserPrivateKeyCreated": HostPhase_ACMEUserPrivateKeyCreated,
"ACMEUserRegistered": HostPhase_ACMEUserRegistered,
"ACMECertificateChallenge": HostPhase_ACMECertificateChallenge,
}
)
func (o HostPhase) MarshalJSON() ([]byte, error) {
return json.Marshal(o.String())
}
func (o HostPhase) String() string {
return hostPhase_name[o]
}
func (o *HostPhase) UnmarshalJSON(data []byte) error {
if string(data) == "null" {
*o = 0
return nil
}
var str string
if err := json.Unmarshal(data, &str); err != nil {
return err
}
*o = hostPhase_value[str]
return nil
}
const (
PreviewURLType_Path = "Path"
)
const (
HostTLSCertificateSource_Unknown = "Unknown"
HostTLSCertificateSource_None = "None"
HostTLSCertificateSource_Other = "Other"
HostTLSCertificateSource_ACME = "ACME"
)