github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/cmd/discover_asset.go (about)

     1  package cmd
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  )
     7  
     8  // discoverAsset will find an asset path relative to the executable, assuming
     9  // the executable is installed as /usr/local/concourse/bin/concourse, and the
    10  // asset lives under /usr/local/concourse
    11  func DiscoverAsset(name string) string {
    12  	self, err := os.Executable()
    13  	if err != nil {
    14  		return ""
    15  	}
    16  
    17  	asset := filepath.Join(filepath.Dir(filepath.Dir(self)), name)
    18  	if _, err := os.Stat(asset); err == nil {
    19  		return asset
    20  	}
    21  
    22  	return ""
    23  }