Fix kubectl conversions
Kubernetes-commit: bfa4188123ed334d4f5dda3a79994cadf663d8f2
This commit is contained in:
parent
c390dc2e34
commit
24d21a0ee4
|
@ -23,7 +23,6 @@ import (
|
||||||
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/kubectl/pkg/scheme"
|
|
||||||
deploymentutil "k8s.io/kubectl/pkg/util/deployment"
|
deploymentutil "k8s.io/kubectl/pkg/util/deployment"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -59,7 +58,7 @@ type StatefulSetStatusViewer struct{}
|
||||||
// Status returns a message describing deployment status, and a bool value indicating if the status is considered done.
|
// Status returns a message describing deployment status, and a bool value indicating if the status is considered done.
|
||||||
func (s *DeploymentStatusViewer) Status(obj runtime.Unstructured, revision int64) (string, bool, error) {
|
func (s *DeploymentStatusViewer) Status(obj runtime.Unstructured, revision int64) (string, bool, error) {
|
||||||
deployment := &appsv1.Deployment{}
|
deployment := &appsv1.Deployment{}
|
||||||
err := scheme.Scheme.Convert(obj, deployment, nil)
|
err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.UnstructuredContent(), deployment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", false, fmt.Errorf("failed to convert %T to %T: %v", obj, deployment, err)
|
return "", false, fmt.Errorf("failed to convert %T to %T: %v", obj, deployment, err)
|
||||||
}
|
}
|
||||||
|
@ -97,7 +96,7 @@ func (s *DaemonSetStatusViewer) Status(obj runtime.Unstructured, revision int64)
|
||||||
//ignoring revision as DaemonSets does not have history yet
|
//ignoring revision as DaemonSets does not have history yet
|
||||||
|
|
||||||
daemon := &appsv1.DaemonSet{}
|
daemon := &appsv1.DaemonSet{}
|
||||||
err := scheme.Scheme.Convert(obj, daemon, nil)
|
err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.UnstructuredContent(), daemon)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", false, fmt.Errorf("failed to convert %T to %T: %v", obj, daemon, err)
|
return "", false, fmt.Errorf("failed to convert %T to %T: %v", obj, daemon, err)
|
||||||
}
|
}
|
||||||
|
@ -120,7 +119,7 @@ func (s *DaemonSetStatusViewer) Status(obj runtime.Unstructured, revision int64)
|
||||||
// Status returns a message describing statefulset status, and a bool value indicating if the status is considered done.
|
// Status returns a message describing statefulset status, and a bool value indicating if the status is considered done.
|
||||||
func (s *StatefulSetStatusViewer) Status(obj runtime.Unstructured, revision int64) (string, bool, error) {
|
func (s *StatefulSetStatusViewer) Status(obj runtime.Unstructured, revision int64) (string, bool, error) {
|
||||||
sts := &appsv1.StatefulSet{}
|
sts := &appsv1.StatefulSet{}
|
||||||
err := scheme.Scheme.Convert(obj, sts, nil)
|
err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.UnstructuredContent(), sts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", false, fmt.Errorf("failed to convert %T to %T: %v", obj, sts, err)
|
return "", false, fmt.Errorf("failed to convert %T to %T: %v", obj, sts, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
api "k8s.io/api/core/v1"
|
api "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
"k8s.io/kubectl/pkg/scheme"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDeploymentStatusViewerStatus(t *testing.T) {
|
func TestDeploymentStatusViewerStatus(t *testing.T) {
|
||||||
|
@ -128,7 +128,8 @@ func TestDeploymentStatusViewerStatus(t *testing.T) {
|
||||||
Status: test.status,
|
Status: test.status,
|
||||||
}
|
}
|
||||||
unstructuredD := &unstructured.Unstructured{}
|
unstructuredD := &unstructured.Unstructured{}
|
||||||
err := scheme.Scheme.Convert(d, unstructuredD, nil)
|
var err error
|
||||||
|
unstructuredD.Object, err = runtime.DefaultUnstructuredConverter.ToUnstructured(d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -233,7 +234,8 @@ func TestDaemonSetStatusViewerStatus(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
unstructuredD := &unstructured.Unstructured{}
|
unstructuredD := &unstructured.Unstructured{}
|
||||||
err := scheme.Scheme.Convert(d, unstructuredD, nil)
|
var err error
|
||||||
|
unstructuredD.Object, err = runtime.DefaultUnstructuredConverter.ToUnstructured(d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -384,7 +386,8 @@ func TestStatefulSetStatusViewerStatus(t *testing.T) {
|
||||||
s.Generation = test.generation
|
s.Generation = test.generation
|
||||||
|
|
||||||
unstructuredS := &unstructured.Unstructured{}
|
unstructuredS := &unstructured.Unstructured{}
|
||||||
err := scheme.Scheme.Convert(s, unstructuredS, nil)
|
var err error
|
||||||
|
unstructuredS.Object, err = runtime.DefaultUnstructuredConverter.ToUnstructured(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -422,7 +425,8 @@ func TestDaemonSetStatusViewerStatusWithWrongUpdateStrategyType(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
unstructuredD := &unstructured.Unstructured{}
|
unstructuredD := &unstructured.Unstructured{}
|
||||||
err := scheme.Scheme.Convert(d, unstructuredD, nil)
|
var err error
|
||||||
|
unstructuredD.Object, err = runtime.DefaultUnstructuredConverter.ToUnstructured(d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue