forked from helm/helm-classic
/
publish.go
40 lines (33 loc) · 922 Bytes
/
publish.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package action
import "os"
import (
"github.com/helm/helm/log"
helm "github.com/helm/helm/util"
)
// Publish a chart from the workspace to the cache directory
//
// - chartName being published
// - homeDir is the helm home directory for the user
// - force publishing even if the chart directory already exists
func Publish(chartName, homeDir, repo string, force bool) {
if repo == "" {
repo = "charts"
}
if !mustConfig(homeDir).Repos.Exists(repo) {
log.Err("Repo %s does not exist", repo)
log.Info("Available repositories")
ListRepos(homeDir)
return
}
src := helm.WorkspaceChartDirectory(homeDir, chartName)
dst := helm.CacheDirectory(homeDir, repo, chartName)
if _, err := os.Stat(dst); err == nil {
if force != true {
log.Info("chart already exists, use -f to force")
return
}
}
if err := helm.CopyDir(src, dst); err != nil {
log.Die("failed to publish directory: %v", err)
}
}