mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
fixup extensions->apps references
This commit is contained in:
parent
b502bc093c
commit
d0577ace6b
@ -50,6 +50,7 @@
|
|||||||
"k8s.io/kubernetes/pkg/apis/autoscaling",
|
"k8s.io/kubernetes/pkg/apis/autoscaling",
|
||||||
"k8s.io/kubernetes/pkg/apis/core",
|
"k8s.io/kubernetes/pkg/apis/core",
|
||||||
"k8s.io/kubernetes/pkg/api/service",
|
"k8s.io/kubernetes/pkg/api/service",
|
||||||
|
"k8s.io/kubernetes/pkg/apis/apps",
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions",
|
"k8s.io/kubernetes/pkg/apis/extensions",
|
||||||
"k8s.io/kubernetes/pkg/apis/networking",
|
"k8s.io/kubernetes/pkg/apis/networking",
|
||||||
"k8s.io/kubernetes/pkg/apis/policy",
|
"k8s.io/kubernetes/pkg/apis/policy",
|
||||||
|
@ -11,10 +11,10 @@
|
|||||||
|
|
||||||
# the following are temporary and should go away. Think twice (or more) before adding anything here.
|
# the following are temporary and should go away. Think twice (or more) before adding anything here.
|
||||||
# Main goal: pkg/apis should be as self-contained as possible.
|
# Main goal: pkg/apis should be as self-contained as possible.
|
||||||
- k8s.io/kubernetes/pkg/apis/extensions
|
- k8s.io/kubernetes/pkg/apis/apps
|
||||||
- k8s.io/kubernetes/pkg/api/legacyscheme
|
- k8s.io/kubernetes/pkg/api/legacyscheme
|
||||||
- k8s.io/kubernetes/pkg/api/testapi
|
- k8s.io/kubernetes/pkg/api/testapi
|
||||||
- k8s.io/api/extensions/v1beta1
|
- k8s.io/api/apps/v1
|
||||||
ignoredSubTrees:
|
ignoredSubTrees:
|
||||||
- "./pkg/apis/core/validation"
|
- "./pkg/apis/core/validation"
|
||||||
|
|
||||||
|
@ -27,9 +27,9 @@ import (
|
|||||||
unversionedvalidation "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
|
unversionedvalidation "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||||
|
appsvalidation "k8s.io/kubernetes/pkg/apis/apps/validation"
|
||||||
core "k8s.io/kubernetes/pkg/apis/core"
|
core "k8s.io/kubernetes/pkg/apis/core"
|
||||||
apivalidation "k8s.io/kubernetes/pkg/apis/core/validation"
|
apivalidation "k8s.io/kubernetes/pkg/apis/core/validation"
|
||||||
extensionsvalidation "k8s.io/kubernetes/pkg/apis/extensions/validation"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/policy"
|
"k8s.io/kubernetes/pkg/apis/policy"
|
||||||
"k8s.io/kubernetes/pkg/features"
|
"k8s.io/kubernetes/pkg/features"
|
||||||
"k8s.io/kubernetes/pkg/security/apparmor"
|
"k8s.io/kubernetes/pkg/security/apparmor"
|
||||||
@ -68,13 +68,13 @@ func ValidatePodDisruptionBudgetSpec(spec policy.PodDisruptionBudgetSpec, fldPat
|
|||||||
}
|
}
|
||||||
|
|
||||||
if spec.MinAvailable != nil {
|
if spec.MinAvailable != nil {
|
||||||
allErrs = append(allErrs, extensionsvalidation.ValidatePositiveIntOrPercent(*spec.MinAvailable, fldPath.Child("minAvailable"))...)
|
allErrs = append(allErrs, appsvalidation.ValidatePositiveIntOrPercent(*spec.MinAvailable, fldPath.Child("minAvailable"))...)
|
||||||
allErrs = append(allErrs, extensionsvalidation.IsNotMoreThan100Percent(*spec.MinAvailable, fldPath.Child("minAvailable"))...)
|
allErrs = append(allErrs, appsvalidation.IsNotMoreThan100Percent(*spec.MinAvailable, fldPath.Child("minAvailable"))...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if spec.MaxUnavailable != nil {
|
if spec.MaxUnavailable != nil {
|
||||||
allErrs = append(allErrs, extensionsvalidation.ValidatePositiveIntOrPercent(*spec.MaxUnavailable, fldPath.Child("maxUnavailable"))...)
|
allErrs = append(allErrs, appsvalidation.ValidatePositiveIntOrPercent(*spec.MaxUnavailable, fldPath.Child("maxUnavailable"))...)
|
||||||
allErrs = append(allErrs, extensionsvalidation.IsNotMoreThan100Percent(*spec.MaxUnavailable, fldPath.Child("maxUnavailable"))...)
|
allErrs = append(allErrs, appsvalidation.IsNotMoreThan100Percent(*spec.MaxUnavailable, fldPath.Child("maxUnavailable"))...)
|
||||||
}
|
}
|
||||||
|
|
||||||
allErrs = append(allErrs, unversionedvalidation.ValidateLabelSelector(spec.Selector, fldPath.Child("selector"))...)
|
allErrs = append(allErrs, unversionedvalidation.ValidateLabelSelector(spec.Selector, fldPath.Child("selector"))...)
|
||||||
|
@ -1872,7 +1872,7 @@ type ReplicaSetDescriber struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *ReplicaSetDescriber) Describe(namespace, name string, describerSettings printers.DescriberSettings) (string, error) {
|
func (d *ReplicaSetDescriber) Describe(namespace, name string, describerSettings printers.DescriberSettings) (string, error) {
|
||||||
rsc := d.Extensions().ReplicaSets(namespace)
|
rsc := d.Apps().ReplicaSets(namespace)
|
||||||
pc := d.Core().Pods(namespace)
|
pc := d.Core().Pods(namespace)
|
||||||
|
|
||||||
rs, err := rsc.Get(name, metav1.GetOptions{})
|
rs, err := rsc.Get(name, metav1.GetOptions{})
|
||||||
@ -1895,7 +1895,7 @@ func (d *ReplicaSetDescriber) Describe(namespace, name string, describerSettings
|
|||||||
return describeReplicaSet(rs, events, running, waiting, succeeded, failed, getPodErr)
|
return describeReplicaSet(rs, events, running, waiting, succeeded, failed, getPodErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func describeReplicaSet(rs *extensions.ReplicaSet, events *api.EventList, running, waiting, succeeded, failed int, getPodErr error) (string, error) {
|
func describeReplicaSet(rs *apps.ReplicaSet, events *api.EventList, running, waiting, succeeded, failed int, getPodErr error) (string, error) {
|
||||||
return tabbedString(func(out io.Writer) error {
|
return tabbedString(func(out io.Writer) error {
|
||||||
w := NewPrefixWriter(out)
|
w := NewPrefixWriter(out)
|
||||||
w.Write(LEVEL_0, "Name:\t%s\n", rs.Name)
|
w.Write(LEVEL_0, "Name:\t%s\n", rs.Name)
|
||||||
@ -2085,7 +2085,7 @@ type DaemonSetDescriber struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *DaemonSetDescriber) Describe(namespace, name string, describerSettings printers.DescriberSettings) (string, error) {
|
func (d *DaemonSetDescriber) Describe(namespace, name string, describerSettings printers.DescriberSettings) (string, error) {
|
||||||
dc := d.Extensions().DaemonSets(namespace)
|
dc := d.Apps().DaemonSets(namespace)
|
||||||
pc := d.Core().Pods(namespace)
|
pc := d.Core().Pods(namespace)
|
||||||
|
|
||||||
daemon, err := dc.Get(name, metav1.GetOptions{})
|
daemon, err := dc.Get(name, metav1.GetOptions{})
|
||||||
@ -2110,7 +2110,7 @@ func (d *DaemonSetDescriber) Describe(namespace, name string, describerSettings
|
|||||||
return describeDaemonSet(daemon, events, running, waiting, succeeded, failed)
|
return describeDaemonSet(daemon, events, running, waiting, succeeded, failed)
|
||||||
}
|
}
|
||||||
|
|
||||||
func describeDaemonSet(daemon *extensions.DaemonSet, events *api.EventList, running, waiting, succeeded, failed int) (string, error) {
|
func describeDaemonSet(daemon *apps.DaemonSet, events *api.EventList, running, waiting, succeeded, failed int) (string, error) {
|
||||||
return tabbedString(func(out io.Writer) error {
|
return tabbedString(func(out io.Writer) error {
|
||||||
w := NewPrefixWriter(out)
|
w := NewPrefixWriter(out)
|
||||||
w.Write(LEVEL_0, "Name:\t%s\n", daemon.Name)
|
w.Write(LEVEL_0, "Name:\t%s\n", daemon.Name)
|
||||||
@ -3224,8 +3224,8 @@ func (dd *DeploymentDescriber) Describe(namespace, name string, describerSetting
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
internalDeployment := &extensions.Deployment{}
|
internalDeployment := &apps.Deployment{}
|
||||||
if err := legacyscheme.Scheme.Convert(d, internalDeployment, extensions.SchemeGroupVersion); err != nil {
|
if err := legacyscheme.Scheme.Convert(d, internalDeployment, apps.SchemeGroupVersion); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3237,7 +3237,7 @@ func (dd *DeploymentDescriber) Describe(namespace, name string, describerSetting
|
|||||||
return describeDeployment(d, selector, internalDeployment, events, dd)
|
return describeDeployment(d, selector, internalDeployment, events, dd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func describeDeployment(d *appsv1.Deployment, selector labels.Selector, internalDeployment *extensions.Deployment, events *api.EventList, dd *DeploymentDescriber) (string, error) {
|
func describeDeployment(d *appsv1.Deployment, selector labels.Selector, internalDeployment *apps.Deployment, events *api.EventList, dd *DeploymentDescriber) (string, error) {
|
||||||
return tabbedString(func(out io.Writer) error {
|
return tabbedString(func(out io.Writer) error {
|
||||||
w := NewPrefixWriter(out)
|
w := NewPrefixWriter(out)
|
||||||
w.Write(LEVEL_0, "Name:\t%s\n", d.ObjectMeta.Name)
|
w.Write(LEVEL_0, "Name:\t%s\n", d.ObjectMeta.Name)
|
||||||
|
@ -36,7 +36,6 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/apis/apps"
|
"k8s.io/kubernetes/pkg/apis/apps"
|
||||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
"k8s.io/kubernetes/pkg/apis/networking"
|
"k8s.io/kubernetes/pkg/apis/networking"
|
||||||
"k8s.io/kubernetes/pkg/apis/policy"
|
"k8s.io/kubernetes/pkg/apis/policy"
|
||||||
"k8s.io/kubernetes/pkg/apis/storage"
|
"k8s.io/kubernetes/pkg/apis/storage"
|
||||||
@ -2188,7 +2187,7 @@ func TestDescribeEvents(t *testing.T) {
|
|||||||
|
|
||||||
m := map[string]printers.Describer{
|
m := map[string]printers.Describer{
|
||||||
"DaemonSetDescriber": &DaemonSetDescriber{
|
"DaemonSetDescriber": &DaemonSetDescriber{
|
||||||
fake.NewSimpleClientset(&extensions.DaemonSet{
|
fake.NewSimpleClientset(&apps.DaemonSet{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "bar",
|
Name: "bar",
|
||||||
Namespace: "foo",
|
Namespace: "foo",
|
||||||
@ -2245,7 +2244,7 @@ func TestDescribeEvents(t *testing.T) {
|
|||||||
}, events),
|
}, events),
|
||||||
},
|
},
|
||||||
"ReplicaSetDescriber": &ReplicaSetDescriber{
|
"ReplicaSetDescriber": &ReplicaSetDescriber{
|
||||||
fake.NewSimpleClientset(&extensions.ReplicaSet{
|
fake.NewSimpleClientset(&apps.ReplicaSet{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "bar",
|
Name: "bar",
|
||||||
Namespace: "foo",
|
Namespace: "foo",
|
||||||
|
@ -769,7 +769,7 @@ func printReplicationControllerList(list *api.ReplicationControllerList, options
|
|||||||
return rows, nil
|
return rows, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func printReplicaSet(obj *extensions.ReplicaSet, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
func printReplicaSet(obj *apps.ReplicaSet, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||||
row := metav1beta1.TableRow{
|
row := metav1beta1.TableRow{
|
||||||
Object: runtime.RawExtension{Object: obj},
|
Object: runtime.RawExtension{Object: obj},
|
||||||
}
|
}
|
||||||
@ -786,7 +786,7 @@ func printReplicaSet(obj *extensions.ReplicaSet, options printers.PrintOptions)
|
|||||||
return []metav1beta1.TableRow{row}, nil
|
return []metav1beta1.TableRow{row}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func printReplicaSetList(list *extensions.ReplicaSetList, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
func printReplicaSetList(list *apps.ReplicaSetList, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||||
rows := make([]metav1beta1.TableRow, 0, len(list.Items))
|
rows := make([]metav1beta1.TableRow, 0, len(list.Items))
|
||||||
for i := range list.Items {
|
for i := range list.Items {
|
||||||
r, err := printReplicaSet(&list.Items[i], options)
|
r, err := printReplicaSet(&list.Items[i], options)
|
||||||
@ -1063,7 +1063,7 @@ func printStatefulSetList(list *apps.StatefulSetList, options printers.PrintOpti
|
|||||||
return rows, nil
|
return rows, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func printDaemonSet(obj *extensions.DaemonSet, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
func printDaemonSet(obj *apps.DaemonSet, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||||
row := metav1beta1.TableRow{
|
row := metav1beta1.TableRow{
|
||||||
Object: runtime.RawExtension{Object: obj},
|
Object: runtime.RawExtension{Object: obj},
|
||||||
}
|
}
|
||||||
@ -1082,7 +1082,7 @@ func printDaemonSet(obj *extensions.DaemonSet, options printers.PrintOptions) ([
|
|||||||
return []metav1beta1.TableRow{row}, nil
|
return []metav1beta1.TableRow{row}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func printDaemonSetList(list *extensions.DaemonSetList, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
func printDaemonSetList(list *apps.DaemonSetList, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||||
rows := make([]metav1beta1.TableRow, 0, len(list.Items))
|
rows := make([]metav1beta1.TableRow, 0, len(list.Items))
|
||||||
for i := range list.Items {
|
for i := range list.Items {
|
||||||
r, err := printDaemonSet(&list.Items[i], options)
|
r, err := printDaemonSet(&list.Items[i], options)
|
||||||
@ -1555,7 +1555,7 @@ func truncate(str string, maxLen int) string {
|
|||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
func printDeployment(obj *extensions.Deployment, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
func printDeployment(obj *apps.Deployment, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||||
row := metav1beta1.TableRow{
|
row := metav1beta1.TableRow{
|
||||||
Object: runtime.RawExtension{Object: obj},
|
Object: runtime.RawExtension{Object: obj},
|
||||||
}
|
}
|
||||||
@ -1578,7 +1578,7 @@ func printDeployment(obj *extensions.Deployment, options printers.PrintOptions)
|
|||||||
return []metav1beta1.TableRow{row}, nil
|
return []metav1beta1.TableRow{row}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func printDeploymentList(list *extensions.DeploymentList, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
func printDeploymentList(list *apps.DeploymentList, options printers.PrintOptions) ([]metav1beta1.TableRow, error) {
|
||||||
rows := make([]metav1beta1.TableRow, 0, len(list.Items))
|
rows := make([]metav1beta1.TableRow, 0, len(list.Items))
|
||||||
for i := range list.Items {
|
for i := range list.Items {
|
||||||
r, err := printDeployment(&list.Items[i], options)
|
r, err := printDeployment(&list.Items[i], options)
|
||||||
|
@ -1971,17 +1971,17 @@ func TestTranslateTimestampUntil(t *testing.T) {
|
|||||||
|
|
||||||
func TestPrintDeployment(t *testing.T) {
|
func TestPrintDeployment(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
deployment extensions.Deployment
|
deployment apps.Deployment
|
||||||
expect string
|
expect string
|
||||||
wideExpect string
|
wideExpect string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
extensions.Deployment{
|
apps.Deployment{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "test1",
|
Name: "test1",
|
||||||
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
|
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
|
||||||
},
|
},
|
||||||
Spec: extensions.DeploymentSpec{
|
Spec: apps.DeploymentSpec{
|
||||||
Replicas: 5,
|
Replicas: 5,
|
||||||
Template: api.PodTemplateSpec{
|
Template: api.PodTemplateSpec{
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
@ -1999,7 +1999,7 @@ func TestPrintDeployment(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
|
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
|
||||||
},
|
},
|
||||||
Status: extensions.DeploymentStatus{
|
Status: apps.DeploymentStatus{
|
||||||
Replicas: 10,
|
Replicas: 10,
|
||||||
UpdatedReplicas: 2,
|
UpdatedReplicas: 2,
|
||||||
AvailableReplicas: 1,
|
AvailableReplicas: 1,
|
||||||
@ -2040,21 +2040,21 @@ func TestPrintDeployment(t *testing.T) {
|
|||||||
|
|
||||||
func TestPrintDaemonSet(t *testing.T) {
|
func TestPrintDaemonSet(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
ds extensions.DaemonSet
|
ds apps.DaemonSet
|
||||||
startsWith string
|
startsWith string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
extensions.DaemonSet{
|
apps.DaemonSet{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "test1",
|
Name: "test1",
|
||||||
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
|
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
|
||||||
},
|
},
|
||||||
Spec: extensions.DaemonSetSpec{
|
Spec: apps.DaemonSetSpec{
|
||||||
Template: api.PodTemplateSpec{
|
Template: api.PodTemplateSpec{
|
||||||
Spec: api.PodSpec{Containers: make([]api.Container, 2)},
|
Spec: api.PodSpec{Containers: make([]api.Container, 2)},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Status: extensions.DaemonSetStatus{
|
Status: apps.DaemonSetStatus{
|
||||||
CurrentNumberScheduled: 2,
|
CurrentNumberScheduled: 2,
|
||||||
DesiredNumberScheduled: 3,
|
DesiredNumberScheduled: 3,
|
||||||
NumberReady: 1,
|
NumberReady: 1,
|
||||||
@ -3154,17 +3154,17 @@ func boolP(b bool) *bool {
|
|||||||
|
|
||||||
func TestPrintReplicaSet(t *testing.T) {
|
func TestPrintReplicaSet(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
replicaSet extensions.ReplicaSet
|
replicaSet apps.ReplicaSet
|
||||||
expect string
|
expect string
|
||||||
wideExpect string
|
wideExpect string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
extensions.ReplicaSet{
|
apps.ReplicaSet{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "test1",
|
Name: "test1",
|
||||||
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
|
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
|
||||||
},
|
},
|
||||||
Spec: extensions.ReplicaSetSpec{
|
Spec: apps.ReplicaSetSpec{
|
||||||
Replicas: 5,
|
Replicas: 5,
|
||||||
Template: api.PodTemplateSpec{
|
Template: api.PodTemplateSpec{
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
@ -3182,7 +3182,7 @@ func TestPrintReplicaSet(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
|
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
|
||||||
},
|
},
|
||||||
Status: extensions.ReplicaSetStatus{
|
Status: apps.ReplicaSetStatus{
|
||||||
Replicas: 5,
|
Replicas: 5,
|
||||||
ReadyReplicas: 2,
|
ReadyReplicas: 2,
|
||||||
},
|
},
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
"k8s.io/apiserver/pkg/registry/rest"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
"k8s.io/kubernetes/pkg/apis/apps"
|
||||||
"k8s.io/kubernetes/pkg/printers"
|
"k8s.io/kubernetes/pkg/printers"
|
||||||
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
||||||
printerstorage "k8s.io/kubernetes/pkg/printers/storage"
|
printerstorage "k8s.io/kubernetes/pkg/printers/storage"
|
||||||
@ -40,9 +40,9 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against DaemonSets.
|
// NewREST returns a RESTStorage object that will work against DaemonSets.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &extensions.DaemonSet{} },
|
NewFunc: func() runtime.Object { return &apps.DaemonSet{} },
|
||||||
NewListFunc: func() runtime.Object { return &extensions.DaemonSetList{} },
|
NewListFunc: func() runtime.Object { return &apps.DaemonSetList{} },
|
||||||
DefaultQualifiedResource: extensions.Resource("daemonsets"),
|
DefaultQualifiedResource: apps.Resource("daemonsets"),
|
||||||
|
|
||||||
CreateStrategy: daemonset.Strategy,
|
CreateStrategy: daemonset.Strategy,
|
||||||
UpdateStrategy: daemonset.Strategy,
|
UpdateStrategy: daemonset.Strategy,
|
||||||
@ -87,7 +87,7 @@ type StatusREST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *StatusREST) New() runtime.Object {
|
func (r *StatusREST) New() runtime.Object {
|
||||||
return &extensions.DaemonSet{}
|
return &apps.DaemonSet{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get retrieves the object from the storage. It is required to support Patch.
|
// Get retrieves the object from the storage. It is required to support Patch.
|
||||||
|
@ -26,13 +26,13 @@ import (
|
|||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
||||||
etcdtesting "k8s.io/apiserver/pkg/storage/etcd/testing"
|
etcdtesting "k8s.io/apiserver/pkg/storage/etcd/testing"
|
||||||
|
"k8s.io/kubernetes/pkg/apis/apps"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*REST, *StatusREST, *etcdtesting.EtcdTestServer) {
|
func newStorage(t *testing.T) (*REST, *StatusREST, *etcdtesting.EtcdTestServer) {
|
||||||
etcdStorage, server := registrytest.NewEtcdStorage(t, extensions.GroupName)
|
etcdStorage, server := registrytest.NewEtcdStorage(t, apps.GroupName)
|
||||||
restOptions := generic.RESTOptions{
|
restOptions := generic.RESTOptions{
|
||||||
StorageConfig: etcdStorage,
|
StorageConfig: etcdStorage,
|
||||||
Decorator: generic.UndecoratedStorage,
|
Decorator: generic.UndecoratedStorage,
|
||||||
@ -43,15 +43,15 @@ func newStorage(t *testing.T) (*REST, *StatusREST, *etcdtesting.EtcdTestServer)
|
|||||||
return daemonSetStorage, statusStorage, server
|
return daemonSetStorage, statusStorage, server
|
||||||
}
|
}
|
||||||
|
|
||||||
func newValidDaemonSet() *extensions.DaemonSet {
|
func newValidDaemonSet() *apps.DaemonSet {
|
||||||
return &extensions.DaemonSet{
|
return &apps.DaemonSet{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Namespace: metav1.NamespaceDefault,
|
Namespace: metav1.NamespaceDefault,
|
||||||
},
|
},
|
||||||
Spec: extensions.DaemonSetSpec{
|
Spec: apps.DaemonSetSpec{
|
||||||
UpdateStrategy: extensions.DaemonSetUpdateStrategy{
|
UpdateStrategy: apps.DaemonSetUpdateStrategy{
|
||||||
Type: extensions.OnDeleteDaemonSetStrategyType,
|
Type: apps.OnDeleteDaemonSetStrategyType,
|
||||||
},
|
},
|
||||||
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"a": "b"}},
|
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"a": "b"}},
|
||||||
Template: api.PodTemplateSpec{
|
Template: api.PodTemplateSpec{
|
||||||
@ -88,15 +88,15 @@ func TestCreate(t *testing.T) {
|
|||||||
// valid
|
// valid
|
||||||
ds,
|
ds,
|
||||||
// invalid (invalid selector)
|
// invalid (invalid selector)
|
||||||
&extensions.DaemonSet{
|
&apps.DaemonSet{
|
||||||
Spec: extensions.DaemonSetSpec{
|
Spec: apps.DaemonSetSpec{
|
||||||
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{}},
|
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{}},
|
||||||
Template: validDaemonSet.Spec.Template,
|
Template: validDaemonSet.Spec.Template,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// invalid update strategy
|
// invalid update strategy
|
||||||
&extensions.DaemonSet{
|
&apps.DaemonSet{
|
||||||
Spec: extensions.DaemonSetSpec{
|
Spec: apps.DaemonSetSpec{
|
||||||
Selector: validDaemonSet.Spec.Selector,
|
Selector: validDaemonSet.Spec.Selector,
|
||||||
Template: validDaemonSet.Spec.Template,
|
Template: validDaemonSet.Spec.Template,
|
||||||
},
|
},
|
||||||
@ -114,19 +114,19 @@ func TestUpdate(t *testing.T) {
|
|||||||
newValidDaemonSet(),
|
newValidDaemonSet(),
|
||||||
// updateFunc
|
// updateFunc
|
||||||
func(obj runtime.Object) runtime.Object {
|
func(obj runtime.Object) runtime.Object {
|
||||||
object := obj.(*extensions.DaemonSet)
|
object := obj.(*apps.DaemonSet)
|
||||||
object.Spec.Template.Spec.NodeSelector = map[string]string{"c": "d"}
|
object.Spec.Template.Spec.NodeSelector = map[string]string{"c": "d"}
|
||||||
object.Spec.Template.Spec.DNSPolicy = api.DNSDefault
|
object.Spec.Template.Spec.DNSPolicy = api.DNSDefault
|
||||||
return object
|
return object
|
||||||
},
|
},
|
||||||
// invalid updateFunc
|
// invalid updateFunc
|
||||||
func(obj runtime.Object) runtime.Object {
|
func(obj runtime.Object) runtime.Object {
|
||||||
object := obj.(*extensions.DaemonSet)
|
object := obj.(*apps.DaemonSet)
|
||||||
object.Name = ""
|
object.Name = ""
|
||||||
return object
|
return object
|
||||||
},
|
},
|
||||||
func(obj runtime.Object) runtime.Object {
|
func(obj runtime.Object) runtime.Object {
|
||||||
object := obj.(*extensions.DaemonSet)
|
object := obj.(*apps.DaemonSet)
|
||||||
object.Spec.Template.Spec.RestartPolicy = api.RestartPolicyOnFailure
|
object.Spec.Template.Spec.RestartPolicy = api.RestartPolicyOnFailure
|
||||||
return object
|
return object
|
||||||
},
|
},
|
||||||
|
@ -31,8 +31,8 @@ import (
|
|||||||
"k8s.io/apiserver/pkg/storage/names"
|
"k8s.io/apiserver/pkg/storage/names"
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
"k8s.io/kubernetes/pkg/api/pod"
|
"k8s.io/kubernetes/pkg/api/pod"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
"k8s.io/kubernetes/pkg/apis/apps"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions/validation"
|
"k8s.io/kubernetes/pkg/apis/apps/validation"
|
||||||
)
|
)
|
||||||
|
|
||||||
// daemonSetStrategy implements verification logic for daemon sets.
|
// daemonSetStrategy implements verification logic for daemon sets.
|
||||||
@ -66,8 +66,8 @@ func (daemonSetStrategy) NamespaceScoped() bool {
|
|||||||
|
|
||||||
// PrepareForCreate clears the status of a daemon set before creation.
|
// PrepareForCreate clears the status of a daemon set before creation.
|
||||||
func (daemonSetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
func (daemonSetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
||||||
daemonSet := obj.(*extensions.DaemonSet)
|
daemonSet := obj.(*apps.DaemonSet)
|
||||||
daemonSet.Status = extensions.DaemonSetStatus{}
|
daemonSet.Status = apps.DaemonSetStatus{}
|
||||||
|
|
||||||
daemonSet.Generation = 1
|
daemonSet.Generation = 1
|
||||||
if daemonSet.Spec.TemplateGeneration < 1 {
|
if daemonSet.Spec.TemplateGeneration < 1 {
|
||||||
@ -79,8 +79,8 @@ func (daemonSetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Objec
|
|||||||
|
|
||||||
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
|
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
|
||||||
func (daemonSetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
func (daemonSetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||||
newDaemonSet := obj.(*extensions.DaemonSet)
|
newDaemonSet := obj.(*apps.DaemonSet)
|
||||||
oldDaemonSet := old.(*extensions.DaemonSet)
|
oldDaemonSet := old.(*apps.DaemonSet)
|
||||||
|
|
||||||
pod.DropDisabledAlphaFields(&newDaemonSet.Spec.Template.Spec)
|
pod.DropDisabledAlphaFields(&newDaemonSet.Spec.Template.Spec)
|
||||||
pod.DropDisabledAlphaFields(&oldDaemonSet.Spec.Template.Spec)
|
pod.DropDisabledAlphaFields(&oldDaemonSet.Spec.Template.Spec)
|
||||||
@ -114,7 +114,7 @@ func (daemonSetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.
|
|||||||
|
|
||||||
// Validate validates a new daemon set.
|
// Validate validates a new daemon set.
|
||||||
func (daemonSetStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
func (daemonSetStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
||||||
daemonSet := obj.(*extensions.DaemonSet)
|
daemonSet := obj.(*apps.DaemonSet)
|
||||||
return validation.ValidateDaemonSet(daemonSet)
|
return validation.ValidateDaemonSet(daemonSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,9 +130,9 @@ func (daemonSetStrategy) AllowCreateOnUpdate() bool {
|
|||||||
|
|
||||||
// ValidateUpdate is the default update validation for an end user.
|
// ValidateUpdate is the default update validation for an end user.
|
||||||
func (daemonSetStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
func (daemonSetStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||||
newDaemonSet := obj.(*extensions.DaemonSet)
|
newDaemonSet := obj.(*apps.DaemonSet)
|
||||||
oldDaemonSet := old.(*extensions.DaemonSet)
|
oldDaemonSet := old.(*apps.DaemonSet)
|
||||||
allErrs := validation.ValidateDaemonSet(obj.(*extensions.DaemonSet))
|
allErrs := validation.ValidateDaemonSet(obj.(*apps.DaemonSet))
|
||||||
allErrs = append(allErrs, validation.ValidateDaemonSetUpdate(newDaemonSet, oldDaemonSet)...)
|
allErrs = append(allErrs, validation.ValidateDaemonSetUpdate(newDaemonSet, oldDaemonSet)...)
|
||||||
|
|
||||||
// Update is not allowed to set Spec.Selector for apps/v1 and apps/v1beta2 (allowed for extensions/v1beta1).
|
// Update is not allowed to set Spec.Selector for apps/v1 and apps/v1beta2 (allowed for extensions/v1beta1).
|
||||||
@ -165,11 +165,11 @@ type daemonSetStatusStrategy struct {
|
|||||||
var StatusStrategy = daemonSetStatusStrategy{Strategy}
|
var StatusStrategy = daemonSetStatusStrategy{Strategy}
|
||||||
|
|
||||||
func (daemonSetStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
func (daemonSetStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||||
newDaemonSet := obj.(*extensions.DaemonSet)
|
newDaemonSet := obj.(*apps.DaemonSet)
|
||||||
oldDaemonSet := old.(*extensions.DaemonSet)
|
oldDaemonSet := old.(*apps.DaemonSet)
|
||||||
newDaemonSet.Spec = oldDaemonSet.Spec
|
newDaemonSet.Spec = oldDaemonSet.Spec
|
||||||
}
|
}
|
||||||
|
|
||||||
func (daemonSetStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
func (daemonSetStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||||
return validation.ValidateDaemonSetStatusUpdate(obj.(*extensions.DaemonSet), old.(*extensions.DaemonSet))
|
return validation.ValidateDaemonSetStatusUpdate(obj.(*apps.DaemonSet), old.(*apps.DaemonSet))
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
"k8s.io/apiserver/pkg/registry/rest"
|
||||||
|
"k8s.io/kubernetes/pkg/apis/apps"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -160,20 +160,20 @@ func TestSelectorImmutability(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDaemonSetWithSelectorLabels(selectorLabels map[string]string, templateGeneration int64) *extensions.DaemonSet {
|
func newDaemonSetWithSelectorLabels(selectorLabels map[string]string, templateGeneration int64) *apps.DaemonSet {
|
||||||
return &extensions.DaemonSet{
|
return &apps.DaemonSet{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: daemonsetName,
|
Name: daemonsetName,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
ResourceVersion: "1",
|
ResourceVersion: "1",
|
||||||
},
|
},
|
||||||
Spec: extensions.DaemonSetSpec{
|
Spec: apps.DaemonSetSpec{
|
||||||
Selector: &metav1.LabelSelector{
|
Selector: &metav1.LabelSelector{
|
||||||
MatchLabels: selectorLabels,
|
MatchLabels: selectorLabels,
|
||||||
MatchExpressions: []metav1.LabelSelectorRequirement{},
|
MatchExpressions: []metav1.LabelSelectorRequirement{},
|
||||||
},
|
},
|
||||||
UpdateStrategy: extensions.DaemonSetUpdateStrategy{
|
UpdateStrategy: apps.DaemonSetUpdateStrategy{
|
||||||
Type: extensions.OnDeleteDaemonSetStrategyType,
|
Type: apps.OnDeleteDaemonSetStrategyType,
|
||||||
},
|
},
|
||||||
TemplateGeneration: templateGeneration,
|
TemplateGeneration: templateGeneration,
|
||||||
Template: api.PodTemplateSpec{
|
Template: api.PodTemplateSpec{
|
||||||
|
@ -31,14 +31,14 @@ import (
|
|||||||
"k8s.io/apiserver/pkg/storage"
|
"k8s.io/apiserver/pkg/storage"
|
||||||
storeerr "k8s.io/apiserver/pkg/storage/errors"
|
storeerr "k8s.io/apiserver/pkg/storage/errors"
|
||||||
"k8s.io/apiserver/pkg/util/dryrun"
|
"k8s.io/apiserver/pkg/util/dryrun"
|
||||||
|
"k8s.io/kubernetes/pkg/apis/apps"
|
||||||
appsv1beta1 "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
|
appsv1beta1 "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
|
||||||
appsv1beta2 "k8s.io/kubernetes/pkg/apis/apps/v1beta2"
|
appsv1beta2 "k8s.io/kubernetes/pkg/apis/apps/v1beta2"
|
||||||
|
appsvalidation "k8s.io/kubernetes/pkg/apis/apps/validation"
|
||||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||||
autoscalingv1 "k8s.io/kubernetes/pkg/apis/autoscaling/v1"
|
autoscalingv1 "k8s.io/kubernetes/pkg/apis/autoscaling/v1"
|
||||||
autoscalingvalidation "k8s.io/kubernetes/pkg/apis/autoscaling/validation"
|
autoscalingvalidation "k8s.io/kubernetes/pkg/apis/autoscaling/validation"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
extensionsv1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
|
extensionsv1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
|
||||||
extvalidation "k8s.io/kubernetes/pkg/apis/extensions/validation"
|
|
||||||
"k8s.io/kubernetes/pkg/printers"
|
"k8s.io/kubernetes/pkg/printers"
|
||||||
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
||||||
printerstorage "k8s.io/kubernetes/pkg/printers/storage"
|
printerstorage "k8s.io/kubernetes/pkg/printers/storage"
|
||||||
@ -72,9 +72,9 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against deployments.
|
// NewREST returns a RESTStorage object that will work against deployments.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *RollbackREST) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *RollbackREST) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &extensions.Deployment{} },
|
NewFunc: func() runtime.Object { return &apps.Deployment{} },
|
||||||
NewListFunc: func() runtime.Object { return &extensions.DeploymentList{} },
|
NewListFunc: func() runtime.Object { return &apps.DeploymentList{} },
|
||||||
DefaultQualifiedResource: extensions.Resource("deployments"),
|
DefaultQualifiedResource: apps.Resource("deployments"),
|
||||||
|
|
||||||
CreateStrategy: deployment.Strategy,
|
CreateStrategy: deployment.Strategy,
|
||||||
UpdateStrategy: deployment.Strategy,
|
UpdateStrategy: deployment.Strategy,
|
||||||
@ -119,7 +119,7 @@ type StatusREST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *StatusREST) New() runtime.Object {
|
func (r *StatusREST) New() runtime.Object {
|
||||||
return &extensions.Deployment{}
|
return &apps.Deployment{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get retrieves the object from the storage. It is required to support Patch.
|
// Get retrieves the object from the storage. It is required to support Patch.
|
||||||
@ -155,19 +155,19 @@ var _ = rest.StorageMetadata(&RollbackREST{})
|
|||||||
|
|
||||||
// New creates a rollback
|
// New creates a rollback
|
||||||
func (r *RollbackREST) New() runtime.Object {
|
func (r *RollbackREST) New() runtime.Object {
|
||||||
return &extensions.DeploymentRollback{}
|
return &apps.DeploymentRollback{}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ = rest.Creater(&RollbackREST{})
|
var _ = rest.Creater(&RollbackREST{})
|
||||||
|
|
||||||
func (r *RollbackREST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
|
func (r *RollbackREST) Create(ctx context.Context, obj runtime.Object, createValidation rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
|
||||||
rollback, ok := obj.(*extensions.DeploymentRollback)
|
rollback, ok := obj.(*apps.DeploymentRollback)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errors.NewBadRequest(fmt.Sprintf("not a DeploymentRollback: %#v", obj))
|
return nil, errors.NewBadRequest(fmt.Sprintf("not a DeploymentRollback: %#v", obj))
|
||||||
}
|
}
|
||||||
|
|
||||||
if errs := extvalidation.ValidateDeploymentRollback(rollback); len(errs) != 0 {
|
if errs := appsvalidation.ValidateDeploymentRollback(rollback); len(errs) != 0 {
|
||||||
return nil, errors.NewInvalid(extensions.Kind("DeploymentRollback"), rollback.Name, errs)
|
return nil, errors.NewInvalid(apps.Kind("DeploymentRollback"), rollback.Name, errs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the Deployment with information in DeploymentRollback to trigger rollback
|
// Update the Deployment with information in DeploymentRollback to trigger rollback
|
||||||
@ -182,10 +182,10 @@ func (r *RollbackREST) Create(ctx context.Context, obj runtime.Object, createVal
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RollbackREST) rollbackDeployment(ctx context.Context, deploymentID string, config *extensions.RollbackConfig, annotations map[string]string, dryRun bool) error {
|
func (r *RollbackREST) rollbackDeployment(ctx context.Context, deploymentID string, config *apps.RollbackConfig, annotations map[string]string, dryRun bool) error {
|
||||||
if _, err := r.setDeploymentRollback(ctx, deploymentID, config, annotations, dryRun); err != nil {
|
if _, err := r.setDeploymentRollback(ctx, deploymentID, config, annotations, dryRun); err != nil {
|
||||||
err = storeerr.InterpretGetError(err, extensions.Resource("deployments"), deploymentID)
|
err = storeerr.InterpretGetError(err, apps.Resource("deployments"), deploymentID)
|
||||||
err = storeerr.InterpretUpdateError(err, extensions.Resource("deployments"), deploymentID)
|
err = storeerr.InterpretUpdateError(err, apps.Resource("deployments"), deploymentID)
|
||||||
if _, ok := err.(*errors.StatusError); !ok {
|
if _, ok := err.(*errors.StatusError); !ok {
|
||||||
err = errors.NewInternalError(err)
|
err = errors.NewInternalError(err)
|
||||||
}
|
}
|
||||||
@ -194,14 +194,14 @@ func (r *RollbackREST) rollbackDeployment(ctx context.Context, deploymentID stri
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RollbackREST) setDeploymentRollback(ctx context.Context, deploymentID string, config *extensions.RollbackConfig, annotations map[string]string, dryRun bool) (*extensions.Deployment, error) {
|
func (r *RollbackREST) setDeploymentRollback(ctx context.Context, deploymentID string, config *apps.RollbackConfig, annotations map[string]string, dryRun bool) (*apps.Deployment, error) {
|
||||||
dKey, err := r.store.KeyFunc(ctx, deploymentID)
|
dKey, err := r.store.KeyFunc(ctx, deploymentID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var finalDeployment *extensions.Deployment
|
var finalDeployment *apps.Deployment
|
||||||
err = r.store.Storage.GuaranteedUpdate(ctx, dKey, &extensions.Deployment{}, false, nil, storage.SimpleUpdate(func(obj runtime.Object) (runtime.Object, error) {
|
err = r.store.Storage.GuaranteedUpdate(ctx, dKey, &apps.Deployment{}, false, nil, storage.SimpleUpdate(func(obj runtime.Object) (runtime.Object, error) {
|
||||||
d, ok := obj.(*extensions.Deployment)
|
d, ok := obj.(*apps.Deployment)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("unexpected object: %#v", obj)
|
return nil, fmt.Errorf("unexpected object: %#v", obj)
|
||||||
}
|
}
|
||||||
@ -247,9 +247,9 @@ func (r *ScaleREST) New() runtime.Object {
|
|||||||
func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
|
func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
|
||||||
obj, err := r.store.Get(ctx, name, options)
|
obj, err := r.store.Get(ctx, name, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.NewNotFound(extensions.Resource("deployments/scale"), name)
|
return nil, errors.NewNotFound(apps.Resource("deployments/scale"), name)
|
||||||
}
|
}
|
||||||
deployment := obj.(*extensions.Deployment)
|
deployment := obj.(*apps.Deployment)
|
||||||
scale, err := scaleFromDeployment(deployment)
|
scale, err := scaleFromDeployment(deployment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.NewBadRequest(fmt.Sprintf("%v", err))
|
return nil, errors.NewBadRequest(fmt.Sprintf("%v", err))
|
||||||
@ -260,9 +260,9 @@ func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOpt
|
|||||||
func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) {
|
func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) {
|
||||||
obj, err := r.store.Get(ctx, name, &metav1.GetOptions{})
|
obj, err := r.store.Get(ctx, name, &metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, errors.NewNotFound(extensions.Resource("deployments/scale"), name)
|
return nil, false, errors.NewNotFound(apps.Resource("deployments/scale"), name)
|
||||||
}
|
}
|
||||||
deployment := obj.(*extensions.Deployment)
|
deployment := obj.(*apps.Deployment)
|
||||||
|
|
||||||
oldScale, err := scaleFromDeployment(deployment)
|
oldScale, err := scaleFromDeployment(deployment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -282,7 +282,7 @@ func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.Update
|
|||||||
}
|
}
|
||||||
|
|
||||||
if errs := autoscalingvalidation.ValidateScale(scale); len(errs) > 0 {
|
if errs := autoscalingvalidation.ValidateScale(scale); len(errs) > 0 {
|
||||||
return nil, false, errors.NewInvalid(extensions.Kind("Scale"), name, errs)
|
return nil, false, errors.NewInvalid(autoscaling.Kind("Scale"), name, errs)
|
||||||
}
|
}
|
||||||
|
|
||||||
deployment.Spec.Replicas = scale.Spec.Replicas
|
deployment.Spec.Replicas = scale.Spec.Replicas
|
||||||
@ -291,7 +291,7 @@ func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.Update
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
deployment = obj.(*extensions.Deployment)
|
deployment = obj.(*apps.Deployment)
|
||||||
newScale, err := scaleFromDeployment(deployment)
|
newScale, err := scaleFromDeployment(deployment)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, errors.NewBadRequest(fmt.Sprintf("%v", err))
|
return nil, false, errors.NewBadRequest(fmt.Sprintf("%v", err))
|
||||||
@ -300,7 +300,7 @@ func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.Update
|
|||||||
}
|
}
|
||||||
|
|
||||||
// scaleFromDeployment returns a scale subresource for a deployment.
|
// scaleFromDeployment returns a scale subresource for a deployment.
|
||||||
func scaleFromDeployment(deployment *extensions.Deployment) (*autoscaling.Scale, error) {
|
func scaleFromDeployment(deployment *apps.Deployment) (*autoscaling.Scale, error) {
|
||||||
selector, err := metav1.LabelSelectorAsSelector(deployment.Spec.Selector)
|
selector, err := metav1.LabelSelectorAsSelector(deployment.Spec.Selector)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -35,16 +35,16 @@ import (
|
|||||||
"k8s.io/apiserver/pkg/registry/rest"
|
"k8s.io/apiserver/pkg/registry/rest"
|
||||||
storeerr "k8s.io/apiserver/pkg/storage/errors"
|
storeerr "k8s.io/apiserver/pkg/storage/errors"
|
||||||
etcdtesting "k8s.io/apiserver/pkg/storage/etcd/testing"
|
etcdtesting "k8s.io/apiserver/pkg/storage/etcd/testing"
|
||||||
|
"k8s.io/kubernetes/pkg/apis/apps"
|
||||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultReplicas = 100
|
const defaultReplicas = 100
|
||||||
|
|
||||||
func newStorage(t *testing.T) (*DeploymentStorage, *etcdtesting.EtcdTestServer) {
|
func newStorage(t *testing.T) (*DeploymentStorage, *etcdtesting.EtcdTestServer) {
|
||||||
etcdStorage, server := registrytest.NewEtcdStorage(t, extensions.GroupName)
|
etcdStorage, server := registrytest.NewEtcdStorage(t, apps.GroupName)
|
||||||
restOptions := generic.RESTOptions{StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1, ResourcePrefix: "deployments"}
|
restOptions := generic.RESTOptions{StorageConfig: etcdStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1, ResourcePrefix: "deployments"}
|
||||||
deploymentStorage := NewStorage(restOptions)
|
deploymentStorage := NewStorage(restOptions)
|
||||||
return &deploymentStorage, server
|
return &deploymentStorage, server
|
||||||
@ -53,17 +53,17 @@ func newStorage(t *testing.T) (*DeploymentStorage, *etcdtesting.EtcdTestServer)
|
|||||||
var namespace = "foo-namespace"
|
var namespace = "foo-namespace"
|
||||||
var name = "foo-deployment"
|
var name = "foo-deployment"
|
||||||
|
|
||||||
func validNewDeployment() *extensions.Deployment {
|
func validNewDeployment() *apps.Deployment {
|
||||||
return &extensions.Deployment{
|
return &apps.Deployment{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
},
|
},
|
||||||
Spec: extensions.DeploymentSpec{
|
Spec: apps.DeploymentSpec{
|
||||||
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"a": "b"}},
|
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"a": "b"}},
|
||||||
Strategy: extensions.DeploymentStrategy{
|
Strategy: apps.DeploymentStrategy{
|
||||||
Type: extensions.RollingUpdateDeploymentStrategyType,
|
Type: apps.RollingUpdateDeploymentStrategyType,
|
||||||
RollingUpdate: &extensions.RollingUpdateDeployment{
|
RollingUpdate: &apps.RollingUpdateDeployment{
|
||||||
MaxSurge: intstr.FromInt(1),
|
MaxSurge: intstr.FromInt(1),
|
||||||
MaxUnavailable: intstr.FromInt(1),
|
MaxUnavailable: intstr.FromInt(1),
|
||||||
},
|
},
|
||||||
@ -87,7 +87,7 @@ func validNewDeployment() *extensions.Deployment {
|
|||||||
},
|
},
|
||||||
Replicas: 7,
|
Replicas: 7,
|
||||||
},
|
},
|
||||||
Status: extensions.DeploymentStatus{
|
Status: apps.DeploymentStatus{
|
||||||
Replicas: 5,
|
Replicas: 5,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -106,8 +106,8 @@ func TestCreate(t *testing.T) {
|
|||||||
// valid
|
// valid
|
||||||
deployment,
|
deployment,
|
||||||
// invalid (invalid selector)
|
// invalid (invalid selector)
|
||||||
&extensions.Deployment{
|
&apps.Deployment{
|
||||||
Spec: extensions.DeploymentSpec{
|
Spec: apps.DeploymentSpec{
|
||||||
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{}},
|
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{}},
|
||||||
Template: validDeployment.Spec.Template,
|
Template: validDeployment.Spec.Template,
|
||||||
},
|
},
|
||||||
@ -125,23 +125,23 @@ func TestUpdate(t *testing.T) {
|
|||||||
validNewDeployment(),
|
validNewDeployment(),
|
||||||
// updateFunc
|
// updateFunc
|
||||||
func(obj runtime.Object) runtime.Object {
|
func(obj runtime.Object) runtime.Object {
|
||||||
object := obj.(*extensions.Deployment)
|
object := obj.(*apps.Deployment)
|
||||||
object.Spec.Template.Spec.NodeSelector = map[string]string{"c": "d"}
|
object.Spec.Template.Spec.NodeSelector = map[string]string{"c": "d"}
|
||||||
return object
|
return object
|
||||||
},
|
},
|
||||||
// invalid updateFunc
|
// invalid updateFunc
|
||||||
func(obj runtime.Object) runtime.Object {
|
func(obj runtime.Object) runtime.Object {
|
||||||
object := obj.(*extensions.Deployment)
|
object := obj.(*apps.Deployment)
|
||||||
object.Name = ""
|
object.Name = ""
|
||||||
return object
|
return object
|
||||||
},
|
},
|
||||||
func(obj runtime.Object) runtime.Object {
|
func(obj runtime.Object) runtime.Object {
|
||||||
object := obj.(*extensions.Deployment)
|
object := obj.(*apps.Deployment)
|
||||||
object.Spec.Template.Spec.RestartPolicy = api.RestartPolicyOnFailure
|
object.Spec.Template.Spec.RestartPolicy = api.RestartPolicyOnFailure
|
||||||
return object
|
return object
|
||||||
},
|
},
|
||||||
func(obj runtime.Object) runtime.Object {
|
func(obj runtime.Object) runtime.Object {
|
||||||
object := obj.(*extensions.Deployment)
|
object := obj.(*apps.Deployment)
|
||||||
object.Spec.Selector = &metav1.LabelSelector{MatchLabels: map[string]string{}}
|
object.Spec.Selector = &metav1.LabelSelector{MatchLabels: map[string]string{}}
|
||||||
return object
|
return object
|
||||||
},
|
},
|
||||||
@ -202,7 +202,7 @@ func TestScaleGet(t *testing.T) {
|
|||||||
storage, server := newStorage(t)
|
storage, server := newStorage(t)
|
||||||
defer server.Terminate(t)
|
defer server.Terminate(t)
|
||||||
defer storage.Deployment.Store.DestroyFunc()
|
defer storage.Deployment.Store.DestroyFunc()
|
||||||
var deployment extensions.Deployment
|
var deployment apps.Deployment
|
||||||
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), namespace)
|
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), namespace)
|
||||||
key := "/deployments/" + namespace + "/" + name
|
key := "/deployments/" + namespace + "/" + name
|
||||||
if err := storage.Deployment.Storage.Create(ctx, key, &validDeployment, &deployment, 0, false); err != nil {
|
if err := storage.Deployment.Storage.Create(ctx, key, &validDeployment, &deployment, 0, false); err != nil {
|
||||||
@ -243,7 +243,7 @@ func TestScaleUpdate(t *testing.T) {
|
|||||||
storage, server := newStorage(t)
|
storage, server := newStorage(t)
|
||||||
defer server.Terminate(t)
|
defer server.Terminate(t)
|
||||||
defer storage.Deployment.Store.DestroyFunc()
|
defer storage.Deployment.Store.DestroyFunc()
|
||||||
var deployment extensions.Deployment
|
var deployment apps.Deployment
|
||||||
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), namespace)
|
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), namespace)
|
||||||
key := "/deployments/" + namespace + "/" + name
|
key := "/deployments/" + namespace + "/" + name
|
||||||
if err := storage.Deployment.Storage.Create(ctx, key, &validDeployment, &deployment, 0, false); err != nil {
|
if err := storage.Deployment.Storage.Create(ctx, key, &validDeployment, &deployment, 0, false); err != nil {
|
||||||
@ -286,12 +286,12 @@ func TestStatusUpdate(t *testing.T) {
|
|||||||
if err := storage.Deployment.Storage.Create(ctx, key, &validDeployment, nil, 0, false); err != nil {
|
if err := storage.Deployment.Storage.Create(ctx, key, &validDeployment, nil, 0, false); err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
update := extensions.Deployment{
|
update := apps.Deployment{
|
||||||
ObjectMeta: validDeployment.ObjectMeta,
|
ObjectMeta: validDeployment.ObjectMeta,
|
||||||
Spec: extensions.DeploymentSpec{
|
Spec: apps.DeploymentSpec{
|
||||||
Replicas: defaultReplicas,
|
Replicas: defaultReplicas,
|
||||||
},
|
},
|
||||||
Status: extensions.DeploymentStatus{
|
Status: apps.DeploymentStatus{
|
||||||
Replicas: defaultReplicas,
|
Replicas: defaultReplicas,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -304,7 +304,7 @@ func TestStatusUpdate(t *testing.T) {
|
|||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
deployment := obj.(*extensions.Deployment)
|
deployment := obj.(*apps.Deployment)
|
||||||
if deployment.Spec.Replicas != 7 {
|
if deployment.Spec.Replicas != 7 {
|
||||||
t.Errorf("we expected .spec.replicas to not be updated but it was updated to %v", deployment.Spec.Replicas)
|
t.Errorf("we expected .spec.replicas to not be updated but it was updated to %v", deployment.Spec.Replicas)
|
||||||
}
|
}
|
||||||
@ -317,28 +317,28 @@ func TestEtcdCreateDeploymentRollback(t *testing.T) {
|
|||||||
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), namespace)
|
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), namespace)
|
||||||
|
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
rollback extensions.DeploymentRollback
|
rollback apps.DeploymentRollback
|
||||||
errOK func(error) bool
|
errOK func(error) bool
|
||||||
}{
|
}{
|
||||||
"normal": {
|
"normal": {
|
||||||
rollback: extensions.DeploymentRollback{
|
rollback: apps.DeploymentRollback{
|
||||||
Name: name,
|
Name: name,
|
||||||
UpdatedAnnotations: map[string]string{},
|
UpdatedAnnotations: map[string]string{},
|
||||||
RollbackTo: extensions.RollbackConfig{Revision: 1},
|
RollbackTo: apps.RollbackConfig{Revision: 1},
|
||||||
},
|
},
|
||||||
errOK: func(err error) bool { return err == nil },
|
errOK: func(err error) bool { return err == nil },
|
||||||
},
|
},
|
||||||
"noAnnotation": {
|
"noAnnotation": {
|
||||||
rollback: extensions.DeploymentRollback{
|
rollback: apps.DeploymentRollback{
|
||||||
Name: name,
|
Name: name,
|
||||||
RollbackTo: extensions.RollbackConfig{Revision: 1},
|
RollbackTo: apps.RollbackConfig{Revision: 1},
|
||||||
},
|
},
|
||||||
errOK: func(err error) bool { return err == nil },
|
errOK: func(err error) bool { return err == nil },
|
||||||
},
|
},
|
||||||
"noName": {
|
"noName": {
|
||||||
rollback: extensions.DeploymentRollback{
|
rollback: apps.DeploymentRollback{
|
||||||
UpdatedAnnotations: map[string]string{},
|
UpdatedAnnotations: map[string]string{},
|
||||||
RollbackTo: extensions.RollbackConfig{Revision: 1},
|
RollbackTo: apps.RollbackConfig{Revision: 1},
|
||||||
},
|
},
|
||||||
errOK: func(err error) bool { return err != nil },
|
errOK: func(err error) bool { return err != nil },
|
||||||
},
|
},
|
||||||
@ -365,8 +365,8 @@ func TestEtcdCreateDeploymentRollback(t *testing.T) {
|
|||||||
d, err := storage.Deployment.Get(ctx, validNewDeployment().ObjectMeta.Name, &metav1.GetOptions{})
|
d, err := storage.Deployment.Get(ctx, validNewDeployment().ObjectMeta.Name, &metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("%s: unexpected error: %v", k, err)
|
t.Errorf("%s: unexpected error: %v", k, err)
|
||||||
} else if !reflect.DeepEqual(*d.(*extensions.Deployment).Spec.RollbackTo, test.rollback.RollbackTo) {
|
} else if !reflect.DeepEqual(*d.(*apps.Deployment).Spec.RollbackTo, test.rollback.RollbackTo) {
|
||||||
t.Errorf("%s: expected: %v, got: %v", k, *d.(*extensions.Deployment).Spec.RollbackTo, test.rollback.RollbackTo)
|
t.Errorf("%s: expected: %v, got: %v", k, *d.(*apps.Deployment).Spec.RollbackTo, test.rollback.RollbackTo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
storage.Deployment.Store.DestroyFunc()
|
storage.Deployment.Store.DestroyFunc()
|
||||||
@ -383,15 +383,15 @@ func TestEtcdCreateDeploymentRollbackNoDeployment(t *testing.T) {
|
|||||||
rollbackStorage := storage.Rollback
|
rollbackStorage := storage.Rollback
|
||||||
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), namespace)
|
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), namespace)
|
||||||
|
|
||||||
_, err := rollbackStorage.Create(ctx, &extensions.DeploymentRollback{
|
_, err := rollbackStorage.Create(ctx, &apps.DeploymentRollback{
|
||||||
Name: name,
|
Name: name,
|
||||||
UpdatedAnnotations: map[string]string{},
|
UpdatedAnnotations: map[string]string{},
|
||||||
RollbackTo: extensions.RollbackConfig{Revision: 1},
|
RollbackTo: apps.RollbackConfig{Revision: 1},
|
||||||
}, rest.ValidateAllObjectFunc, &metav1.CreateOptions{})
|
}, rest.ValidateAllObjectFunc, &metav1.CreateOptions{})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("Expected not-found-error but got nothing")
|
t.Fatalf("Expected not-found-error but got nothing")
|
||||||
}
|
}
|
||||||
if !errors.IsNotFound(storeerr.InterpretGetError(err, extensions.Resource("deployments"), name)) {
|
if !errors.IsNotFound(storeerr.InterpretGetError(err, apps.Resource("deployments"), name)) {
|
||||||
t.Fatalf("Unexpected error returned: %#v", err)
|
t.Fatalf("Unexpected error returned: %#v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,7 +399,7 @@ func TestEtcdCreateDeploymentRollbackNoDeployment(t *testing.T) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("Expected not-found-error but got nothing")
|
t.Fatalf("Expected not-found-error but got nothing")
|
||||||
}
|
}
|
||||||
if !errors.IsNotFound(storeerr.InterpretGetError(err, extensions.Resource("deployments"), name)) {
|
if !errors.IsNotFound(storeerr.InterpretGetError(err, apps.Resource("deployments"), name)) {
|
||||||
t.Fatalf("Unexpected error: %v", err)
|
t.Fatalf("Unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,8 @@ import (
|
|||||||
"k8s.io/apiserver/pkg/storage/names"
|
"k8s.io/apiserver/pkg/storage/names"
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
"k8s.io/kubernetes/pkg/api/pod"
|
"k8s.io/kubernetes/pkg/api/pod"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
"k8s.io/kubernetes/pkg/apis/apps"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions/validation"
|
"k8s.io/kubernetes/pkg/apis/apps/validation"
|
||||||
)
|
)
|
||||||
|
|
||||||
// deploymentStrategy implements behavior for Deployments.
|
// deploymentStrategy implements behavior for Deployments.
|
||||||
@ -68,8 +68,8 @@ func (deploymentStrategy) NamespaceScoped() bool {
|
|||||||
|
|
||||||
// PrepareForCreate clears fields that are not allowed to be set by end users on creation.
|
// PrepareForCreate clears fields that are not allowed to be set by end users on creation.
|
||||||
func (deploymentStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
func (deploymentStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
||||||
deployment := obj.(*extensions.Deployment)
|
deployment := obj.(*apps.Deployment)
|
||||||
deployment.Status = extensions.DeploymentStatus{}
|
deployment.Status = apps.DeploymentStatus{}
|
||||||
deployment.Generation = 1
|
deployment.Generation = 1
|
||||||
|
|
||||||
pod.DropDisabledAlphaFields(&deployment.Spec.Template.Spec)
|
pod.DropDisabledAlphaFields(&deployment.Spec.Template.Spec)
|
||||||
@ -77,7 +77,7 @@ func (deploymentStrategy) PrepareForCreate(ctx context.Context, obj runtime.Obje
|
|||||||
|
|
||||||
// Validate validates a new deployment.
|
// Validate validates a new deployment.
|
||||||
func (deploymentStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
func (deploymentStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
||||||
deployment := obj.(*extensions.Deployment)
|
deployment := obj.(*apps.Deployment)
|
||||||
return validation.ValidateDeployment(deployment)
|
return validation.ValidateDeployment(deployment)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,8 +92,8 @@ func (deploymentStrategy) AllowCreateOnUpdate() bool {
|
|||||||
|
|
||||||
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
|
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
|
||||||
func (deploymentStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
func (deploymentStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||||
newDeployment := obj.(*extensions.Deployment)
|
newDeployment := obj.(*apps.Deployment)
|
||||||
oldDeployment := old.(*extensions.Deployment)
|
oldDeployment := old.(*apps.Deployment)
|
||||||
newDeployment.Status = oldDeployment.Status
|
newDeployment.Status = oldDeployment.Status
|
||||||
|
|
||||||
pod.DropDisabledAlphaFields(&newDeployment.Spec.Template.Spec)
|
pod.DropDisabledAlphaFields(&newDeployment.Spec.Template.Spec)
|
||||||
@ -110,8 +110,8 @@ func (deploymentStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime
|
|||||||
|
|
||||||
// ValidateUpdate is the default update validation for an end user.
|
// ValidateUpdate is the default update validation for an end user.
|
||||||
func (deploymentStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
func (deploymentStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||||
newDeployment := obj.(*extensions.Deployment)
|
newDeployment := obj.(*apps.Deployment)
|
||||||
oldDeployment := old.(*extensions.Deployment)
|
oldDeployment := old.(*apps.Deployment)
|
||||||
allErrs := validation.ValidateDeploymentUpdate(newDeployment, oldDeployment)
|
allErrs := validation.ValidateDeploymentUpdate(newDeployment, oldDeployment)
|
||||||
|
|
||||||
// Update is not allowed to set Spec.Selector for all groups/versions except extensions/v1beta1.
|
// Update is not allowed to set Spec.Selector for all groups/versions except extensions/v1beta1.
|
||||||
@ -145,13 +145,13 @@ var StatusStrategy = deploymentStatusStrategy{Strategy}
|
|||||||
|
|
||||||
// PrepareForUpdate clears fields that are not allowed to be set by end users on update of status
|
// PrepareForUpdate clears fields that are not allowed to be set by end users on update of status
|
||||||
func (deploymentStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
func (deploymentStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||||
newDeployment := obj.(*extensions.Deployment)
|
newDeployment := obj.(*apps.Deployment)
|
||||||
oldDeployment := old.(*extensions.Deployment)
|
oldDeployment := old.(*apps.Deployment)
|
||||||
newDeployment.Spec = oldDeployment.Spec
|
newDeployment.Spec = oldDeployment.Spec
|
||||||
newDeployment.Labels = oldDeployment.Labels
|
newDeployment.Labels = oldDeployment.Labels
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateUpdate is the default update validation for an end user updating status
|
// ValidateUpdate is the default update validation for an end user updating status
|
||||||
func (deploymentStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
func (deploymentStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||||
return validation.ValidateDeploymentStatusUpdate(obj.(*extensions.Deployment), old.(*extensions.Deployment))
|
return validation.ValidateDeploymentStatusUpdate(obj.(*apps.Deployment), old.(*apps.Deployment))
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
"k8s.io/apiserver/pkg/registry/rest"
|
||||||
|
"k8s.io/kubernetes/pkg/apis/apps"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -63,17 +63,17 @@ func TestStatusUpdates(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDeployment(labels, annotations map[string]string) *extensions.Deployment {
|
func newDeployment(labels, annotations map[string]string) *apps.Deployment {
|
||||||
return &extensions.Deployment{
|
return &apps.Deployment{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "test",
|
Name: "test",
|
||||||
Labels: labels,
|
Labels: labels,
|
||||||
Annotations: annotations,
|
Annotations: annotations,
|
||||||
},
|
},
|
||||||
Spec: extensions.DeploymentSpec{
|
Spec: apps.DeploymentSpec{
|
||||||
Replicas: 1,
|
Replicas: 1,
|
||||||
Strategy: extensions.DeploymentStrategy{
|
Strategy: apps.DeploymentStrategy{
|
||||||
Type: extensions.RecreateDeploymentStrategyType,
|
Type: apps.RecreateDeploymentStrategyType,
|
||||||
},
|
},
|
||||||
Template: api.PodTemplateSpec{
|
Template: api.PodTemplateSpec{
|
||||||
Spec: api.PodSpec{
|
Spec: api.PodSpec{
|
||||||
@ -152,21 +152,21 @@ func TestSelectorImmutability(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDeploymentWithSelectorLabels(selectorLabels map[string]string) *extensions.Deployment {
|
func newDeploymentWithSelectorLabels(selectorLabels map[string]string) *apps.Deployment {
|
||||||
return &extensions.Deployment{
|
return &apps.Deployment{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: deploymentName,
|
Name: deploymentName,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
ResourceVersion: "1",
|
ResourceVersion: "1",
|
||||||
},
|
},
|
||||||
Spec: extensions.DeploymentSpec{
|
Spec: apps.DeploymentSpec{
|
||||||
Selector: &metav1.LabelSelector{
|
Selector: &metav1.LabelSelector{
|
||||||
MatchLabels: selectorLabels,
|
MatchLabels: selectorLabels,
|
||||||
MatchExpressions: []metav1.LabelSelectorRequirement{},
|
MatchExpressions: []metav1.LabelSelectorRequirement{},
|
||||||
},
|
},
|
||||||
Strategy: extensions.DeploymentStrategy{
|
Strategy: apps.DeploymentStrategy{
|
||||||
Type: extensions.RollingUpdateDeploymentStrategyType,
|
Type: apps.RollingUpdateDeploymentStrategyType,
|
||||||
RollingUpdate: &extensions.RollingUpdateDeployment{
|
RollingUpdate: &apps.RollingUpdateDeployment{
|
||||||
MaxSurge: intstr.FromInt(1),
|
MaxSurge: intstr.FromInt(1),
|
||||||
MaxUnavailable: intstr.FromInt(1),
|
MaxUnavailable: intstr.FromInt(1),
|
||||||
},
|
},
|
||||||
|
@ -29,12 +29,12 @@ import (
|
|||||||
"k8s.io/apiserver/pkg/registry/generic"
|
"k8s.io/apiserver/pkg/registry/generic"
|
||||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
"k8s.io/apiserver/pkg/registry/rest"
|
||||||
|
"k8s.io/kubernetes/pkg/apis/apps"
|
||||||
appsv1beta1 "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
|
appsv1beta1 "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
|
||||||
appsv1beta2 "k8s.io/kubernetes/pkg/apis/apps/v1beta2"
|
appsv1beta2 "k8s.io/kubernetes/pkg/apis/apps/v1beta2"
|
||||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||||
autoscalingv1 "k8s.io/kubernetes/pkg/apis/autoscaling/v1"
|
autoscalingv1 "k8s.io/kubernetes/pkg/apis/autoscaling/v1"
|
||||||
autoscalingvalidation "k8s.io/kubernetes/pkg/apis/autoscaling/validation"
|
autoscalingvalidation "k8s.io/kubernetes/pkg/apis/autoscaling/validation"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
extensionsv1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
|
extensionsv1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
|
||||||
"k8s.io/kubernetes/pkg/printers"
|
"k8s.io/kubernetes/pkg/printers"
|
||||||
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
||||||
@ -67,10 +67,10 @@ type REST struct {
|
|||||||
// NewREST returns a RESTStorage object that will work against ReplicaSet.
|
// NewREST returns a RESTStorage object that will work against ReplicaSet.
|
||||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
|
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
|
||||||
store := &genericregistry.Store{
|
store := &genericregistry.Store{
|
||||||
NewFunc: func() runtime.Object { return &extensions.ReplicaSet{} },
|
NewFunc: func() runtime.Object { return &apps.ReplicaSet{} },
|
||||||
NewListFunc: func() runtime.Object { return &extensions.ReplicaSetList{} },
|
NewListFunc: func() runtime.Object { return &apps.ReplicaSetList{} },
|
||||||
PredicateFunc: replicaset.MatchReplicaSet,
|
PredicateFunc: replicaset.MatchReplicaSet,
|
||||||
DefaultQualifiedResource: extensions.Resource("replicasets"),
|
DefaultQualifiedResource: apps.Resource("replicasets"),
|
||||||
|
|
||||||
CreateStrategy: replicaset.Strategy,
|
CreateStrategy: replicaset.Strategy,
|
||||||
UpdateStrategy: replicaset.Strategy,
|
UpdateStrategy: replicaset.Strategy,
|
||||||
@ -116,7 +116,7 @@ type StatusREST struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *StatusREST) New() runtime.Object {
|
func (r *StatusREST) New() runtime.Object {
|
||||||
return &extensions.ReplicaSet{}
|
return &apps.ReplicaSet{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get retrieves the object from the storage. It is required to support Patch.
|
// Get retrieves the object from the storage. It is required to support Patch.
|
||||||
@ -160,9 +160,9 @@ func (r *ScaleREST) New() runtime.Object {
|
|||||||
func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
|
func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOptions) (runtime.Object, error) {
|
||||||
obj, err := r.store.Get(ctx, name, options)
|
obj, err := r.store.Get(ctx, name, options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.NewNotFound(extensions.Resource("replicasets/scale"), name)
|
return nil, errors.NewNotFound(apps.Resource("replicasets/scale"), name)
|
||||||
}
|
}
|
||||||
rs := obj.(*extensions.ReplicaSet)
|
rs := obj.(*apps.ReplicaSet)
|
||||||
scale, err := scaleFromReplicaSet(rs)
|
scale, err := scaleFromReplicaSet(rs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.NewBadRequest(fmt.Sprintf("%v", err))
|
return nil, errors.NewBadRequest(fmt.Sprintf("%v", err))
|
||||||
@ -173,9 +173,9 @@ func (r *ScaleREST) Get(ctx context.Context, name string, options *metav1.GetOpt
|
|||||||
func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) {
|
func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) {
|
||||||
obj, err := r.store.Get(ctx, name, &metav1.GetOptions{})
|
obj, err := r.store.Get(ctx, name, &metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, errors.NewNotFound(extensions.Resource("replicasets/scale"), name)
|
return nil, false, errors.NewNotFound(apps.Resource("replicasets/scale"), name)
|
||||||
}
|
}
|
||||||
rs := obj.(*extensions.ReplicaSet)
|
rs := obj.(*apps.ReplicaSet)
|
||||||
|
|
||||||
oldScale, err := scaleFromReplicaSet(rs)
|
oldScale, err := scaleFromReplicaSet(rs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -196,7 +196,7 @@ func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.Update
|
|||||||
}
|
}
|
||||||
|
|
||||||
if errs := autoscalingvalidation.ValidateScale(scale); len(errs) > 0 {
|
if errs := autoscalingvalidation.ValidateScale(scale); len(errs) > 0 {
|
||||||
return nil, false, errors.NewInvalid(extensions.Kind("Scale"), scale.Name, errs)
|
return nil, false, errors.NewInvalid(autoscaling.Kind("Scale"), scale.Name, errs)
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.Spec.Replicas = scale.Spec.Replicas
|
rs.Spec.Replicas = scale.Spec.Replicas
|
||||||
@ -205,7 +205,7 @@ func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.Update
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
rs = obj.(*extensions.ReplicaSet)
|
rs = obj.(*apps.ReplicaSet)
|
||||||
newScale, err := scaleFromReplicaSet(rs)
|
newScale, err := scaleFromReplicaSet(rs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, errors.NewBadRequest(fmt.Sprintf("%v", err))
|
return nil, false, errors.NewBadRequest(fmt.Sprintf("%v", err))
|
||||||
@ -214,7 +214,7 @@ func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.Update
|
|||||||
}
|
}
|
||||||
|
|
||||||
// scaleFromReplicaSet returns a scale subresource for a replica set.
|
// scaleFromReplicaSet returns a scale subresource for a replica set.
|
||||||
func scaleFromReplicaSet(rs *extensions.ReplicaSet) (*autoscaling.Scale, error) {
|
func scaleFromReplicaSet(rs *apps.ReplicaSet) (*autoscaling.Scale, error) {
|
||||||
selector, err := metav1.LabelSelectorAsSelector(rs.Spec.Selector)
|
selector, err := metav1.LabelSelectorAsSelector(rs.Spec.Selector)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -31,9 +31,9 @@ import (
|
|||||||
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
"k8s.io/apiserver/pkg/registry/rest"
|
||||||
etcdtesting "k8s.io/apiserver/pkg/storage/etcd/testing"
|
etcdtesting "k8s.io/apiserver/pkg/storage/etcd/testing"
|
||||||
|
"k8s.io/kubernetes/pkg/apis/apps"
|
||||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -47,23 +47,23 @@ func newStorage(t *testing.T) (*ReplicaSetStorage, *etcdtesting.EtcdTestServer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// createReplicaSet is a helper function that returns a ReplicaSet with the updated resource version.
|
// createReplicaSet is a helper function that returns a ReplicaSet with the updated resource version.
|
||||||
func createReplicaSet(storage *REST, rs extensions.ReplicaSet, t *testing.T) (extensions.ReplicaSet, error) {
|
func createReplicaSet(storage *REST, rs apps.ReplicaSet, t *testing.T) (apps.ReplicaSet, error) {
|
||||||
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), rs.Namespace)
|
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), rs.Namespace)
|
||||||
obj, err := storage.Create(ctx, &rs, rest.ValidateAllObjectFunc, &metav1.CreateOptions{})
|
obj, err := storage.Create(ctx, &rs, rest.ValidateAllObjectFunc, &metav1.CreateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Failed to create ReplicaSet, %v", err)
|
t.Errorf("Failed to create ReplicaSet, %v", err)
|
||||||
}
|
}
|
||||||
newRS := obj.(*extensions.ReplicaSet)
|
newRS := obj.(*apps.ReplicaSet)
|
||||||
return *newRS, nil
|
return *newRS, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func validNewReplicaSet() *extensions.ReplicaSet {
|
func validNewReplicaSet() *apps.ReplicaSet {
|
||||||
return &extensions.ReplicaSet{
|
return &apps.ReplicaSet{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Namespace: metav1.NamespaceDefault,
|
Namespace: metav1.NamespaceDefault,
|
||||||
},
|
},
|
||||||
Spec: extensions.ReplicaSetSpec{
|
Spec: apps.ReplicaSetSpec{
|
||||||
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"a": "b"}},
|
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"a": "b"}},
|
||||||
Template: api.PodTemplateSpec{
|
Template: api.PodTemplateSpec{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
@ -84,7 +84,7 @@ func validNewReplicaSet() *extensions.ReplicaSet {
|
|||||||
},
|
},
|
||||||
Replicas: 7,
|
Replicas: 7,
|
||||||
},
|
},
|
||||||
Status: extensions.ReplicaSetStatus{
|
Status: apps.ReplicaSetStatus{
|
||||||
Replicas: 5,
|
Replicas: 5,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -103,8 +103,8 @@ func TestCreate(t *testing.T) {
|
|||||||
// valid
|
// valid
|
||||||
rs,
|
rs,
|
||||||
// invalid (invalid selector)
|
// invalid (invalid selector)
|
||||||
&extensions.ReplicaSet{
|
&apps.ReplicaSet{
|
||||||
Spec: extensions.ReplicaSetSpec{
|
Spec: apps.ReplicaSetSpec{
|
||||||
Replicas: 2,
|
Replicas: 2,
|
||||||
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{}},
|
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{}},
|
||||||
Template: validReplicaSet.Spec.Template,
|
Template: validReplicaSet.Spec.Template,
|
||||||
@ -123,18 +123,18 @@ func TestUpdate(t *testing.T) {
|
|||||||
validNewReplicaSet(),
|
validNewReplicaSet(),
|
||||||
// valid updateFunc
|
// valid updateFunc
|
||||||
func(obj runtime.Object) runtime.Object {
|
func(obj runtime.Object) runtime.Object {
|
||||||
object := obj.(*extensions.ReplicaSet)
|
object := obj.(*apps.ReplicaSet)
|
||||||
object.Spec.Replicas = object.Spec.Replicas + 1
|
object.Spec.Replicas = object.Spec.Replicas + 1
|
||||||
return object
|
return object
|
||||||
},
|
},
|
||||||
// invalid updateFunc
|
// invalid updateFunc
|
||||||
func(obj runtime.Object) runtime.Object {
|
func(obj runtime.Object) runtime.Object {
|
||||||
object := obj.(*extensions.ReplicaSet)
|
object := obj.(*apps.ReplicaSet)
|
||||||
object.Name = ""
|
object.Name = ""
|
||||||
return object
|
return object
|
||||||
},
|
},
|
||||||
func(obj runtime.Object) runtime.Object {
|
func(obj runtime.Object) runtime.Object {
|
||||||
object := obj.(*extensions.ReplicaSet)
|
object := obj.(*apps.ReplicaSet)
|
||||||
object.Spec.Selector = &metav1.LabelSelector{MatchLabels: map[string]string{}}
|
object.Spec.Selector = &metav1.LabelSelector{MatchLabels: map[string]string{}}
|
||||||
return object
|
return object
|
||||||
},
|
},
|
||||||
@ -165,7 +165,7 @@ func TestGenerationNumber(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
storedRS, _ := etcdRS.(*extensions.ReplicaSet)
|
storedRS, _ := etcdRS.(*apps.ReplicaSet)
|
||||||
|
|
||||||
// Generation initialization
|
// Generation initialization
|
||||||
if storedRS.Generation != 1 || storedRS.Status.ObservedGeneration != 0 {
|
if storedRS.Generation != 1 || storedRS.Status.ObservedGeneration != 0 {
|
||||||
@ -181,7 +181,7 @@ func TestGenerationNumber(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
storedRS, _ = etcdRS.(*extensions.ReplicaSet)
|
storedRS, _ = etcdRS.(*apps.ReplicaSet)
|
||||||
if storedRS.Generation != 2 || storedRS.Status.ObservedGeneration != 0 {
|
if storedRS.Generation != 2 || storedRS.Status.ObservedGeneration != 0 {
|
||||||
t.Fatalf("Unexpected generation, spec: %v, status: %v", storedRS.Generation, storedRS.Status.ObservedGeneration)
|
t.Fatalf("Unexpected generation, spec: %v, status: %v", storedRS.Generation, storedRS.Status.ObservedGeneration)
|
||||||
}
|
}
|
||||||
@ -195,7 +195,7 @@ func TestGenerationNumber(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
storedRS, _ = etcdRS.(*extensions.ReplicaSet)
|
storedRS, _ = etcdRS.(*apps.ReplicaSet)
|
||||||
if storedRS.Generation != 2 || storedRS.Status.ObservedGeneration != 0 {
|
if storedRS.Generation != 2 || storedRS.Status.ObservedGeneration != 0 {
|
||||||
t.Fatalf("Unexpected generation number, spec: %v, status: %v", storedRS.Generation, storedRS.Status.ObservedGeneration)
|
t.Fatalf("Unexpected generation number, spec: %v, status: %v", storedRS.Generation, storedRS.Status.ObservedGeneration)
|
||||||
}
|
}
|
||||||
@ -257,7 +257,7 @@ func TestScaleGet(t *testing.T) {
|
|||||||
|
|
||||||
name := "foo"
|
name := "foo"
|
||||||
|
|
||||||
var rs extensions.ReplicaSet
|
var rs apps.ReplicaSet
|
||||||
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), metav1.NamespaceDefault)
|
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), metav1.NamespaceDefault)
|
||||||
key := "/replicasets/" + metav1.NamespaceDefault + "/" + name
|
key := "/replicasets/" + metav1.NamespaceDefault + "/" + name
|
||||||
if err := storage.ReplicaSet.Storage.Create(ctx, key, &validReplicaSet, &rs, 0, false); err != nil {
|
if err := storage.ReplicaSet.Storage.Create(ctx, key, &validReplicaSet, &rs, 0, false); err != nil {
|
||||||
@ -302,7 +302,7 @@ func TestScaleUpdate(t *testing.T) {
|
|||||||
|
|
||||||
name := "foo"
|
name := "foo"
|
||||||
|
|
||||||
var rs extensions.ReplicaSet
|
var rs apps.ReplicaSet
|
||||||
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), metav1.NamespaceDefault)
|
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), metav1.NamespaceDefault)
|
||||||
key := "/replicasets/" + metav1.NamespaceDefault + "/" + name
|
key := "/replicasets/" + metav1.NamespaceDefault + "/" + name
|
||||||
if err := storage.ReplicaSet.Storage.Create(ctx, key, &validReplicaSet, &rs, 0, false); err != nil {
|
if err := storage.ReplicaSet.Storage.Create(ctx, key, &validReplicaSet, &rs, 0, false); err != nil {
|
||||||
@ -350,12 +350,12 @@ func TestStatusUpdate(t *testing.T) {
|
|||||||
if err := storage.ReplicaSet.Storage.Create(ctx, key, &validReplicaSet, nil, 0, false); err != nil {
|
if err := storage.ReplicaSet.Storage.Create(ctx, key, &validReplicaSet, nil, 0, false); err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
update := extensions.ReplicaSet{
|
update := apps.ReplicaSet{
|
||||||
ObjectMeta: validReplicaSet.ObjectMeta,
|
ObjectMeta: validReplicaSet.ObjectMeta,
|
||||||
Spec: extensions.ReplicaSetSpec{
|
Spec: apps.ReplicaSetSpec{
|
||||||
Replicas: defaultReplicas,
|
Replicas: defaultReplicas,
|
||||||
},
|
},
|
||||||
Status: extensions.ReplicaSetStatus{
|
Status: apps.ReplicaSetStatus{
|
||||||
Replicas: defaultReplicas,
|
Replicas: defaultReplicas,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -368,7 +368,7 @@ func TestStatusUpdate(t *testing.T) {
|
|||||||
t.Fatalf("unexpected error: %v", err)
|
t.Fatalf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
rs := obj.(*extensions.ReplicaSet)
|
rs := obj.(*apps.ReplicaSet)
|
||||||
if rs.Spec.Replicas != 7 {
|
if rs.Spec.Replicas != 7 {
|
||||||
t.Errorf("we expected .spec.replicas to not be updated but it was updated to %v", rs.Spec.Replicas)
|
t.Errorf("we expected .spec.replicas to not be updated but it was updated to %v", rs.Spec.Replicas)
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,8 @@ import (
|
|||||||
"k8s.io/apiserver/pkg/storage/names"
|
"k8s.io/apiserver/pkg/storage/names"
|
||||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||||
"k8s.io/kubernetes/pkg/api/pod"
|
"k8s.io/kubernetes/pkg/api/pod"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
"k8s.io/kubernetes/pkg/apis/apps"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions/validation"
|
"k8s.io/kubernetes/pkg/apis/apps/validation"
|
||||||
)
|
)
|
||||||
|
|
||||||
// rsStrategy implements verification logic for ReplicaSets.
|
// rsStrategy implements verification logic for ReplicaSets.
|
||||||
@ -74,8 +74,8 @@ func (rsStrategy) NamespaceScoped() bool {
|
|||||||
|
|
||||||
// PrepareForCreate clears the status of a ReplicaSet before creation.
|
// PrepareForCreate clears the status of a ReplicaSet before creation.
|
||||||
func (rsStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
func (rsStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
||||||
rs := obj.(*extensions.ReplicaSet)
|
rs := obj.(*apps.ReplicaSet)
|
||||||
rs.Status = extensions.ReplicaSetStatus{}
|
rs.Status = apps.ReplicaSetStatus{}
|
||||||
|
|
||||||
rs.Generation = 1
|
rs.Generation = 1
|
||||||
|
|
||||||
@ -84,8 +84,8 @@ func (rsStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
|||||||
|
|
||||||
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
|
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
|
||||||
func (rsStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
func (rsStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||||
newRS := obj.(*extensions.ReplicaSet)
|
newRS := obj.(*apps.ReplicaSet)
|
||||||
oldRS := old.(*extensions.ReplicaSet)
|
oldRS := old.(*apps.ReplicaSet)
|
||||||
// update is not allowed to set status
|
// update is not allowed to set status
|
||||||
newRS.Status = oldRS.Status
|
newRS.Status = oldRS.Status
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ func (rsStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object)
|
|||||||
|
|
||||||
// Validate validates a new ReplicaSet.
|
// Validate validates a new ReplicaSet.
|
||||||
func (rsStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
func (rsStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
||||||
rs := obj.(*extensions.ReplicaSet)
|
rs := obj.(*apps.ReplicaSet)
|
||||||
return validation.ValidateReplicaSet(rs)
|
return validation.ValidateReplicaSet(rs)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,9 +123,9 @@ func (rsStrategy) AllowCreateOnUpdate() bool {
|
|||||||
|
|
||||||
// ValidateUpdate is the default update validation for an end user.
|
// ValidateUpdate is the default update validation for an end user.
|
||||||
func (rsStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
func (rsStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||||
newReplicaSet := obj.(*extensions.ReplicaSet)
|
newReplicaSet := obj.(*apps.ReplicaSet)
|
||||||
oldReplicaSet := old.(*extensions.ReplicaSet)
|
oldReplicaSet := old.(*apps.ReplicaSet)
|
||||||
allErrs := validation.ValidateReplicaSet(obj.(*extensions.ReplicaSet))
|
allErrs := validation.ValidateReplicaSet(obj.(*apps.ReplicaSet))
|
||||||
allErrs = append(allErrs, validation.ValidateReplicaSetUpdate(newReplicaSet, oldReplicaSet)...)
|
allErrs = append(allErrs, validation.ValidateReplicaSetUpdate(newReplicaSet, oldReplicaSet)...)
|
||||||
|
|
||||||
// Update is not allowed to set Spec.Selector for all groups/versions except extensions/v1beta1.
|
// Update is not allowed to set Spec.Selector for all groups/versions except extensions/v1beta1.
|
||||||
@ -151,7 +151,7 @@ func (rsStrategy) AllowUnconditionalUpdate() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ReplicaSetToSelectableFields returns a field set that represents the object.
|
// ReplicaSetToSelectableFields returns a field set that represents the object.
|
||||||
func ReplicaSetToSelectableFields(rs *extensions.ReplicaSet) fields.Set {
|
func ReplicaSetToSelectableFields(rs *apps.ReplicaSet) fields.Set {
|
||||||
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(&rs.ObjectMeta, true)
|
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(&rs.ObjectMeta, true)
|
||||||
rsSpecificFieldsSet := fields.Set{
|
rsSpecificFieldsSet := fields.Set{
|
||||||
"status.replicas": strconv.Itoa(int(rs.Status.Replicas)),
|
"status.replicas": strconv.Itoa(int(rs.Status.Replicas)),
|
||||||
@ -161,7 +161,7 @@ func ReplicaSetToSelectableFields(rs *extensions.ReplicaSet) fields.Set {
|
|||||||
|
|
||||||
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
||||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
|
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
|
||||||
rs, ok := obj.(*extensions.ReplicaSet)
|
rs, ok := obj.(*apps.ReplicaSet)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, false, fmt.Errorf("given object is not a ReplicaSet.")
|
return nil, nil, false, fmt.Errorf("given object is not a ReplicaSet.")
|
||||||
}
|
}
|
||||||
@ -186,12 +186,12 @@ type rsStatusStrategy struct {
|
|||||||
var StatusStrategy = rsStatusStrategy{Strategy}
|
var StatusStrategy = rsStatusStrategy{Strategy}
|
||||||
|
|
||||||
func (rsStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
func (rsStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||||
newRS := obj.(*extensions.ReplicaSet)
|
newRS := obj.(*apps.ReplicaSet)
|
||||||
oldRS := old.(*extensions.ReplicaSet)
|
oldRS := old.(*apps.ReplicaSet)
|
||||||
// update is not allowed to set spec
|
// update is not allowed to set spec
|
||||||
newRS.Spec = oldRS.Spec
|
newRS.Spec = oldRS.Spec
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rsStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
func (rsStatusStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||||
return validation.ValidateReplicaSetStatusUpdate(obj.(*extensions.ReplicaSet), old.(*extensions.ReplicaSet))
|
return validation.ValidateReplicaSetStatusUpdate(obj.(*apps.ReplicaSet), old.(*apps.ReplicaSet))
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
"k8s.io/apiserver/pkg/registry/rest"
|
||||||
|
"k8s.io/kubernetes/pkg/apis/apps"
|
||||||
api "k8s.io/kubernetes/pkg/apis/core"
|
api "k8s.io/kubernetes/pkg/apis/core"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -57,13 +57,13 @@ func TestReplicaSetStrategy(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
rs := &extensions.ReplicaSet{
|
rs := &apps.ReplicaSet{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
|
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
|
||||||
Spec: extensions.ReplicaSetSpec{
|
Spec: apps.ReplicaSetSpec{
|
||||||
Selector: &metav1.LabelSelector{MatchLabels: validSelector},
|
Selector: &metav1.LabelSelector{MatchLabels: validSelector},
|
||||||
Template: validPodTemplate.Template,
|
Template: validPodTemplate.Template,
|
||||||
},
|
},
|
||||||
Status: extensions.ReplicaSetStatus{
|
Status: apps.ReplicaSetStatus{
|
||||||
Replicas: 1,
|
Replicas: 1,
|
||||||
ObservedGeneration: int64(10),
|
ObservedGeneration: int64(10),
|
||||||
},
|
},
|
||||||
@ -81,7 +81,7 @@ func TestReplicaSetStrategy(t *testing.T) {
|
|||||||
t.Errorf("Unexpected error validating %v", errs)
|
t.Errorf("Unexpected error validating %v", errs)
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidRc := &extensions.ReplicaSet{
|
invalidRc := &apps.ReplicaSet{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "bar", ResourceVersion: "4"},
|
ObjectMeta: metav1.ObjectMeta{Name: "bar", ResourceVersion: "4"},
|
||||||
}
|
}
|
||||||
Strategy.PrepareForUpdate(ctx, invalidRc, rs)
|
Strategy.PrepareForUpdate(ctx, invalidRc, rs)
|
||||||
@ -115,26 +115,26 @@ func TestReplicaSetStatusStrategy(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
oldRS := &extensions.ReplicaSet{
|
oldRS := &apps.ReplicaSet{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault, ResourceVersion: "10"},
|
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault, ResourceVersion: "10"},
|
||||||
Spec: extensions.ReplicaSetSpec{
|
Spec: apps.ReplicaSetSpec{
|
||||||
Replicas: 3,
|
Replicas: 3,
|
||||||
Selector: &metav1.LabelSelector{MatchLabels: validSelector},
|
Selector: &metav1.LabelSelector{MatchLabels: validSelector},
|
||||||
Template: validPodTemplate.Template,
|
Template: validPodTemplate.Template,
|
||||||
},
|
},
|
||||||
Status: extensions.ReplicaSetStatus{
|
Status: apps.ReplicaSetStatus{
|
||||||
Replicas: 1,
|
Replicas: 1,
|
||||||
ObservedGeneration: int64(10),
|
ObservedGeneration: int64(10),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
newRS := &extensions.ReplicaSet{
|
newRS := &apps.ReplicaSet{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault, ResourceVersion: "9"},
|
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault, ResourceVersion: "9"},
|
||||||
Spec: extensions.ReplicaSetSpec{
|
Spec: apps.ReplicaSetSpec{
|
||||||
Replicas: 1,
|
Replicas: 1,
|
||||||
Selector: &metav1.LabelSelector{MatchLabels: validSelector},
|
Selector: &metav1.LabelSelector{MatchLabels: validSelector},
|
||||||
Template: validPodTemplate.Template,
|
Template: validPodTemplate.Template,
|
||||||
},
|
},
|
||||||
Status: extensions.ReplicaSetStatus{
|
Status: apps.ReplicaSetStatus{
|
||||||
Replicas: 3,
|
Replicas: 3,
|
||||||
ObservedGeneration: int64(11),
|
ObservedGeneration: int64(11),
|
||||||
},
|
},
|
||||||
@ -203,14 +203,14 @@ func TestSelectorImmutability(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newReplicaSetWithSelectorLabels(selectorLabels map[string]string) *extensions.ReplicaSet {
|
func newReplicaSetWithSelectorLabels(selectorLabels map[string]string) *apps.ReplicaSet {
|
||||||
return &extensions.ReplicaSet{
|
return &apps.ReplicaSet{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: replicasetName,
|
Name: replicasetName,
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
ResourceVersion: "1",
|
ResourceVersion: "1",
|
||||||
},
|
},
|
||||||
Spec: extensions.ReplicaSetSpec{
|
Spec: apps.ReplicaSetSpec{
|
||||||
Selector: &metav1.LabelSelector{
|
Selector: &metav1.LabelSelector{
|
||||||
MatchLabels: selectorLabels,
|
MatchLabels: selectorLabels,
|
||||||
MatchExpressions: []metav1.LabelSelectorRequirement{},
|
MatchExpressions: []metav1.LabelSelectorRequirement{},
|
||||||
|
@ -33,7 +33,6 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||||
autoscalingv1 "k8s.io/kubernetes/pkg/apis/autoscaling/v1"
|
autoscalingv1 "k8s.io/kubernetes/pkg/apis/autoscaling/v1"
|
||||||
autoscalingvalidation "k8s.io/kubernetes/pkg/apis/autoscaling/validation"
|
autoscalingvalidation "k8s.io/kubernetes/pkg/apis/autoscaling/validation"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
|
||||||
"k8s.io/kubernetes/pkg/printers"
|
"k8s.io/kubernetes/pkg/printers"
|
||||||
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
||||||
printerstorage "k8s.io/kubernetes/pkg/printers/storage"
|
printerstorage "k8s.io/kubernetes/pkg/printers/storage"
|
||||||
@ -184,7 +183,7 @@ func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.Update
|
|||||||
}
|
}
|
||||||
|
|
||||||
if errs := autoscalingvalidation.ValidateScale(scale); len(errs) > 0 {
|
if errs := autoscalingvalidation.ValidateScale(scale); len(errs) > 0 {
|
||||||
return nil, false, errors.NewInvalid(extensions.Kind("Scale"), scale.Name, errs)
|
return nil, false, errors.NewInvalid(autoscaling.Kind("Scale"), scale.Name, errs)
|
||||||
}
|
}
|
||||||
|
|
||||||
ss.Spec.Replicas = scale.Spec.Replicas
|
ss.Spec.Replicas = scale.Spec.Replicas
|
||||||
|
Loading…
Reference in New Issue
Block a user