github.com/hashicorp/packer@v1.14.3/packer/fixconfigmode_enumer.go (about) 1 // Code generated by "enumer -type FixConfigMode"; DO NOT EDIT. 2 3 package packer 4 5 import ( 6 "fmt" 7 "strings" 8 ) 9 10 const _FixConfigModeName = "StdoutInplaceDiff" 11 12 var _FixConfigModeIndex = [...]uint8{0, 6, 13, 17} 13 14 const _FixConfigModeLowerName = "stdoutinplacediff" 15 16 func (i FixConfigMode) String() string { 17 if i < 0 || i >= FixConfigMode(len(_FixConfigModeIndex)-1) { 18 return fmt.Sprintf("FixConfigMode(%d)", i) 19 } 20 return _FixConfigModeName[_FixConfigModeIndex[i]:_FixConfigModeIndex[i+1]] 21 } 22 23 // An "invalid array index" compiler error signifies that the constant values have changed. 24 // Re-run the stringer command to generate them again. 25 func _FixConfigModeNoOp() { 26 var x [1]struct{} 27 _ = x[Stdout-(0)] 28 _ = x[Inplace-(1)] 29 _ = x[Diff-(2)] 30 } 31 32 var _FixConfigModeValues = []FixConfigMode{Stdout, Inplace, Diff} 33 34 var _FixConfigModeNameToValueMap = map[string]FixConfigMode{ 35 _FixConfigModeName[0:6]: Stdout, 36 _FixConfigModeLowerName[0:6]: Stdout, 37 _FixConfigModeName[6:13]: Inplace, 38 _FixConfigModeLowerName[6:13]: Inplace, 39 _FixConfigModeName[13:17]: Diff, 40 _FixConfigModeLowerName[13:17]: Diff, 41 } 42 43 var _FixConfigModeNames = []string{ 44 _FixConfigModeName[0:6], 45 _FixConfigModeName[6:13], 46 _FixConfigModeName[13:17], 47 } 48 49 // FixConfigModeString retrieves an enum value from the enum constants string name. 50 // Throws an error if the param is not part of the enum. 51 func FixConfigModeString(s string) (FixConfigMode, error) { 52 if val, ok := _FixConfigModeNameToValueMap[s]; ok { 53 return val, nil 54 } 55 56 if val, ok := _FixConfigModeNameToValueMap[strings.ToLower(s)]; ok { 57 return val, nil 58 } 59 return 0, fmt.Errorf("%s does not belong to FixConfigMode values", s) 60 } 61 62 // FixConfigModeValues returns all values of the enum 63 func FixConfigModeValues() []FixConfigMode { 64 return _FixConfigModeValues 65 } 66 67 // FixConfigModeStrings returns a slice of all String values of the enum 68 func FixConfigModeStrings() []string { 69 strs := make([]string, len(_FixConfigModeNames)) 70 copy(strs, _FixConfigModeNames) 71 return strs 72 } 73 74 // IsAFixConfigMode returns "true" if the value is listed in the enum definition. "false" otherwise 75 func (i FixConfigMode) IsAFixConfigMode() bool { 76 for _, v := range _FixConfigModeValues { 77 if i == v { 78 return true 79 } 80 } 81 return false 82 }