MCPcopy Index your code
hub / github.com/devspace-sh/devspace / Deploy

Method Deploy

pkg/devspace/deploy/deployer/helm/deploy.go:30–170  ·  view source on GitHub ↗

Deploy deploys the given deployment with helm

(ctx devspacecontext.Context, forceDeploy bool)

Source from the content-addressed store, hash-verified

28
29// Deploy deploys the given deployment with helm
30func (d *DeployConfig) Deploy(ctx devspacecontext.Context, forceDeploy bool) (bool, error) {
31 var releaseName string
32 if d.DeploymentConfig.Helm.ReleaseName != "" {
33 releaseName = d.DeploymentConfig.Helm.ReleaseName
34 } else {
35 releaseName = d.DeploymentConfig.Name
36 }
37
38 var (
39 chartPath = d.DeploymentConfig.Helm.Chart.Name
40 hash = ""
41 )
42
43 releaseNamespace := ctx.KubeClient().Namespace()
44 if d.DeploymentConfig.Namespace != "" {
45 releaseNamespace = d.DeploymentConfig.Namespace
46 }
47
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
56 // Hash the chart directory if there is any
57 _, err := os.Stat(ctx.ResolvePath(chartPath))
58 if err == nil {
59 chartPath = ctx.ResolvePath(chartPath)
60
61 // Check if the chart directory has changed
62 hash, err = hashpkg.DirectoryExcludes(chartPath, []string{
63 ".git/",
64 ".devspace/",
65 }, true)
66 if err != nil {
67 return false, errors.Errorf("Error hashing chart directory: %v", err)
68 }
69 }
70
71 // Ensure deployment config is there
72 deployCache, _ := ctx.Config().RemoteCache().GetDeployment(releaseName)
73
74 // Check values files for changes
75 helmOverridesHash := ""
76 if d.DeploymentConfig.Helm.ValuesFiles != nil {
77 for _, override := range d.DeploymentConfig.Helm.ValuesFiles {
78 override = ctx.ResolvePath(override)
79
80 hash, err := hashpkg.Directory(override)
81 if err != nil {
82 return false, errors.Errorf("Error stating override file %s: %v", override, err)
83 }
84
85 helmOverridesHash += hash
86 }
87 }

Callers 1

TestDeployFunction · 0.95

Calls 15

getDeploymentValuesMethod · 0.95
internalDeployMethod · 0.95
NewClientFunction · 0.92
RootNameFromFunction · 0.92
ContainsFunction · 0.92
NamespaceMethod · 0.65
KubeClientMethod · 0.65
DownloadChartMethod · 0.65
ResolvePathMethod · 0.65
GetDeploymentMethod · 0.65
RemoteCacheMethod · 0.65
ConfigMethod · 0.65

Tested by 1

TestDeployFunction · 0.76