github.com/anchore/syft@v1.38.2/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  	// DeepSquashedScope indicates to catalog content on all layers, but only include content visible from the squashed filesystem representation.
    16  	DeepSquashedScope Scope = "deep-squashed"
    17  )
    18  
    19  // AllScopes is a slice containing all possible scope options
    20  var AllScopes = []Scope{
    21  	SquashedScope,
    22  	AllLayersScope,
    23  	DeepSquashedScope,
    24  }
    25  
    26  // ParseScope returns a scope as indicated from the given string.
    27  func ParseScope(userStr string) Scope {
    28  	switch strings.ToLower(userStr) {
    29  	case SquashedScope.String():
    30  		return SquashedScope
    31  	case "all", "alllayers", AllLayersScope.String():
    32  		return AllLayersScope
    33  	case "deepsquashed", "squasheddeep", "squashed-deep", "deep-squash", "deepsquash", strings.ToLower(DeepSquashedScope.String()):
    34  		return DeepSquashedScope
    35  	}
    36  	return UnknownScope
    37  }
    38  
    39  func (o Scope) String() string {
    40  	return string(o)
    41  }