Move to internal

Signed-off-by: John Howard <howardjohn@google.com>
pull/6609/head
John Howard 6 years ago
parent cc579781b5
commit db5358965e

@ -1,5 +1,5 @@
/* /*
Copyright The Helm Authors. Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with 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. limitations under the License.
*/ */
package kube package util
import ( import (
"sort" "sort"
@ -27,8 +27,9 @@ import (
appsclient "k8s.io/client-go/kubernetes/typed/apps/v1" 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 // deploymentutil contains a copy of a few functions from Kubernetes controller code to avoid a dependency on k8s.io/kubernetes.
// 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. // RsListFunc returns the ReplicaSet from the ReplicaSet namespace and the List metav1.ListOptions.
type RsListFunc func(string, metav1.ListOptions) ([]*apps.ReplicaSet, error) type RsListFunc func(string, metav1.ListOptions) ([]*apps.ReplicaSet, error)

@ -45,6 +45,9 @@ func Expand(dir string, r io.Reader) error {
if err := yaml.Unmarshal(file.Data, ch); err != nil { if err := yaml.Unmarshal(file.Data, ch); err != nil {
return errors.Wrap(err, "cannot load Chart.yaml") return errors.Wrap(err, "cannot load Chart.yaml")
} }
if err != nil {
return err
}
chartName = ch.Name chartName = ch.Name
} }
} }

@ -36,6 +36,8 @@ import (
"k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/kubernetes/scheme"
deploymentutil "helm.sh/helm/v3/internal/third_party/k8s.io/kubernetes/deployment/util"
) )
type waiter struct { type waiter struct {
@ -74,7 +76,7 @@ func (w *waiter) waitForResources(created ResourceList) error {
continue continue
} }
// Find RS associated with deployment // 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 { if err != nil || newReplicaSet == nil {
return false, err return false, err
} }
@ -91,7 +93,7 @@ func (w *waiter) waitForResources(created ResourceList) error {
continue continue
} }
// Find RS associated with deployment // 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 { if err != nil || newReplicaSet == nil {
return false, err return false, err
} }
@ -108,7 +110,7 @@ func (w *waiter) waitForResources(created ResourceList) error {
continue continue
} }
// Find RS associated with deployment // 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 { if err != nil || newReplicaSet == nil {
return false, err return false, err
} }
@ -125,7 +127,7 @@ func (w *waiter) waitForResources(created ResourceList) error {
continue continue
} }
// Find RS associated with deployment // 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 { if err != nil || newReplicaSet == nil {
return false, err 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 { 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) { 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) 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 return false

Loading…
Cancel
Save