Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,25 @@ func (cmd *AddCmd) RunAddPackage(cobraCmd *cobra.Command, args []string) {
log.Fatal(err)
}

f, err := os.OpenFile(filepath.Join(cwd, "chart", "values.yaml"), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
// Check if key already exists
valuesYaml := filepath.Join(cwd, "chart", "values.yaml")
valuesYamlContents := map[interface{}]interface{}{}

err = yamlutil.ReadYamlFromFile(valuesYaml, valuesYamlContents)
if err != nil {
log.Fatal(err)
log.Fatalf("Error parsing %s: %v", valuesYaml, err)
}

defer f.Close()
if _, err = f.WriteString("\n" + version.GetName() + ": {}\n"); err != nil {
log.Fatal(err)
if _, ok := valuesYamlContents[version.GetName()]; ok == false {
f, err := os.OpenFile(valuesYaml, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
log.Fatal(err)
}

defer f.Close()
if _, err = f.WriteString("\n# Here you can specify the subcharts values (for more information see: https://github.com/helm/helm/blob/master/docs/chart_template_guide/subcharts_and_globals.md#overriding-values-from-a-parent-chart)\n" + version.GetName() + ": {}\n"); err != nil {
log.Fatal(err)
}
}

log.Donef("Successfully added %s as chart dependency, you can configure the package in 'chart/values.yaml'", version.GetName())
Expand Down
13 changes: 11 additions & 2 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"regexp"
"strconv"
Expand Down Expand Up @@ -542,11 +543,19 @@ func (cmd *InitCmd) configureRegistry() {

if isGoogleRegistry {
if len(defaultImageNameParts) < 2 {
project, err := exec.Command("gcloud", "config", "get-value", "project").Output()
gcloudProject := ""

if err == nil {
gcloudProject = strings.TrimSpace(string(project))
}

gcloudProjectName := stdinutil.GetFromStdin(&stdinutil.GetFromStdinParams{
Question: "What is the name of your Google Cloud Project? (run 'gcloud config get-value project' to get the project name)",
DefaultValue: "",
Question: "What Google Cloud Project should be used?",
DefaultValue: gcloudProject,
ValidationRegexPattern: "^.*$",
})

cmd.defaultImage.Name = configutil.String(*gcloudProjectName + "/" + strings.TrimPrefix(defaultImageName, *gcloudProjectName))
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (cmd *StatusCmd) getDevspaceStatus() ([]string, error) {
return nil, err
}

if len(releases.Releases) == 0 {
if releases == nil || len(releases.Releases) == 0 {
return nil, errors.New("No release found")
}

Expand Down