Skip to content

Commit 9aca70f

Browse files
committed
fix: download once
1 parent 5e5017f commit 9aca70f

4 files changed

Lines changed: 34 additions & 3 deletions

File tree

pkg/devspace/dependency/util/util.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,34 @@ func init() {
3636
// downloadMutex makes sure we only download a single dependency at a time
3737
var downloadMutex = sync.Mutex{}
3838

39+
func GetDependencyPath(workingDirectory string, source *latest.SourceConfig) (configPath string, err error) {
40+
ID, err := GetDependencyID(source)
41+
if err != nil {
42+
return "", err
43+
}
44+
45+
// Resolve source
46+
var localPath string
47+
if source.Git != "" {
48+
localPath = filepath.Join(DependencyFolderPath, ID)
49+
} else if source.Path != "" {
50+
if isURL(source.Path) {
51+
localPath = filepath.Join(DependencyFolderPath, ID)
52+
} else {
53+
if filepath.IsAbs(source.Path) {
54+
localPath = source.Path
55+
} else {
56+
localPath, err = filepath.Abs(filepath.Join(workingDirectory, filepath.FromSlash(source.Path)))
57+
if err != nil {
58+
return "", errors.Wrap(err, "filepath absolute")
59+
}
60+
}
61+
}
62+
}
63+
64+
return getDependencyConfigPath(localPath, source)
65+
}
66+
3967
func DownloadDependency(ctx context.Context, workingDirectory string, source *latest.SourceConfig, log log.Logger) (configPath string, err error) {
4068
downloadMutex.Lock()
4169
defer downloadMutex.Unlock()

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ func (d *DeployConfig) Deploy(ctx devspacecontext.Context, forceDeploy bool) (bo
5959
chartPath = ctx.ResolvePath(chartPath)
6060

6161
// Check if the chart directory has changed
62-
hash, err = hashpkg.Directory(chartPath)
62+
hash, err = hashpkg.DirectoryExcludes(chartPath, []string{
63+
".git/",
64+
".devspace/",
65+
}, true)
6366
if err != nil {
6467
return false, errors.Errorf("Error hashing chart directory: %v", err)
6568
}

pkg/devspace/helm/v3/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ func (c *client) InstallChart(ctx devspacecontext.Context, releaseName string, r
6565
// Chart settings
6666
chartName := ""
6767
if helmConfig.Chart.Source != nil {
68-
chartName, err = c.DownloadChart(ctx, helmConfig)
68+
chartName, err = dependencyutil.GetDependencyPath(ctx.WorkingDir(), helmConfig.Chart.Source)
6969
if err != nil {
7070
return nil, err
7171
}
7272

73+
chartName = filepath.Dir(chartName)
7374
args = append(args, chartName)
7475
} else {
7576
var chartRepo string

pkg/util/hash/hash.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ func Directory(path string) (string, error) {
7373

7474
return nil
7575
})
76-
7776
if err != nil {
7877
return "", err
7978
}

0 commit comments

Comments
 (0)