github.com/itscaro/cli@v0.0.0-20190705081621-c9db0fe93829/cli/config/credentials/default_store.go (about)

     1  package credentials
     2  
     3  import (
     4  	"os/exec"
     5  )
     6  
     7  // DetectDefaultStore return the default credentials store for the platform if
     8  // the store executable is available.
     9  func DetectDefaultStore(store string) string {
    10  	platformDefault := defaultCredentialsStore()
    11  
    12  	// user defined or no default for platform
    13  	if store != "" || platformDefault == "" {
    14  		return store
    15  	}
    16  
    17  	if _, err := exec.LookPath(remoteCredentialsPrefix + platformDefault); err == nil {
    18  		return platformDefault
    19  	}
    20  	return ""
    21  }