@@ -39,6 +39,7 @@ import (
3939 helmenvironment "k8s.io/helm/pkg/helm/environment"
4040 "k8s.io/helm/pkg/helm/helmpath"
4141 "k8s.io/helm/pkg/helm/portforwarder"
42+ "k8s.io/helm/pkg/proto/hapi/chart"
4243 hapi_release5 "k8s.io/helm/pkg/proto/hapi/release"
4344 rls "k8s.io/helm/pkg/proto/hapi/services"
4445 helmstoragedriver "k8s.io/helm/pkg/storage/driver"
@@ -203,7 +204,7 @@ func ensureTiller(kubectlClient *kubernetes.Clientset, config *v1.Config, upgrad
203204 tillerOptions := & helminstaller.Options {
204205 Namespace : tillerNamespace ,
205206 MaxHistory : 10 ,
206- ImageSpec : "gcr.io/kubernetes-helm/tiller:v2.9.1 " ,
207+ ImageSpec : "gcr.io/kubernetes-helm/tiller:v2.10.0 " ,
207208 ServiceAccount : tillerSA .ObjectMeta .Name ,
208209 }
209210
@@ -515,43 +516,60 @@ func (helmClientWrapper *HelmClientWrapper) ReleaseExists(releaseName string) (b
515516 return true , nil
516517}
517518
519+ func checkDependencies (ch * chart.Chart , reqs * helmchartutil.Requirements ) error {
520+ missing := []string {}
521+
522+ deps := ch .GetDependencies ()
523+ for _ , r := range reqs .Dependencies {
524+ found := false
525+ for _ , d := range deps {
526+ if d .Metadata .Name == r .Name {
527+ found = true
528+ break
529+ }
530+ }
531+ if ! found {
532+ missing = append (missing , r .Name )
533+ }
534+ }
535+
536+ if len (missing ) > 0 {
537+ return fmt .Errorf ("found in requirements.yaml, but missing in charts/ directory: %s" , strings .Join (missing , ", " ))
538+ }
539+ return nil
540+ }
541+
518542// InstallChartByPath installs the given chartpath und the releasename in the releasenamespace
519543func (helmClientWrapper * HelmClientWrapper ) InstallChartByPath (releaseName string , releaseNamespace string , chartPath string , values * map [interface {}]interface {}) (* hapi_release5.Release , error ) {
520544 chart , err := helmchartutil .Load (chartPath )
521545 if err != nil {
522546 return nil , err
523547 }
524548
525- chartDependencies := chart .GetDependencies ()
526-
527- if len (chartDependencies ) > 0 {
528- _ , err = helmchartutil .LoadRequirements (chart )
529-
530- if err != nil {
531- return nil , err
532- }
533- chartDownloader := & helmdownloader.Manager {
534- /* Out: i.out,
535- ChartPath: i.chartPath,
536- HelmHome: settings.Home,
537- Keyring: defaultKeyring(),
538- SkipUpdate: false,
539- Getters: getter.All(settings),
540- */
541- }
542- err = chartDownloader .Update ()
543-
544- if err != nil {
545- return nil , err
546- }
547- chart , err = helmchartutil .Load (chartPath )
549+ if req , err := helmchartutil .LoadRequirements (chart ); err == nil {
550+ // If checkDependencies returns an error, we have unfulfilled dependencies.
551+ // As of Helm 2.4.0, this is treated as a stopping condition:
552+ // https://github.com/kubernetes/helm/issues/2209
553+ if err := checkDependencies (chart , req ); err != nil {
554+ man := & helmdownloader.Manager {
555+ Out : ioutil .Discard ,
556+ ChartPath : chartPath ,
557+ HelmHome : helmClientWrapper .Settings .Home ,
558+ Getters : getter .All (* helmClientWrapper .Settings ),
559+ }
560+ if err := man .Update (); err != nil {
561+ return nil , err
562+ }
548563
549- if err != nil {
550- return nil , err
564+ // Update all dependencies which are present in /charts.
565+ chart , err = helmchartutil .Load (chartPath )
566+ if err != nil {
567+ return nil , err
568+ }
551569 }
552570 }
553- releaseExists , err := helmClientWrapper .ReleaseExists (releaseName )
554571
572+ releaseExists , err := helmClientWrapper .ReleaseExists (releaseName )
555573 if err != nil {
556574 return nil , err
557575 }
0 commit comments