github.com/anchore/syft@v1.4.2-0.20240516191711-1bec1fc5d397/syft/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 = "unknown-scope"
    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, regardless if it is visible from the container at runtime.
    14  	AllLayersScope Scope = "all-layers"
    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 SquashedScope.String():
    27  		return SquashedScope
    28  	case "alllayers", AllLayersScope.String():
    29  		return AllLayersScope
    30  	}
    31  	return UnknownScope
    32  }
    33  
    34  func (o Scope) String() string {
    35  	return string(o)
    36  }