Files
backy/pkg/backy/filecommandoperation_enumer.go
Andrew Woodlee 765ef2ee36
All checks were successful
ci/woodpecker/push/publish-docs Pipeline was successful
ci/woodpecker/tag/gitea Pipeline was successful
ci/woodpecker/tag/publish-docs Pipeline was successful
ci/woodpecker/release/publish-docs Pipeline was successful
v0.11.3
2026-01-31 01:06:18 -06:00

142 lines
4.8 KiB
Go

// Code generated by "enumer -linecomment -yaml -text -json -type=FileCommandOperation"; DO NOT EDIT.
package backy
import (
"encoding/json"
"fmt"
"strings"
)
const _FileCommandOperationName = "copymovedeletechownchmod"
var _FileCommandOperationIndex = [...]uint8{0, 0, 4, 8, 14, 19, 24}
const _FileCommandOperationLowerName = "copymovedeletechownchmod"
func (i FileCommandOperation) String() string {
if i < 0 || i >= FileCommandOperation(len(_FileCommandOperationIndex)-1) {
return fmt.Sprintf("FileCommandOperation(%d)", i)
}
return _FileCommandOperationName[_FileCommandOperationIndex[i]:_FileCommandOperationIndex[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 _FileCommandOperationNoOp() {
var x [1]struct{}
_ = x[DefaultFCO-(0)]
_ = x[FileCommandOperationCopy-(1)]
_ = x[FileCommandOperationMove-(2)]
_ = x[FileCommandOperationDelete-(3)]
_ = x[FileCommandOperationChown-(4)]
_ = x[FileCommandOperationChmod-(5)]
}
var _FileCommandOperationValues = []FileCommandOperation{DefaultFCO, FileCommandOperationCopy, FileCommandOperationMove, FileCommandOperationDelete, FileCommandOperationChown, FileCommandOperationChmod}
var _FileCommandOperationNameToValueMap = map[string]FileCommandOperation{
_FileCommandOperationName[0:0]: DefaultFCO,
_FileCommandOperationLowerName[0:0]: DefaultFCO,
_FileCommandOperationName[0:4]: FileCommandOperationCopy,
_FileCommandOperationLowerName[0:4]: FileCommandOperationCopy,
_FileCommandOperationName[4:8]: FileCommandOperationMove,
_FileCommandOperationLowerName[4:8]: FileCommandOperationMove,
_FileCommandOperationName[8:14]: FileCommandOperationDelete,
_FileCommandOperationLowerName[8:14]: FileCommandOperationDelete,
_FileCommandOperationName[14:19]: FileCommandOperationChown,
_FileCommandOperationLowerName[14:19]: FileCommandOperationChown,
_FileCommandOperationName[19:24]: FileCommandOperationChmod,
_FileCommandOperationLowerName[19:24]: FileCommandOperationChmod,
}
var _FileCommandOperationNames = []string{
_FileCommandOperationName[0:0],
_FileCommandOperationName[0:4],
_FileCommandOperationName[4:8],
_FileCommandOperationName[8:14],
_FileCommandOperationName[14:19],
_FileCommandOperationName[19:24],
}
// FileCommandOperationString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func FileCommandOperationString(s string) (FileCommandOperation, error) {
if val, ok := _FileCommandOperationNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _FileCommandOperationNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to FileCommandOperation values", s)
}
// FileCommandOperationValues returns all values of the enum
func FileCommandOperationValues() []FileCommandOperation {
return _FileCommandOperationValues
}
// FileCommandOperationStrings returns a slice of all String values of the enum
func FileCommandOperationStrings() []string {
strs := make([]string, len(_FileCommandOperationNames))
copy(strs, _FileCommandOperationNames)
return strs
}
// IsAFileCommandOperation returns "true" if the value is listed in the enum definition. "false" otherwise
func (i FileCommandOperation) IsAFileCommandOperation() bool {
for _, v := range _FileCommandOperationValues {
if i == v {
return true
}
}
return false
}
// MarshalJSON implements the json.Marshaler interface for FileCommandOperation
func (i FileCommandOperation) MarshalJSON() ([]byte, error) {
return json.Marshal(i.String())
}
// UnmarshalJSON implements the json.Unmarshaler interface for FileCommandOperation
func (i *FileCommandOperation) UnmarshalJSON(data []byte) error {
var s string
if err := json.Unmarshal(data, &s); err != nil {
return fmt.Errorf("FileCommandOperation should be a string, got %s", data)
}
var err error
*i, err = FileCommandOperationString(s)
return err
}
// MarshalText implements the encoding.TextMarshaler interface for FileCommandOperation
func (i FileCommandOperation) MarshalText() ([]byte, error) {
return []byte(i.String()), nil
}
// UnmarshalText implements the encoding.TextUnmarshaler interface for FileCommandOperation
func (i *FileCommandOperation) UnmarshalText(text []byte) error {
var err error
*i, err = FileCommandOperationString(string(text))
return err
}
// MarshalYAML implements a YAML Marshaler for FileCommandOperation
func (i FileCommandOperation) MarshalYAML() (interface{}, error) {
return i.String(), nil
}
// UnmarshalYAML implements a YAML Unmarshaler for FileCommandOperation
func (i *FileCommandOperation) UnmarshalYAML(unmarshal func(interface{}) error) error {
var s string
if err := unmarshal(&s); err != nil {
return err
}
var err error
*i, err = FileCommandOperationString(s)
return err
}