github.com/nextlinux/gosbom@v0.81.1-0.20230627115839-1ff50c281391/gosbom/formats/common/spdxhelpers/document_name.go (about)

     1  package spdxhelpers
     2  
     3  import (
     4  	"github.com/nextlinux/gosbom/gosbom/source"
     5  )
     6  
     7  func DocumentName(srcMetadata source.Metadata) string {
     8  	if srcMetadata.Name != "" {
     9  		return srcMetadata.Name
    10  	}
    11  
    12  	switch srcMetadata.Scheme {
    13  	case source.ImageScheme:
    14  		return srcMetadata.ImageMetadata.UserInput
    15  	case source.DirectoryScheme, source.FileScheme:
    16  		return srcMetadata.Path
    17  	default:
    18  		return "unknown"
    19  	}
    20  }