Skip to content

Commit 0e06b0d

Browse files
committed
fix: git deployment fixes
1 parent 1ddcce5 commit 0e06b0d

6 files changed

Lines changed: 61 additions & 52 deletions

File tree

cmd/run_pipeline.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,10 @@ func (cmd *RunPipelineCmd) Run(cobraCmd *cobra.Command, args []string, f factory
147147
// Print upgrade message if new version available
148148
if !cmd.Render {
149149
upgrade.PrintUpgradeMessage(cmd.log)
150+
} else {
151+
cmd.RenderWriter = os.Stdout
150152
}
153+
151154
if cobraCmd != nil {
152155
plugin.SetPluginCommand(cobraCmd, args)
153156
}

pkg/devspace/config/versions/latest/schema.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,6 @@ type HelmConfig struct {
734734
TemplateArgs []string `yaml:"templateArgs,omitempty" json:"templateArgs,omitempty"`
735735
// UpgradeArgs are additional arguments to pass to `helm upgrade`
736736
UpgradeArgs []string `yaml:"upgradeArgs,omitempty" json:"upgradeArgs,omitempty"`
737-
// FetchArgs are additional arguments to pass to `helm fetch`
738-
FetchArgs []string `yaml:"fetchArgs,omitempty" json:"fetchArgs,omitempty"`
739737
}
740738

741739
// ChartConfig defines the helm chart options

pkg/devspace/config/versions/v1beta11/upgrade.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,9 @@ func (c *Config) Upgrade(log log.Logger) (config.Config, error) {
425425
DisplayOutput: deployment.Helm.DisplayOutput,
426426
TemplateArgs: deployment.Helm.TemplateArgs,
427427
UpgradeArgs: deployment.Helm.UpgradeArgs,
428-
FetchArgs: deployment.Helm.FetchArgs,
428+
}
429+
if len(deployment.Helm.FetchArgs) > 0 {
430+
log.Warnf("deployments[*].helm.fetchArgs is not supported anymore in DevSpace v6")
429431
}
430432
if deployment.Helm.Driver != "" {
431433
log.Warnf("deployments[*].helm.driver is not supported anymore in DevSpace v6")

pkg/devspace/deploy/deploy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func (c *controller) deployOne(ctx *devspacecontext.Context, deployConfig *lates
265265
if err != nil {
266266
return true, err
267267
}
268-
} else {
268+
} else if !options.Render {
269269
ctx.Log.Infof("Skipping deployment %s", deployConfig.Name)
270270
// Execute skip deploy hook
271271
err = hook.ExecuteHooks(ctx, map[string]interface{}{

pkg/devspace/helm/generic/generic.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import (
66
devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context"
77
"github.com/loft-sh/devspace/pkg/util/command"
88
"io/ioutil"
9-
"os"
10-
"path/filepath"
119
"strings"
1210

1311
"gopkg.in/yaml.v3"
@@ -25,7 +23,6 @@ const stableChartRepo = "https://charts.helm.sh/stable"
2523

2624
type Client interface {
2725
Exec(ctx *devspacecontext.Context, args []string) ([]byte, error)
28-
FetchChart(ctx *devspacecontext.Context, helmConfig *latest.HelmConfig) (bool, string, error)
2926
WriteValues(values map[string]interface{}) (string, error)
3027
}
3128

@@ -98,39 +95,6 @@ func (c *client) ensureHelmBinary(ctx context.Context) error {
9895
return err
9996
}
10097

101-
func (c *client) FetchChart(ctx *devspacecontext.Context, helmConfig *latest.HelmConfig) (bool, string, error) {
102-
chartName, chartRepo := ChartNameAndRepo(helmConfig)
103-
if chartRepo == "" {
104-
return false, chartName, nil
105-
}
106-
107-
tempFolder, err := ioutil.TempDir("", "")
108-
if err != nil {
109-
return false, "", err
110-
}
111-
112-
args := []string{"fetch", chartName, "--repo", chartRepo, "--untar", "--untardir", tempFolder}
113-
if helmConfig.Chart.Version != "" {
114-
args = append(args, "--version", helmConfig.Chart.Version)
115-
}
116-
if helmConfig.Chart.Username != "" {
117-
args = append(args, "--username", helmConfig.Chart.Username)
118-
}
119-
if helmConfig.Chart.Password != "" {
120-
args = append(args, "--password", helmConfig.Chart.Password)
121-
}
122-
args = append(args, "--repository-config=''")
123-
124-
args = append(args, helmConfig.FetchArgs...)
125-
out, err := c.Exec(ctx, args)
126-
if err != nil {
127-
_ = os.RemoveAll(tempFolder)
128-
return false, "", fmt.Errorf("error running helm fetch: %s => %v", string(out), err)
129-
}
130-
131-
return true, filepath.Join(tempFolder, chartName), nil
132-
}
133-
13498
func ChartNameAndRepo(helmConfig *latest.HelmConfig) (string, string) {
13599
chartName := strings.TrimSpace(helmConfig.Chart.Name)
136100
chartRepo := helmConfig.Chart.RepoURL

pkg/devspace/helm/v3/client.go

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,18 @@ func (c *client) InstallChart(ctx *devspacecontext.Context, releaseName string,
5050
}
5151

5252
// Chart settings
53+
chartName := ""
5354
if helmConfig.Chart.Source != nil {
54-
chartName, err := dependencyutil.DownloadDependency(ctx.Context, ctx.WorkingDir, helmConfig.Chart.Source, ctx.Log)
55+
chartName, err = dependencyutil.DownloadDependency(ctx.Context, ctx.WorkingDir, helmConfig.Chart.Source, ctx.Log)
5556
if err != nil {
5657
return nil, err
5758
}
5859

5960
chartName = filepath.Dir(chartName)
6061
args = append(args, chartName)
6162
} else {
62-
chartName, chartRepo := generic.ChartNameAndRepo(helmConfig)
63+
var chartRepo string
64+
chartName, chartRepo = generic.ChartNameAndRepo(helmConfig)
6365
args = append(args, chartName)
6466
if chartRepo != "" {
6567
args = append(args, "--repo", chartRepo)
@@ -76,6 +78,15 @@ func (c *client) InstallChart(ctx *devspacecontext.Context, releaseName string,
7678
}
7779
}
7880

81+
// Update dependencies if needed
82+
stat, err := os.Stat(chartName)
83+
if err == nil && stat.IsDir() {
84+
_, err := c.genericHelm.Exec(ctx.WithWorkingDir(chartName), []string{"dependency", "update"})
85+
if err != nil {
86+
ctx.Log.Warnf("error running helm dependency update: %v", err)
87+
}
88+
}
89+
7990
// Upgrade options
8091
args = append(args, helmConfig.UpgradeArgs...)
8192
output, err := c.genericHelm.Exec(ctx, args)
@@ -103,32 +114,63 @@ func (c *client) InstallChart(ctx *devspacecontext.Context, releaseName string,
103114
}
104115

105116
func (c *client) Template(ctx *devspacecontext.Context, releaseName, releaseNamespace string, values map[string]interface{}, helmConfig *latest.HelmConfig) (string, error) {
106-
cleanup, chartDir, err := c.genericHelm.FetchChart(ctx, helmConfig)
117+
valuesFile, err := c.genericHelm.WriteValues(values)
107118
if err != nil {
108119
return "", err
109-
} else if cleanup {
110-
defer os.RemoveAll(filepath.Dir(chartDir))
111120
}
121+
defer os.Remove(valuesFile)
112122

113123
if releaseNamespace == "" {
114124
releaseNamespace = ctx.KubeClient.Namespace()
115125
}
116126

117-
valuesFile, err := c.genericHelm.WriteValues(values)
118-
if err != nil {
119-
return "", err
120-
}
121-
defer os.Remove(valuesFile)
122-
123127
args := []string{
124128
"template",
125129
releaseName,
126-
chartDir,
127130
"--namespace",
128131
releaseNamespace,
129132
"--values",
130133
valuesFile,
131134
}
135+
136+
// Chart settings
137+
chartName := ""
138+
if helmConfig.Chart.Source != nil {
139+
chartName, err = dependencyutil.DownloadDependency(ctx.Context, ctx.WorkingDir, helmConfig.Chart.Source, ctx.Log)
140+
if err != nil {
141+
return "", err
142+
}
143+
144+
chartName = filepath.Dir(chartName)
145+
args = append(args, chartName)
146+
} else {
147+
var chartRepo string
148+
chartName, chartRepo = generic.ChartNameAndRepo(helmConfig)
149+
args = append(args, chartName)
150+
if chartRepo != "" {
151+
args = append(args, "--repo", chartRepo)
152+
args = append(args, "--repository-config=''")
153+
}
154+
if helmConfig.Chart.Version != "" {
155+
args = append(args, "--version", helmConfig.Chart.Version)
156+
}
157+
if helmConfig.Chart.Username != "" {
158+
args = append(args, "--username", helmConfig.Chart.Username)
159+
}
160+
if helmConfig.Chart.Password != "" {
161+
args = append(args, "--password", helmConfig.Chart.Password)
162+
}
163+
}
164+
165+
// Update dependencies if needed
166+
stat, err := os.Stat(chartName)
167+
if err == nil && stat.IsDir() {
168+
_, err := c.genericHelm.Exec(ctx.WithWorkingDir(chartName), []string{"dependency", "update"})
169+
if err != nil {
170+
ctx.Log.Warnf("error running helm dependency update: %v", err)
171+
}
172+
}
173+
132174
args = append(args, helmConfig.TemplateArgs...)
133175
result, err := c.genericHelm.Exec(ctx, args)
134176
if err != nil {

0 commit comments

Comments
 (0)