mirror of https://github.com/dapr/cli.git
Changes to fix the homepath dir on windows
This commit is contained in:
parent
8df8a716ca
commit
9fee955548
|
@ -0,0 +1,20 @@
|
|||
package standalone
|
||||
|
||||
import (
|
||||
"os"
|
||||
path_filepath "path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// getDefaultComponentsFolder returns the hidden .components folder created under install directory at init time
|
||||
func getDefaultComponentsFolder() string {
|
||||
const daprDirName = ".dapr"
|
||||
const componentsDirName = "components"
|
||||
daprDirPath := os.Getenv("HOME")
|
||||
if runtime.GOOS == daprWindowsOS {
|
||||
daprDirPath = path_filepath.Join(os.Getenv("HOMEDRIVE"), os.Getenv("HOMEPATH"))
|
||||
}
|
||||
|
||||
defaultComponentsPath := path_filepath.Join(daprDirPath, daprDirName, componentsDirName)
|
||||
return defaultComponentsPath
|
||||
}
|
|
@ -19,7 +19,6 @@ import (
|
|||
"github.com/Pallinder/sillyname-go"
|
||||
"github.com/phayes/freeport"
|
||||
|
||||
"github.com/dapr/cli/utils"
|
||||
"github.com/dapr/dapr/pkg/components"
|
||||
modes "github.com/dapr/dapr/pkg/config/modes"
|
||||
)
|
||||
|
@ -347,7 +346,7 @@ func Run(config *RunConfig) (*RunOutput, error) {
|
|||
|
||||
func getComponentsPath(config *RunConfig) (string, error) {
|
||||
if config.ComponentsPath == "" {
|
||||
componentsPath := utils.GetDefaultComponentsFolder()
|
||||
componentsPath := getDefaultComponentsFolder()
|
||||
fmt.Println("Read components: ", componentsPath)
|
||||
return componentsPath, nil
|
||||
}
|
||||
|
|
|
@ -393,7 +393,7 @@ func createComponentsDir(wg *sync.WaitGroup, errorChan chan<- error, dir, versio
|
|||
defer wg.Done()
|
||||
|
||||
// Make default components directory under install path
|
||||
componentsDir := utils.GetDefaultComponentsFolder()
|
||||
componentsDir := getDefaultComponentsFolder()
|
||||
fmt.Println("Creating default components dir: ", componentsDir)
|
||||
_, err := os.Stat(componentsDir)
|
||||
if os.IsNotExist(err) {
|
||||
|
|
|
@ -50,7 +50,7 @@ func removeContainers(uninstallAll bool, dockerNetwork string) []error {
|
|||
}
|
||||
|
||||
func removeDefaultComponentsFolder() error {
|
||||
defaultComponentsPath := utils.GetDefaultComponentsFolder()
|
||||
defaultComponentsPath := getDefaultComponentsFolder()
|
||||
fmt.Println("Cleaning up default Components folder: ", defaultComponentsPath)
|
||||
err := os.RemoveAll(defaultComponentsPath)
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
path_filepath "path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/client"
|
||||
|
@ -122,13 +121,3 @@ func IsDockerInstalled() bool {
|
|||
_, err = cli.Ping(context.Background())
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// GetDefaultComponentsFolder returns the hidden .components folder created under install directory at init time
|
||||
func GetDefaultComponentsFolder() string {
|
||||
const daprDirName = ".dapr"
|
||||
const componentsDirName = "components"
|
||||
daprDirPath := os.Getenv("HOME")
|
||||
|
||||
defaultComponentsPath := path_filepath.Join(daprDirPath, daprDirName, componentsDirName)
|
||||
return defaultComponentsPath
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue