Skip to content

Commit 5e5017f

Browse files
committed
fix: use chart directory to detect chart changes
1 parent ff15f7e commit 5e5017f

4 files changed

Lines changed: 31 additions & 10 deletions

File tree

pkg/devspace/deploy/deployer/helm/deploy.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package helm
22

33
import (
44
"fmt"
5-
"github.com/loft-sh/devspace/pkg/devspace/config/versions"
65
"io"
76
"os"
87
"path/filepath"
98

9+
"github.com/loft-sh/devspace/pkg/devspace/config/versions"
10+
1011
"github.com/loft-sh/devspace/pkg/devspace/config/loader/variable/legacy"
1112
runtimevar "github.com/loft-sh/devspace/pkg/devspace/config/loader/variable/runtime"
1213
"github.com/loft-sh/devspace/pkg/devspace/config/remotecache"
@@ -44,6 +45,14 @@ func (d *DeployConfig) Deploy(ctx devspacecontext.Context, forceDeploy bool) (bo
4445
releaseNamespace = d.DeploymentConfig.Namespace
4546
}
4647

48+
if d.DeploymentConfig.Helm.Chart.Source != nil {
49+
downloadPath, err := d.Helm.DownloadChart(ctx, d.DeploymentConfig.Helm)
50+
if err != nil {
51+
return false, errors.Wrap(err, "download chart")
52+
}
53+
chartPath = downloadPath
54+
}
55+
4756
// Hash the chart directory if there is any
4857
_, err := os.Stat(ctx.ResolvePath(chartPath))
4958
if err == nil {

pkg/devspace/helm/testing/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ type Client struct {
1515
Releases []*types.Release
1616
}
1717

18+
func (f *Client) DownloadChart(ctx devspacecontext.Context, helmConfig *latest.HelmConfig) (string, error) {
19+
return "", nil
20+
}
21+
1822
// UpdateRepos implements interface
1923
func (f *Client) UpdateRepos() error {
2024
return nil

pkg/devspace/helm/types/interface.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
// Client is the client interface for helm
99
type Client interface {
10+
DownloadChart(ctx devspacecontext.Context, helmConfig *latest.HelmConfig) (string, error)
1011
InstallChart(ctx devspacecontext.Context, releaseName string, releaseNamespace string, values map[string]interface{}, helmConfig *latest.HelmConfig) (*Release, error)
1112
Template(ctx devspacecontext.Context, releaseName, releaseNamespace string, values map[string]interface{}, helmConfig *latest.HelmConfig) (string, error)
1213
DeleteRelease(ctx devspacecontext.Context, releaseName string, releaseNamespace string) error

pkg/devspace/helm/v3/client.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
package v3
22

33
import (
4-
devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context"
5-
dependencyutil "github.com/loft-sh/devspace/pkg/devspace/dependency/util"
6-
"github.com/pkg/errors"
7-
"github.com/sirupsen/logrus"
4+
"net/url"
85
"os"
96
"path/filepath"
107
"strconv"
118
"strings"
12-
"net/url"
9+
10+
devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context"
11+
dependencyutil "github.com/loft-sh/devspace/pkg/devspace/dependency/util"
12+
"github.com/pkg/errors"
13+
"github.com/sirupsen/logrus"
1314

1415
"github.com/ghodss/yaml"
1516
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
@@ -30,6 +31,14 @@ func NewClient(log log.Logger) (types.Client, error) {
3031
return c, nil
3132
}
3233

34+
func (c *client) DownloadChart(ctx devspacecontext.Context, helmConfig *latest.HelmConfig) (string, error) {
35+
chartName, err := dependencyutil.DownloadDependency(ctx.Context(), ctx.WorkingDir(), helmConfig.Chart.Source, ctx.Log())
36+
if err != nil {
37+
return "", err
38+
}
39+
return filepath.Dir(chartName), nil
40+
}
41+
3342
// InstallChart installs the given chart via helm v3
3443
func (c *client) InstallChart(ctx devspacecontext.Context, releaseName string, releaseNamespace string, values map[string]interface{}, helmConfig *latest.HelmConfig) (*types.Release, error) {
3544
valuesFile, err := c.genericHelm.WriteValues(values)
@@ -56,12 +65,11 @@ func (c *client) InstallChart(ctx devspacecontext.Context, releaseName string, r
5665
// Chart settings
5766
chartName := ""
5867
if helmConfig.Chart.Source != nil {
59-
chartName, err = dependencyutil.DownloadDependency(ctx.Context(), ctx.WorkingDir(), helmConfig.Chart.Source, ctx.Log())
68+
chartName, err = c.DownloadChart(ctx, helmConfig)
6069
if err != nil {
6170
return nil, err
6271
}
6372

64-
chartName = filepath.Dir(chartName)
6573
args = append(args, chartName)
6674
} else {
6775
var chartRepo string
@@ -157,12 +165,11 @@ func (c *client) Template(ctx devspacecontext.Context, releaseName, releaseNames
157165
// Chart settings
158166
chartName := ""
159167
if helmConfig.Chart.Source != nil {
160-
chartName, err = dependencyutil.DownloadDependency(ctx.Context(), ctx.WorkingDir(), helmConfig.Chart.Source, ctx.Log())
168+
chartName, err = c.DownloadChart(ctx, helmConfig)
161169
if err != nil {
162170
return "", err
163171
}
164172

165-
chartName = filepath.Dir(chartName)
166173
args = append(args, chartName)
167174
} else {
168175
var chartRepo string

0 commit comments

Comments
 (0)