github.com/anchore/syft@v1.4.2-0.20240516191711-1bec1fc5d397/internal/relationship/to_source.go (about)

     1  package relationship
     2  
     3  import (
     4  	"github.com/anchore/syft/syft/artifact"
     5  	"github.com/anchore/syft/syft/pkg"
     6  )
     7  
     8  func toSource(src artifact.Identifiable, c *pkg.Collection) []artifact.Relationship {
     9  	relationships := make([]artifact.Relationship, 0) // Should we pre-allocate this by giving catalog a Len() method?
    10  	for p := range c.Enumerate() {
    11  		relationships = append(relationships, artifact.Relationship{
    12  			From: src,
    13  			To:   p,
    14  			Type: artifact.ContainsRelationship,
    15  		})
    16  	}
    17  
    18  	return relationships
    19  }