From 7e45a1e950aa5abb82778e3d90b2f88a5adc273f Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Fri, 8 May 2020 16:54:44 +0200 Subject: [PATCH] fix enum --- packer/fixconfigmode_enumer.go | 51 ++++++++++++++++++++++++++++++++++ packer/new_stuff.go | 8 +++--- 2 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 packer/fixconfigmode_enumer.go diff --git a/packer/fixconfigmode_enumer.go b/packer/fixconfigmode_enumer.go new file mode 100644 index 000000000..82b09a633 --- /dev/null +++ b/packer/fixconfigmode_enumer.go @@ -0,0 +1,51 @@ +// Code generated by "enumer -type FixConfigMode"; DO NOT EDIT. + +// +package packer + +import ( + "fmt" +) + +const _FixConfigModeName = "StdoutInplaceDiff" + +var _FixConfigModeIndex = [...]uint8{0, 6, 13, 17} + +func (i FixConfigMode) String() string { + if i < 0 || i >= FixConfigMode(len(_FixConfigModeIndex)-1) { + return fmt.Sprintf("FixConfigMode(%d)", i) + } + return _FixConfigModeName[_FixConfigModeIndex[i]:_FixConfigModeIndex[i+1]] +} + +var _FixConfigModeValues = []FixConfigMode{0, 1, 2} + +var _FixConfigModeNameToValueMap = map[string]FixConfigMode{ + _FixConfigModeName[0:6]: 0, + _FixConfigModeName[6:13]: 1, + _FixConfigModeName[13:17]: 2, +} + +// FixConfigModeString retrieves an enum value from the enum constants string name. +// Throws an error if the param is not part of the enum. +func FixConfigModeString(s string) (FixConfigMode, error) { + if val, ok := _FixConfigModeNameToValueMap[s]; ok { + return val, nil + } + return 0, fmt.Errorf("%s does not belong to FixConfigMode values", s) +} + +// FixConfigModeValues returns all values of the enum +func FixConfigModeValues() []FixConfigMode { + return _FixConfigModeValues +} + +// IsAFixConfigMode returns "true" if the value is listed in the enum definition. "false" otherwise +func (i FixConfigMode) IsAFixConfigMode() bool { + for _, v := range _FixConfigModeValues { + if i == v { + return true + } + } + return false +} diff --git a/packer/new_stuff.go b/packer/new_stuff.go index 00d252fa4..0df4af30f 100644 --- a/packer/new_stuff.go +++ b/packer/new_stuff.go @@ -14,13 +14,13 @@ type BuildGetter interface { GetBuilds(GetBuildsOptions) ([]Build, hcl.Diagnostics) } -//go:generate enumer -type FixMode +//go:generate enumer -type FixConfigMode type FixConfigMode int const ( - Stdout FixConfigMode = 0 - Inplace FixConfigMode = 1 - Diff FixConfigMode = 2 + Stdout FixConfigMode = iota + Inplace + Diff ) type FixConfigOptions struct {