mirror of
https://github.com/hashicorp/packer.git
synced 2026-09-18 22:11:39 -04:00
Since the enumer implementation we used hadn't been updated for 5+ years, this didn't work with recent linux/go versions, and enumer crashed while attempting to parse/analyse the source files. There's another alternative on Github, forked from the one we used, which seems more maintained now, and does produce the expected files in Packer.
79 lines
2.0 KiB
Go
79 lines
2.0 KiB
Go
// Code generated by "enumer -type configType -trimprefix ConfigType -transform snake"; DO NOT EDIT.
|
|
|
|
package command
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
const _configTypeName = "jsonhcl2"
|
|
|
|
var _configTypeIndex = [...]uint8{0, 4, 8}
|
|
|
|
const _configTypeLowerName = "jsonhcl2"
|
|
|
|
func (i configType) String() string {
|
|
if i < 0 || i >= configType(len(_configTypeIndex)-1) {
|
|
return fmt.Sprintf("configType(%d)", i)
|
|
}
|
|
return _configTypeName[_configTypeIndex[i]:_configTypeIndex[i+1]]
|
|
}
|
|
|
|
// An "invalid array index" compiler error signifies that the constant values have changed.
|
|
// Re-run the stringer command to generate them again.
|
|
func _configTypeNoOp() {
|
|
var x [1]struct{}
|
|
_ = x[ConfigTypeJSON-(0)]
|
|
_ = x[ConfigTypeHCL2-(1)]
|
|
}
|
|
|
|
var _configTypeValues = []configType{ConfigTypeJSON, ConfigTypeHCL2}
|
|
|
|
var _configTypeNameToValueMap = map[string]configType{
|
|
_configTypeName[0:4]: ConfigTypeJSON,
|
|
_configTypeLowerName[0:4]: ConfigTypeJSON,
|
|
_configTypeName[4:8]: ConfigTypeHCL2,
|
|
_configTypeLowerName[4:8]: ConfigTypeHCL2,
|
|
}
|
|
|
|
var _configTypeNames = []string{
|
|
_configTypeName[0:4],
|
|
_configTypeName[4:8],
|
|
}
|
|
|
|
// configTypeString retrieves an enum value from the enum constants string name.
|
|
// Throws an error if the param is not part of the enum.
|
|
func configTypeString(s string) (configType, error) {
|
|
if val, ok := _configTypeNameToValueMap[s]; ok {
|
|
return val, nil
|
|
}
|
|
|
|
if val, ok := _configTypeNameToValueMap[strings.ToLower(s)]; ok {
|
|
return val, nil
|
|
}
|
|
return 0, fmt.Errorf("%s does not belong to configType values", s)
|
|
}
|
|
|
|
// configTypeValues returns all values of the enum
|
|
func configTypeValues() []configType {
|
|
return _configTypeValues
|
|
}
|
|
|
|
// configTypeStrings returns a slice of all String values of the enum
|
|
func configTypeStrings() []string {
|
|
strs := make([]string, len(_configTypeNames))
|
|
copy(strs, _configTypeNames)
|
|
return strs
|
|
}
|
|
|
|
// IsAconfigType returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
func (i configType) IsAconfigType() bool {
|
|
for _, v := range _configTypeValues {
|
|
if i == v {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|