github.com/vchain-us/vcn@v0.9.11-0.20210921212052-a2484d23c0b3/pkg/bom/bom.go (about)

     1  /*
     2   * Copyright (c) 2021 CodeNotary, Inc. All Rights Reserved.
     3   * This software is released under GPL3.
     4   * The full license information can be found under:
     5   * https://www.gnu.org/licenses/gpl-3.0.en.html
     6   *
     7   */
     8  
     9  package bom
    10  
    11  import (
    12  	"github.com/vchain-us/vcn/pkg/bom/artifact"
    13  	"github.com/vchain-us/vcn/pkg/bom/golang"
    14  	"github.com/vchain-us/vcn/pkg/bom/dotnet"
    15  	"github.com/vchain-us/vcn/pkg/bom/java"
    16  	"github.com/vchain-us/vcn/pkg/bom/node"
    17  	"github.com/vchain-us/vcn/pkg/bom/python"
    18  )
    19  
    20  // extractor schemes that can be used to point to BoM source
    21  var BomSchemes = map[string]struct{}{"dir": {}, "git": {}, "docker": {}, "": {}}
    22  
    23  // New returns Artifact implementation of type, matching the artifact language/environment
    24  func New(filename string) artifact.Artifact {
    25  	// try all language options, return the one that matches
    26  	if pkg := golang.New(filename); pkg != nil {
    27  		return pkg
    28  	}
    29  	if pkg := python.New(filename); pkg != nil {
    30  		return pkg
    31  	}
    32  	if pkg := dotnet.New(filename); pkg != nil {
    33  		return pkg
    34  	}
    35  	if pkg := java.New(filename); pkg != nil {
    36  		return pkg
    37  	}
    38  	if pkg := node.New(filename); pkg != nil {
    39  		return pkg
    40  	}
    41  
    42  	return nil
    43  }