Skip to content

Commit

Permalink
fix non-existing component dir error (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaron2 authored Nov 6, 2019
1 parent 997ab8c commit d793380
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/standalone/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ func createRedisStateStore(redisHost string) error {
return err
}

os.Mkdir(componentsDir, 0777)
err = ioutil.WriteFile(path.Join(componentsDir, redisStateStoreYamlFileName), b, 0644)
if err != nil {
return err
Expand All @@ -194,6 +193,13 @@ func createRedisStateStore(redisHost string) error {
return nil
}

func createDirectory(dir string) error {
if _, err := os.Stat(dir); !os.IsNotExist(err) {
return nil
}
return os.Mkdir(dir, 0777)
}

func createRedisPubSub(redisHost string) error {
redisMessageBus := component{
APIVersion: "dapr.io/v1alpha1",
Expand Down Expand Up @@ -222,7 +228,6 @@ func createRedisPubSub(redisHost string) error {
return err
}

os.Mkdir(componentsDir, 0777)
err = ioutil.WriteFile(path.Join(componentsDir, redisMessageBusYamlFileName), b, 0644)
if err != nil {
return err
Expand Down Expand Up @@ -252,6 +257,10 @@ func Run(config *RunConfig) (*RunOutput, error) {
if err != nil {
return nil, err
}
err = createDirectory(componentsDir)
if err != nil {
return nil, err
}

componentsLoader := components.NewStandaloneComponents(modes.StandaloneConfig{ComponentsPath: componentsDir})
components, err := componentsLoader.LoadComponents()
Expand Down

0 comments on commit d793380

Please sign in to comment.