Skip to content

Commit

Permalink
Merge pull request #383 from covexo/improve-config-overwrite
Browse files Browse the repository at this point in the history
Fix issue with relative path in config loading
  • Loading branch information
FabianKramm committed Nov 13, 2018
2 parents db5b68d + ae7e35f commit 3809107
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
1 change: 0 additions & 1 deletion cmd/up.go
Expand Up @@ -118,7 +118,6 @@ func (cmd *UpCmd) Run(cobraCmd *cobra.Command, args []string) {

configExists, _ := configutil.ConfigExists()
if !configExists {
log.Info("Config does not exist")
initFlags := &InitCmdFlags{
reconfigure: false,
overwrite: false,
Expand Down
4 changes: 1 addition & 3 deletions pkg/devspace/config/configutil/get.go
Expand Up @@ -54,9 +54,7 @@ var setDefaultsOnce sync.Once

// ConfigExists checks whether the yaml file for the config exists
func ConfigExists() (bool, error) {
workdir, _ := os.Getwd()

_, err := os.Stat(workdir + ConfigPath)
_, err := os.Stat(ConfigPath)
if os.IsNotExist(err) {
return false, nil
} else if err != nil {
Expand Down
5 changes: 1 addition & 4 deletions pkg/devspace/config/configutil/load.go
Expand Up @@ -2,16 +2,13 @@ package configutil

import (
"io/ioutil"
"os"
"path/filepath"

"github.com/covexo/devspace/pkg/devspace/config/v1"
yaml "gopkg.in/yaml.v2"
)

func loadConfig(config *v1.Config, path string) error {
workdir, _ := os.Getwd()
yamlFileContent, err := ioutil.ReadFile(filepath.Join(workdir, path))
yamlFileContent, err := ioutil.ReadFile(path)
if err != nil {
return err
}
Expand Down
8 changes: 3 additions & 5 deletions pkg/devspace/config/configutil/save.go
Expand Up @@ -16,8 +16,6 @@ func SaveConfig() error {
return nil
}

workdir, _ := os.Getwd()

// default and overwrite values
configToIgnore := makeConfig()

Expand All @@ -42,7 +40,7 @@ func SaveConfig() error {
return err
}

configDir := filepath.Dir(filepath.Join(workdir, ConfigPath))
configDir := filepath.Dir(ConfigPath)
os.MkdirAll(configDir, os.ModePerm)

// Check if .gitignore exists
Expand All @@ -51,7 +49,7 @@ func SaveConfig() error {
fsutil.WriteToFile([]byte(configGitignore), filepath.Join(configDir, ".gitignore"))
}

writeErr := ioutil.WriteFile(filepath.Join(workdir, ConfigPath), configYaml, os.ModePerm)
writeErr := ioutil.WriteFile(ConfigPath, configYaml, os.ModePerm)
if writeErr != nil {
return writeErr
}
Expand All @@ -62,7 +60,7 @@ func SaveConfig() error {
return err
}

return ioutil.WriteFile(filepath.Join(workdir, OverwriteConfigPath), overwriteConfigYaml, os.ModePerm)
return ioutil.WriteFile(OverwriteConfigPath, overwriteConfigYaml, os.ModePerm)
}

return nil
Expand Down

0 comments on commit 3809107

Please sign in to comment.