|
|
@ -27,10 +27,12 @@ import (
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
jsonpatch "github.com/evanphx/json-patch"
|
|
|
|
jsonpatch "github.com/evanphx/json-patch"
|
|
|
|
apps "k8s.io/api/apps/v1beta2"
|
|
|
|
appsv1 "k8s.io/api/apps/v1"
|
|
|
|
|
|
|
|
appsv1beta1 "k8s.io/api/apps/v1beta1"
|
|
|
|
|
|
|
|
appsv1beta2 "k8s.io/api/apps/v1beta2"
|
|
|
|
batch "k8s.io/api/batch/v1"
|
|
|
|
batch "k8s.io/api/batch/v1"
|
|
|
|
"k8s.io/api/core/v1"
|
|
|
|
"k8s.io/api/core/v1"
|
|
|
|
"k8s.io/api/extensions/v1beta1"
|
|
|
|
extv1beta1 "k8s.io/api/extensions/v1beta1"
|
|
|
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
|
|
|
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
|
|
|
"k8s.io/apimachinery/pkg/api/errors"
|
|
|
|
"k8s.io/apimachinery/pkg/api/errors"
|
|
|
|
"k8s.io/apimachinery/pkg/api/meta"
|
|
|
|
"k8s.io/apimachinery/pkg/api/meta"
|
|
|
@ -428,9 +430,7 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object,
|
|
|
|
if err := target.Get(); err != nil {
|
|
|
|
if err := target.Get(); err != nil {
|
|
|
|
return fmt.Errorf("error trying to refresh resource information: %v", err)
|
|
|
|
return fmt.Errorf("error trying to refresh resource information: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// send patch to server
|
|
|
|
// send patch to server
|
|
|
|
helper := resource.NewHelper(target.Client, target.Mapping)
|
|
|
|
helper := resource.NewHelper(target.Client, target.Mapping)
|
|
|
|
|
|
|
|
|
|
|
@ -463,6 +463,7 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object,
|
|
|
|
// When patch succeeds without needing to recreate, refresh target.
|
|
|
|
// When patch succeeds without needing to recreate, refresh target.
|
|
|
|
target.Refresh(obj, true)
|
|
|
|
target.Refresh(obj, true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !recreate {
|
|
|
|
if !recreate {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
@ -508,18 +509,41 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object,
|
|
|
|
|
|
|
|
|
|
|
|
func getSelectorFromObject(obj runtime.Object) (map[string]string, error) {
|
|
|
|
func getSelectorFromObject(obj runtime.Object) (map[string]string, error) {
|
|
|
|
switch typed := obj.(type) {
|
|
|
|
switch typed := obj.(type) {
|
|
|
|
|
|
|
|
|
|
|
|
case *v1.ReplicationController:
|
|
|
|
case *v1.ReplicationController:
|
|
|
|
return typed.Spec.Selector, nil
|
|
|
|
return typed.Spec.Selector, nil
|
|
|
|
case *v1beta1.ReplicaSet:
|
|
|
|
|
|
|
|
|
|
|
|
case *extv1beta1.ReplicaSet:
|
|
|
|
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
|
|
|
|
case *appsv1.ReplicaSet:
|
|
|
|
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case *extv1beta1.Deployment:
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
case *v1beta1.Deployment:
|
|
|
|
case *appsv1beta1.Deployment:
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
case *v1beta1.DaemonSet:
|
|
|
|
case *appsv1beta2.Deployment:
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
|
|
|
|
case *appsv1.Deployment:
|
|
|
|
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case *extv1beta1.DaemonSet:
|
|
|
|
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
|
|
|
|
case *appsv1beta2.DaemonSet:
|
|
|
|
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
|
|
|
|
case *appsv1.DaemonSet:
|
|
|
|
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
|
|
|
|
|
|
|
|
case *batch.Job:
|
|
|
|
case *batch.Job:
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
case *apps.StatefulSet:
|
|
|
|
|
|
|
|
|
|
|
|
case *appsv1beta1.StatefulSet:
|
|
|
|
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
|
|
|
|
case *appsv1beta2.StatefulSet:
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
|
|
|
|
case *appsv1.StatefulSet:
|
|
|
|
|
|
|
|
return typed.Spec.Selector.MatchLabels, nil
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("Unsupported kind when getting selector: %v", obj)
|
|
|
|
return nil, fmt.Errorf("Unsupported kind when getting selector: %v", obj)
|
|
|
|
}
|
|
|
|
}
|
|
|
|