normalize enums to lowercase with hyphens (#2363)

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
Alex Goodman
2023-11-28 11:02:20 -05:00
committed by GitHub
parent 4ee6be3777
commit 4d0da703bf
2 changed files with 62 additions and 5 deletions
+5 -5
View File
@@ -7,11 +7,11 @@ type Scope string
const (
// UnknownScope is the default scope
UnknownScope Scope = "UnknownScope"
UnknownScope Scope = "unknown-scope"
// SquashedScope indicates to only catalog content visible from the squashed filesystem representation (what can be seen only within the container at runtime)
SquashedScope Scope = "Squashed"
SquashedScope Scope = "squashed"
// AllLayersScope indicates to catalog content on all layers, regardless if it is visible from the container at runtime.
AllLayersScope Scope = "AllLayers"
AllLayersScope Scope = "all-layers"
)
// AllScopes is a slice containing all possible scope options
@@ -23,9 +23,9 @@ var AllScopes = []Scope{
// ParseScope returns a scope as indicated from the given string.
func ParseScope(userStr string) Scope {
switch strings.ToLower(userStr) {
case strings.ToLower(SquashedScope.String()):
case SquashedScope.String():
return SquashedScope
case "all-layers", strings.ToLower(AllLayersScope.String()):
case "alllayers", AllLayersScope.String():
return AllLayersScope
}
return UnknownScope