diff --git a/pkg/kube/deploymentutil.go b/internal/third_party/k8s.io/kubernetes/deployment/util/deploymentutil.go similarity index 95% rename from pkg/kube/deploymentutil.go rename to internal/third_party/k8s.io/kubernetes/deployment/util/deploymentutil.go index e10dfbaee..da93a6910 100644 --- a/pkg/kube/deploymentutil.go +++ b/internal/third_party/k8s.io/kubernetes/deployment/util/deploymentutil.go @@ -1,5 +1,5 @@ /* -Copyright The Helm Authors. +Copyright 2016 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package kube +package util import ( "sort" @@ -27,8 +27,9 @@ import ( appsclient "k8s.io/client-go/kubernetes/typed/apps/v1" ) -// deploymentutil contains a copy of a few functions from Kubernetes controller code to avoid a dependency -// on k8s.io/kubernetes. +// deploymentutil contains a copy of a few functions from Kubernetes controller code to avoid a dependency on k8s.io/kubernetes. +// This code is copied from https://github.com/kubernetes/kubernetes/blob/e856613dd5bb00bcfaca6974431151b5c06cbed5/pkg/controller/deployment/util/deployment_util.go +// No changes to the code were made other than removing some unused functions // RsListFunc returns the ReplicaSet from the ReplicaSet namespace and the List metav1.ListOptions. type RsListFunc func(string, metav1.ListOptions) ([]*apps.ReplicaSet, error) diff --git a/pkg/chartutil/expand.go b/pkg/chartutil/expand.go index 6ad09e417..87a5f88af 100644 --- a/pkg/chartutil/expand.go +++ b/pkg/chartutil/expand.go @@ -45,6 +45,9 @@ func Expand(dir string, r io.Reader) error { if err := yaml.Unmarshal(file.Data, ch); err != nil { return errors.Wrap(err, "cannot load Chart.yaml") } + if err != nil { + return err + } chartName = ch.Name } } diff --git a/pkg/kube/wait.go b/pkg/kube/wait.go index b05ffad78..a526de198 100644 --- a/pkg/kube/wait.go +++ b/pkg/kube/wait.go @@ -36,6 +36,8 @@ import ( "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" + + deploymentutil "helm.sh/helm/v3/internal/third_party/k8s.io/kubernetes/deployment/util" ) type waiter struct { @@ -74,7 +76,7 @@ func (w *waiter) waitForResources(created ResourceList) error { continue } // Find RS associated with deployment - newReplicaSet, err := GetNewReplicaSet(currentDeployment, w.c.AppsV1()) + newReplicaSet, err := deploymentutil.GetNewReplicaSet(currentDeployment, w.c.AppsV1()) if err != nil || newReplicaSet == nil { return false, err } @@ -91,7 +93,7 @@ func (w *waiter) waitForResources(created ResourceList) error { continue } // Find RS associated with deployment - newReplicaSet, err := GetNewReplicaSet(currentDeployment, w.c.AppsV1()) + newReplicaSet, err := deploymentutil.GetNewReplicaSet(currentDeployment, w.c.AppsV1()) if err != nil || newReplicaSet == nil { return false, err } @@ -108,7 +110,7 @@ func (w *waiter) waitForResources(created ResourceList) error { continue } // Find RS associated with deployment - newReplicaSet, err := GetNewReplicaSet(currentDeployment, w.c.AppsV1()) + newReplicaSet, err := deploymentutil.GetNewReplicaSet(currentDeployment, w.c.AppsV1()) if err != nil || newReplicaSet == nil { return false, err } @@ -125,7 +127,7 @@ func (w *waiter) waitForResources(created ResourceList) error { continue } // Find RS associated with deployment - newReplicaSet, err := GetNewReplicaSet(currentDeployment, w.c.AppsV1()) + newReplicaSet, err := deploymentutil.GetNewReplicaSet(currentDeployment, w.c.AppsV1()) if err != nil || newReplicaSet == nil { return false, err } @@ -259,7 +261,7 @@ func (w *waiter) volumeReady(v *corev1.PersistentVolumeClaim) bool { } func (w *waiter) deploymentReady(rs *appsv1.ReplicaSet, dep *appsv1.Deployment) bool { - expectedReady := *dep.Spec.Replicas - MaxUnavailable(*dep) + expectedReady := *dep.Spec.Replicas - deploymentutil.MaxUnavailable(*dep) if !(rs.Status.ReadyReplicas >= expectedReady) { w.log("Deployment is not ready: %s/%s. %d out of %d expected pods are ready", dep.Namespace, dep.Name, rs.Status.ReadyReplicas, expectedReady) return false