github.com/thajeztah/cli@v0.0.0-20240223162942-dc6bfac81a8b/cli/config/credentials/default_store.go (about)

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