github.com/nextlinux/gosbom@v0.81.1-0.20230627115839-1ff50c281391/gosbom/source/scope.go (about) 1 package source 2 3 import "strings" 4 5 // Scope indicates "how" or from "which perspectives" the source object should be cataloged from. 6 type Scope string 7 8 const ( 9 // UnknownScope is the default scope 10 UnknownScope Scope = "UnknownScope" 11 // SquashedScope indicates to only catalog content visible from the squashed filesystem representation (what can be seen only within the container at runtime) 12 SquashedScope Scope = "Squashed" 13 // AllLayersScope indicates to catalog content on all layers, irregardless if it is visible from the container at runtime. 14 AllLayersScope Scope = "AllLayers" 15 ) 16 17 // AllScopes is a slice containing all possible scope options 18 var AllScopes = []Scope{ 19 SquashedScope, 20 AllLayersScope, 21 } 22 23 // ParseScope returns a scope as indicated from the given string. 24 func ParseScope(userStr string) Scope { 25 switch strings.ToLower(userStr) { 26 case strings.ToLower(SquashedScope.String()): 27 return SquashedScope 28 case "all-layers", strings.ToLower(AllLayersScope.String()): 29 return AllLayersScope 30 } 31 return UnknownScope 32 } 33 34 func (o Scope) String() string { 35 return string(o) 36 }