146 lines
4.6 KiB
Go
146 lines
4.6 KiB
Go
// Code generated by "enumer -linecomment -yaml -text -json -type=PackageOperation"; DO NOT EDIT.
|
|
|
|
package backy
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
const _PackageOperationName = "installupgradepurgeremovecheckVersionisInstalled"
|
|
|
|
var _PackageOperationIndex = [...]uint8{0, 0, 7, 14, 19, 25, 37, 48}
|
|
|
|
const _PackageOperationLowerName = "installupgradepurgeremovecheckversionisinstalled"
|
|
|
|
func (i PackageOperation) String() string {
|
|
if i < 0 || i >= PackageOperation(len(_PackageOperationIndex)-1) {
|
|
return fmt.Sprintf("PackageOperation(%d)", i)
|
|
}
|
|
return _PackageOperationName[_PackageOperationIndex[i]:_PackageOperationIndex[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 _PackageOperationNoOp() {
|
|
var x [1]struct{}
|
|
_ = x[DefaultPO-(0)]
|
|
_ = x[PackOpInstall-(1)]
|
|
_ = x[PackOpUpgrade-(2)]
|
|
_ = x[PackOpPurge-(3)]
|
|
_ = x[PackOpRemove-(4)]
|
|
_ = x[PackOpCheckVersion-(5)]
|
|
_ = x[PackOpIsInstalled-(6)]
|
|
}
|
|
|
|
var _PackageOperationValues = []PackageOperation{DefaultPO, PackOpInstall, PackOpUpgrade, PackOpPurge, PackOpRemove, PackOpCheckVersion, PackOpIsInstalled}
|
|
|
|
var _PackageOperationNameToValueMap = map[string]PackageOperation{
|
|
_PackageOperationName[0:0]: DefaultPO,
|
|
_PackageOperationLowerName[0:0]: DefaultPO,
|
|
_PackageOperationName[0:7]: PackOpInstall,
|
|
_PackageOperationLowerName[0:7]: PackOpInstall,
|
|
_PackageOperationName[7:14]: PackOpUpgrade,
|
|
_PackageOperationLowerName[7:14]: PackOpUpgrade,
|
|
_PackageOperationName[14:19]: PackOpPurge,
|
|
_PackageOperationLowerName[14:19]: PackOpPurge,
|
|
_PackageOperationName[19:25]: PackOpRemove,
|
|
_PackageOperationLowerName[19:25]: PackOpRemove,
|
|
_PackageOperationName[25:37]: PackOpCheckVersion,
|
|
_PackageOperationLowerName[25:37]: PackOpCheckVersion,
|
|
_PackageOperationName[37:48]: PackOpIsInstalled,
|
|
_PackageOperationLowerName[37:48]: PackOpIsInstalled,
|
|
}
|
|
|
|
var _PackageOperationNames = []string{
|
|
_PackageOperationName[0:0],
|
|
_PackageOperationName[0:7],
|
|
_PackageOperationName[7:14],
|
|
_PackageOperationName[14:19],
|
|
_PackageOperationName[19:25],
|
|
_PackageOperationName[25:37],
|
|
_PackageOperationName[37:48],
|
|
}
|
|
|
|
// PackageOperationString retrieves an enum value from the enum constants string name.
|
|
// Throws an error if the param is not part of the enum.
|
|
func PackageOperationString(s string) (PackageOperation, error) {
|
|
if val, ok := _PackageOperationNameToValueMap[s]; ok {
|
|
return val, nil
|
|
}
|
|
|
|
if val, ok := _PackageOperationNameToValueMap[strings.ToLower(s)]; ok {
|
|
return val, nil
|
|
}
|
|
return 0, fmt.Errorf("%s does not belong to PackageOperation values", s)
|
|
}
|
|
|
|
// PackageOperationValues returns all values of the enum
|
|
func PackageOperationValues() []PackageOperation {
|
|
return _PackageOperationValues
|
|
}
|
|
|
|
// PackageOperationStrings returns a slice of all String values of the enum
|
|
func PackageOperationStrings() []string {
|
|
strs := make([]string, len(_PackageOperationNames))
|
|
copy(strs, _PackageOperationNames)
|
|
return strs
|
|
}
|
|
|
|
// IsAPackageOperation returns "true" if the value is listed in the enum definition. "false" otherwise
|
|
func (i PackageOperation) IsAPackageOperation() bool {
|
|
for _, v := range _PackageOperationValues {
|
|
if i == v {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// MarshalJSON implements the json.Marshaler interface for PackageOperation
|
|
func (i PackageOperation) MarshalJSON() ([]byte, error) {
|
|
return json.Marshal(i.String())
|
|
}
|
|
|
|
// UnmarshalJSON implements the json.Unmarshaler interface for PackageOperation
|
|
func (i *PackageOperation) UnmarshalJSON(data []byte) error {
|
|
var s string
|
|
if err := json.Unmarshal(data, &s); err != nil {
|
|
return fmt.Errorf("PackageOperation should be a string, got %s", data)
|
|
}
|
|
|
|
var err error
|
|
*i, err = PackageOperationString(s)
|
|
return err
|
|
}
|
|
|
|
// MarshalText implements the encoding.TextMarshaler interface for PackageOperation
|
|
func (i PackageOperation) MarshalText() ([]byte, error) {
|
|
return []byte(i.String()), nil
|
|
}
|
|
|
|
// UnmarshalText implements the encoding.TextUnmarshaler interface for PackageOperation
|
|
func (i *PackageOperation) UnmarshalText(text []byte) error {
|
|
var err error
|
|
*i, err = PackageOperationString(string(text))
|
|
return err
|
|
}
|
|
|
|
// MarshalYAML implements a YAML Marshaler for PackageOperation
|
|
func (i PackageOperation) MarshalYAML() (interface{}, error) {
|
|
return i.String(), nil
|
|
}
|
|
|
|
// UnmarshalYAML implements a YAML Unmarshaler for PackageOperation
|
|
func (i *PackageOperation) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|
var s string
|
|
if err := unmarshal(&s); err != nil {
|
|
return err
|
|
}
|
|
|
|
var err error
|
|
*i, err = PackageOperationString(s)
|
|
return err
|
|
}
|