This repository has been archived by the owner on May 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
/
imagepullpolicy_enumer.go
68 lines (55 loc) · 1.95 KB
/
imagepullpolicy_enumer.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
// Code generated by "enumer -type=ImagePullPolicy -trimprefix=ImagePullPolicy --json"; DO NOT EDIT.
package docker
import (
"encoding/json"
"fmt"
)
const _ImagePullPolicyName = "AlwaysIfNotPresentNever"
var _ImagePullPolicyIndex = [...]uint8{0, 6, 18, 23}
func (i ImagePullPolicy) String() string {
if i < 0 || i >= ImagePullPolicy(len(_ImagePullPolicyIndex)-1) {
return fmt.Sprintf("ImagePullPolicy(%d)", i)
}
return _ImagePullPolicyName[_ImagePullPolicyIndex[i]:_ImagePullPolicyIndex[i+1]]
}
var _ImagePullPolicyValues = []ImagePullPolicy{0, 1, 2}
var _ImagePullPolicyNameToValueMap = map[string]ImagePullPolicy{
_ImagePullPolicyName[0:6]: 0,
_ImagePullPolicyName[6:18]: 1,
_ImagePullPolicyName[18:23]: 2,
}
// ImagePullPolicyString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func ImagePullPolicyString(s string) (ImagePullPolicy, error) {
if val, ok := _ImagePullPolicyNameToValueMap[s]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to ImagePullPolicy values", s)
}
// ImagePullPolicyValues returns all values of the enum
func ImagePullPolicyValues() []ImagePullPolicy {
return _ImagePullPolicyValues
}
// IsAImagePullPolicy returns "true" if the value is listed in the enum definition. "false" otherwise
func (i ImagePullPolicy) IsAImagePullPolicy() bool {
for _, v := range _ImagePullPolicyValues {
if i == v {
return true
}
}
return false
}
// MarshalJSON implements the json.Marshaler interface for ImagePullPolicy
func (i ImagePullPolicy) MarshalJSON() ([]byte, error) {
return json.Marshal(i.String())
}
// UnmarshalJSON implements the json.Unmarshaler interface for ImagePullPolicy
func (i *ImagePullPolicy) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return fmt.Errorf("ImagePullPolicy should be a string, got %s", data)
}
var err error
*i, err = ImagePullPolicyString(s)
return err
}