mirror of https://github.com/k3s-io/k3s
fixup extensions->apps references
parent
b502bc093c
commit
d0577ace6b
|
@ -50,6 +50,7 @@
|
|||
"k8s.io/kubernetes/pkg/apis/autoscaling",
|
||||
"k8s.io/kubernetes/pkg/apis/core",
|
||||
"k8s.io/kubernetes/pkg/api/service",
|
||||
"k8s.io/kubernetes/pkg/apis/apps",
|
||||
"k8s.io/kubernetes/pkg/apis/extensions",
|
||||
"k8s.io/kubernetes/pkg/apis/networking",
|
||||
"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.
|
||||
# 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/testapi
|
||||
- k8s.io/api/extensions/v1beta1
|
||||
- k8s.io/api/apps/v1
|
||||
ignoredSubTrees:
|
||||
- "./pkg/apis/core/validation"
|
||||
|
||||
|
|
|
@ -27,9 +27,9 @@ import (
|
|||
unversionedvalidation "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
appsvalidation "k8s.io/kubernetes/pkg/apis/apps/validation"
|
||||
core "k8s.io/kubernetes/pkg/apis/core"
|
||||
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/features"
|
||||
"k8s.io/kubernetes/pkg/security/apparmor"
|
||||
|
@ -68,13 +68,13 @@ func ValidatePodDisruptionBudgetSpec(spec policy.PodDisruptionBudgetSpec, fldPat
|
|||
}
|
||||
|
||||
if spec.MinAvailable != nil {
|
||||
allErrs = append(allErrs, extensionsvalidation.ValidatePositiveIntOrPercent(*spec.MinAvailable, fldPath.Child("minAvailable"))...)
|
||||
allErrs = append(allErrs, extensionsvalidation.IsNotMoreThan100Percent(*spec.MinAvailable, fldPath.Child("minAvailable"))...)
|
||||
allErrs = append(allErrs, appsvalidation.ValidatePositiveIntOrPercent(*spec.MinAvailable, fldPath.Child("minAvailable"))...)
|
||||
allErrs = append(allErrs, appsvalidation.IsNotMoreThan100Percent(*spec.MinAvailable, fldPath.Child("minAvailable"))...)
|
||||
}
|
||||
|
||||
if spec.MaxUnavailable != nil {
|
||||
allErrs = append(allErrs, extensionsvalidation.ValidatePositiveIntOrPercent(*spec.MaxUnavailable, fldPath.Child("maxUnavailable"))...)
|
||||
allErrs = append(allErrs, extensionsvalidation.IsNotMoreThan100Percent(*spec.MaxUnavailable, fldPath.Child("maxUnavailable"))...)
|
||||
allErrs = append(allErrs, appsvalidation.ValidatePositiveIntOrPercent(*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"))...)
|
||||
|
|
|
@ -1872,7 +1872,7 @@ type ReplicaSetDescriber struct {
|
|||
}
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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 {
|
||||
w := NewPrefixWriter(out)
|
||||
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) {
|
||||
dc := d.Extensions().DaemonSets(namespace)
|
||||
dc := d.Apps().DaemonSets(namespace)
|
||||
pc := d.Core().Pods(namespace)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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 {
|
||||
w := NewPrefixWriter(out)
|
||||
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 {
|
||||
return "", err
|
||||
}
|
||||
internalDeployment := &extensions.Deployment{}
|
||||
if err := legacyscheme.Scheme.Convert(d, internalDeployment, extensions.SchemeGroupVersion); err != nil {
|
||||
internalDeployment := &apps.Deployment{}
|
||||
if err := legacyscheme.Scheme.Convert(d, internalDeployment, apps.SchemeGroupVersion); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
@ -3237,7 +3237,7 @@ func (dd *DeploymentDescriber) Describe(namespace, name string, describerSetting
|
|||
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 {
|
||||
w := NewPrefixWriter(out)
|
||||
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/autoscaling"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/apis/networking"
|
||||
"k8s.io/kubernetes/pkg/apis/policy"
|
||||
"k8s.io/kubernetes/pkg/apis/storage"
|
||||
|
@ -2188,7 +2187,7 @@ func TestDescribeEvents(t *testing.T) {
|
|||
|
||||
m := map[string]printers.Describer{
|
||||
"DaemonSetDescriber": &DaemonSetDescriber{
|
||||
fake.NewSimpleClientset(&extensions.DaemonSet{
|
||||
fake.NewSimpleClientset(&apps.DaemonSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "bar",
|
||||
Namespace: "foo",
|
||||
|
@ -2245,7 +2244,7 @@ func TestDescribeEvents(t *testing.T) {
|
|||
}, events),
|
||||
},
|
||||
"ReplicaSetDescriber": &ReplicaSetDescriber{
|
||||
fake.NewSimpleClientset(&extensions.ReplicaSet{
|
||||
fake.NewSimpleClientset(&apps.ReplicaSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "bar",
|
||||
Namespace: "foo",
|
||||
|
|
|
@ -769,7 +769,7 @@ func printReplicationControllerList(list *api.ReplicationControllerList, options
|
|||
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{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
|
@ -786,7 +786,7 @@ func printReplicaSet(obj *extensions.ReplicaSet, options printers.PrintOptions)
|
|||
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))
|
||||
for i := range list.Items {
|
||||
r, err := printReplicaSet(&list.Items[i], options)
|
||||
|
@ -1063,7 +1063,7 @@ func printStatefulSetList(list *apps.StatefulSetList, options printers.PrintOpti
|
|||
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{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
|
@ -1082,7 +1082,7 @@ func printDaemonSet(obj *extensions.DaemonSet, options printers.PrintOptions) ([
|
|||
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))
|
||||
for i := range list.Items {
|
||||
r, err := printDaemonSet(&list.Items[i], options)
|
||||
|
@ -1555,7 +1555,7 @@ func truncate(str string, maxLen int) string {
|
|||
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{
|
||||
Object: runtime.RawExtension{Object: obj},
|
||||
}
|
||||
|
@ -1578,7 +1578,7 @@ func printDeployment(obj *extensions.Deployment, options printers.PrintOptions)
|
|||
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))
|
||||
for i := range list.Items {
|
||||
r, err := printDeployment(&list.Items[i], options)
|
||||
|
|
|
@ -1971,17 +1971,17 @@ func TestTranslateTimestampUntil(t *testing.T) {
|
|||
|
||||
func TestPrintDeployment(t *testing.T) {
|
||||
tests := []struct {
|
||||
deployment extensions.Deployment
|
||||
deployment apps.Deployment
|
||||
expect string
|
||||
wideExpect string
|
||||
}{
|
||||
{
|
||||
extensions.Deployment{
|
||||
apps.Deployment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test1",
|
||||
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
|
||||
},
|
||||
Spec: extensions.DeploymentSpec{
|
||||
Spec: apps.DeploymentSpec{
|
||||
Replicas: 5,
|
||||
Template: api.PodTemplateSpec{
|
||||
Spec: api.PodSpec{
|
||||
|
@ -1999,7 +1999,7 @@ func TestPrintDeployment(t *testing.T) {
|
|||
},
|
||||
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
|
||||
},
|
||||
Status: extensions.DeploymentStatus{
|
||||
Status: apps.DeploymentStatus{
|
||||
Replicas: 10,
|
||||
UpdatedReplicas: 2,
|
||||
AvailableReplicas: 1,
|
||||
|
@ -2040,21 +2040,21 @@ func TestPrintDeployment(t *testing.T) {
|
|||
|
||||
func TestPrintDaemonSet(t *testing.T) {
|
||||
tests := []struct {
|
||||
ds extensions.DaemonSet
|
||||
ds apps.DaemonSet
|
||||
startsWith string
|
||||
}{
|
||||
{
|
||||
extensions.DaemonSet{
|
||||
apps.DaemonSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test1",
|
||||
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
|
||||
},
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Spec: apps.DaemonSetSpec{
|
||||
Template: api.PodTemplateSpec{
|
||||
Spec: api.PodSpec{Containers: make([]api.Container, 2)},
|
||||
},
|
||||
},
|
||||
Status: extensions.DaemonSetStatus{
|
||||
Status: apps.DaemonSetStatus{
|
||||
CurrentNumberScheduled: 2,
|
||||
DesiredNumberScheduled: 3,
|
||||
NumberReady: 1,
|
||||
|
@ -3154,17 +3154,17 @@ func boolP(b bool) *bool {
|
|||
|
||||
func TestPrintReplicaSet(t *testing.T) {
|
||||
tests := []struct {
|
||||
replicaSet extensions.ReplicaSet
|
||||
replicaSet apps.ReplicaSet
|
||||
expect string
|
||||
wideExpect string
|
||||
}{
|
||||
{
|
||||
extensions.ReplicaSet{
|
||||
apps.ReplicaSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test1",
|
||||
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
|
||||
},
|
||||
Spec: extensions.ReplicaSetSpec{
|
||||
Spec: apps.ReplicaSetSpec{
|
||||
Replicas: 5,
|
||||
Template: api.PodTemplateSpec{
|
||||
Spec: api.PodSpec{
|
||||
|
@ -3182,7 +3182,7 @@ func TestPrintReplicaSet(t *testing.T) {
|
|||
},
|
||||
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}},
|
||||
},
|
||||
Status: extensions.ReplicaSetStatus{
|
||||
Status: apps.ReplicaSetStatus{
|
||||
Replicas: 5,
|
||||
ReadyReplicas: 2,
|
||||
},
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
"k8s.io/apiserver/pkg/registry/generic"
|
||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/apis/apps"
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
||||
printerstorage "k8s.io/kubernetes/pkg/printers/storage"
|
||||
|
@ -40,9 +40,9 @@ type REST struct {
|
|||
// NewREST returns a RESTStorage object that will work against DaemonSets.
|
||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
|
||||
store := &genericregistry.Store{
|
||||
NewFunc: func() runtime.Object { return &extensions.DaemonSet{} },
|
||||
NewListFunc: func() runtime.Object { return &extensions.DaemonSetList{} },
|
||||
DefaultQualifiedResource: extensions.Resource("daemonsets"),
|
||||
NewFunc: func() runtime.Object { return &apps.DaemonSet{} },
|
||||
NewListFunc: func() runtime.Object { return &apps.DaemonSetList{} },
|
||||
DefaultQualifiedResource: apps.Resource("daemonsets"),
|
||||
|
||||
CreateStrategy: daemonset.Strategy,
|
||||
UpdateStrategy: daemonset.Strategy,
|
||||
|
@ -87,7 +87,7 @@ type StatusREST struct {
|
|||
}
|
||||
|
||||
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.
|
||||
|
|
|
@ -26,13 +26,13 @@ import (
|
|||
"k8s.io/apiserver/pkg/registry/generic"
|
||||
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
||||
etcdtesting "k8s.io/apiserver/pkg/storage/etcd/testing"
|
||||
"k8s.io/kubernetes/pkg/apis/apps"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||
)
|
||||
|
||||
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{
|
||||
StorageConfig: etcdStorage,
|
||||
Decorator: generic.UndecoratedStorage,
|
||||
|
@ -43,15 +43,15 @@ func newStorage(t *testing.T) (*REST, *StatusREST, *etcdtesting.EtcdTestServer)
|
|||
return daemonSetStorage, statusStorage, server
|
||||
}
|
||||
|
||||
func newValidDaemonSet() *extensions.DaemonSet {
|
||||
return &extensions.DaemonSet{
|
||||
func newValidDaemonSet() *apps.DaemonSet {
|
||||
return &apps.DaemonSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
UpdateStrategy: extensions.DaemonSetUpdateStrategy{
|
||||
Type: extensions.OnDeleteDaemonSetStrategyType,
|
||||
Spec: apps.DaemonSetSpec{
|
||||
UpdateStrategy: apps.DaemonSetUpdateStrategy{
|
||||
Type: apps.OnDeleteDaemonSetStrategyType,
|
||||
},
|
||||
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"a": "b"}},
|
||||
Template: api.PodTemplateSpec{
|
||||
|
@ -88,15 +88,15 @@ func TestCreate(t *testing.T) {
|
|||
// valid
|
||||
ds,
|
||||
// invalid (invalid selector)
|
||||
&extensions.DaemonSet{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
&apps.DaemonSet{
|
||||
Spec: apps.DaemonSetSpec{
|
||||
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{}},
|
||||
Template: validDaemonSet.Spec.Template,
|
||||
},
|
||||
},
|
||||
// invalid update strategy
|
||||
&extensions.DaemonSet{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
&apps.DaemonSet{
|
||||
Spec: apps.DaemonSetSpec{
|
||||
Selector: validDaemonSet.Spec.Selector,
|
||||
Template: validDaemonSet.Spec.Template,
|
||||
},
|
||||
|
@ -114,19 +114,19 @@ func TestUpdate(t *testing.T) {
|
|||
newValidDaemonSet(),
|
||||
// updateFunc
|
||||
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.DNSPolicy = api.DNSDefault
|
||||
return object
|
||||
},
|
||||
// invalid updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*extensions.DaemonSet)
|
||||
object := obj.(*apps.DaemonSet)
|
||||
object.Name = ""
|
||||
return object
|
||||
},
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*extensions.DaemonSet)
|
||||
object := obj.(*apps.DaemonSet)
|
||||
object.Spec.Template.Spec.RestartPolicy = api.RestartPolicyOnFailure
|
||||
return object
|
||||
},
|
||||
|
|
|
@ -31,8 +31,8 @@ import (
|
|||
"k8s.io/apiserver/pkg/storage/names"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/api/pod"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions/validation"
|
||||
"k8s.io/kubernetes/pkg/apis/apps"
|
||||
"k8s.io/kubernetes/pkg/apis/apps/validation"
|
||||
)
|
||||
|
||||
// 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.
|
||||
func (daemonSetStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
||||
daemonSet := obj.(*extensions.DaemonSet)
|
||||
daemonSet.Status = extensions.DaemonSetStatus{}
|
||||
daemonSet := obj.(*apps.DaemonSet)
|
||||
daemonSet.Status = apps.DaemonSetStatus{}
|
||||
|
||||
daemonSet.Generation = 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.
|
||||
func (daemonSetStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||
newDaemonSet := obj.(*extensions.DaemonSet)
|
||||
oldDaemonSet := old.(*extensions.DaemonSet)
|
||||
newDaemonSet := obj.(*apps.DaemonSet)
|
||||
oldDaemonSet := old.(*apps.DaemonSet)
|
||||
|
||||
pod.DropDisabledAlphaFields(&newDaemonSet.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.
|
||||
func (daemonSetStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
||||
daemonSet := obj.(*extensions.DaemonSet)
|
||||
daemonSet := obj.(*apps.DaemonSet)
|
||||
return validation.ValidateDaemonSet(daemonSet)
|
||||
}
|
||||
|
||||
|
@ -130,9 +130,9 @@ func (daemonSetStrategy) AllowCreateOnUpdate() bool {
|
|||
|
||||
// ValidateUpdate is the default update validation for an end user.
|
||||
func (daemonSetStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||
newDaemonSet := obj.(*extensions.DaemonSet)
|
||||
oldDaemonSet := old.(*extensions.DaemonSet)
|
||||
allErrs := validation.ValidateDaemonSet(obj.(*extensions.DaemonSet))
|
||||
newDaemonSet := obj.(*apps.DaemonSet)
|
||||
oldDaemonSet := old.(*apps.DaemonSet)
|
||||
allErrs := validation.ValidateDaemonSet(obj.(*apps.DaemonSet))
|
||||
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).
|
||||
|
@ -165,11 +165,11 @@ type daemonSetStatusStrategy struct {
|
|||
var StatusStrategy = daemonSetStatusStrategy{Strategy}
|
||||
|
||||
func (daemonSetStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||
newDaemonSet := obj.(*extensions.DaemonSet)
|
||||
oldDaemonSet := old.(*extensions.DaemonSet)
|
||||
newDaemonSet := obj.(*apps.DaemonSet)
|
||||
oldDaemonSet := old.(*apps.DaemonSet)
|
||||
newDaemonSet.Spec = oldDaemonSet.Spec
|
||||
}
|
||||
|
||||
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"
|
||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
"k8s.io/kubernetes/pkg/apis/apps"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -160,20 +160,20 @@ func TestSelectorImmutability(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func newDaemonSetWithSelectorLabels(selectorLabels map[string]string, templateGeneration int64) *extensions.DaemonSet {
|
||||
return &extensions.DaemonSet{
|
||||
func newDaemonSetWithSelectorLabels(selectorLabels map[string]string, templateGeneration int64) *apps.DaemonSet {
|
||||
return &apps.DaemonSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: daemonsetName,
|
||||
Namespace: namespace,
|
||||
ResourceVersion: "1",
|
||||
},
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Spec: apps.DaemonSetSpec{
|
||||
Selector: &metav1.LabelSelector{
|
||||
MatchLabels: selectorLabels,
|
||||
MatchExpressions: []metav1.LabelSelectorRequirement{},
|
||||
},
|
||||
UpdateStrategy: extensions.DaemonSetUpdateStrategy{
|
||||
Type: extensions.OnDeleteDaemonSetStrategyType,
|
||||
UpdateStrategy: apps.DaemonSetUpdateStrategy{
|
||||
Type: apps.OnDeleteDaemonSetStrategyType,
|
||||
},
|
||||
TemplateGeneration: templateGeneration,
|
||||
Template: api.PodTemplateSpec{
|
||||
|
|
|
@ -31,14 +31,14 @@ import (
|
|||
"k8s.io/apiserver/pkg/storage"
|
||||
storeerr "k8s.io/apiserver/pkg/storage/errors"
|
||||
"k8s.io/apiserver/pkg/util/dryrun"
|
||||
"k8s.io/kubernetes/pkg/apis/apps"
|
||||
appsv1beta1 "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
|
||||
appsv1beta2 "k8s.io/kubernetes/pkg/apis/apps/v1beta2"
|
||||
appsvalidation "k8s.io/kubernetes/pkg/apis/apps/validation"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
autoscalingv1 "k8s.io/kubernetes/pkg/apis/autoscaling/v1"
|
||||
autoscalingvalidation "k8s.io/kubernetes/pkg/apis/autoscaling/validation"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
extensionsv1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
|
||||
extvalidation "k8s.io/kubernetes/pkg/apis/extensions/validation"
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
||||
printerstorage "k8s.io/kubernetes/pkg/printers/storage"
|
||||
|
@ -72,9 +72,9 @@ type REST struct {
|
|||
// NewREST returns a RESTStorage object that will work against deployments.
|
||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST, *RollbackREST) {
|
||||
store := &genericregistry.Store{
|
||||
NewFunc: func() runtime.Object { return &extensions.Deployment{} },
|
||||
NewListFunc: func() runtime.Object { return &extensions.DeploymentList{} },
|
||||
DefaultQualifiedResource: extensions.Resource("deployments"),
|
||||
NewFunc: func() runtime.Object { return &apps.Deployment{} },
|
||||
NewListFunc: func() runtime.Object { return &apps.DeploymentList{} },
|
||||
DefaultQualifiedResource: apps.Resource("deployments"),
|
||||
|
||||
CreateStrategy: deployment.Strategy,
|
||||
UpdateStrategy: deployment.Strategy,
|
||||
|
@ -119,7 +119,7 @@ type StatusREST struct {
|
|||
}
|
||||
|
||||
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.
|
||||
|
@ -155,19 +155,19 @@ var _ = rest.StorageMetadata(&RollbackREST{})
|
|||
|
||||
// New creates a rollback
|
||||
func (r *RollbackREST) New() runtime.Object {
|
||||
return &extensions.DeploymentRollback{}
|
||||
return &apps.DeploymentRollback{}
|
||||
}
|
||||
|
||||
var _ = rest.Creater(&RollbackREST{})
|
||||
|
||||
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 {
|
||||
return nil, errors.NewBadRequest(fmt.Sprintf("not a DeploymentRollback: %#v", obj))
|
||||
}
|
||||
|
||||
if errs := extvalidation.ValidateDeploymentRollback(rollback); len(errs) != 0 {
|
||||
return nil, errors.NewInvalid(extensions.Kind("DeploymentRollback"), rollback.Name, errs)
|
||||
if errs := appsvalidation.ValidateDeploymentRollback(rollback); len(errs) != 0 {
|
||||
return nil, errors.NewInvalid(apps.Kind("DeploymentRollback"), rollback.Name, errs)
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
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 {
|
||||
err = storeerr.InterpretGetError(err, extensions.Resource("deployments"), deploymentID)
|
||||
err = storeerr.InterpretUpdateError(err, extensions.Resource("deployments"), deploymentID)
|
||||
err = storeerr.InterpretGetError(err, apps.Resource("deployments"), deploymentID)
|
||||
err = storeerr.InterpretUpdateError(err, apps.Resource("deployments"), deploymentID)
|
||||
if _, ok := err.(*errors.StatusError); !ok {
|
||||
err = errors.NewInternalError(err)
|
||||
}
|
||||
|
@ -194,14 +194,14 @@ func (r *RollbackREST) rollbackDeployment(ctx context.Context, deploymentID stri
|
|||
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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var finalDeployment *extensions.Deployment
|
||||
err = r.store.Storage.GuaranteedUpdate(ctx, dKey, &extensions.Deployment{}, false, nil, storage.SimpleUpdate(func(obj runtime.Object) (runtime.Object, error) {
|
||||
d, ok := obj.(*extensions.Deployment)
|
||||
var finalDeployment *apps.Deployment
|
||||
err = r.store.Storage.GuaranteedUpdate(ctx, dKey, &apps.Deployment{}, false, nil, storage.SimpleUpdate(func(obj runtime.Object) (runtime.Object, error) {
|
||||
d, ok := obj.(*apps.Deployment)
|
||||
if !ok {
|
||||
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) {
|
||||
obj, err := r.store.Get(ctx, name, options)
|
||||
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)
|
||||
if err != nil {
|
||||
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) {
|
||||
obj, err := r.store.Get(ctx, name, &metav1.GetOptions{})
|
||||
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)
|
||||
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 {
|
||||
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
|
||||
|
@ -291,7 +291,7 @@ func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.Update
|
|||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
deployment = obj.(*extensions.Deployment)
|
||||
deployment = obj.(*apps.Deployment)
|
||||
newScale, err := scaleFromDeployment(deployment)
|
||||
if err != nil {
|
||||
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.
|
||||
func scaleFromDeployment(deployment *extensions.Deployment) (*autoscaling.Scale, error) {
|
||||
func scaleFromDeployment(deployment *apps.Deployment) (*autoscaling.Scale, error) {
|
||||
selector, err := metav1.LabelSelectorAsSelector(deployment.Spec.Selector)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -35,16 +35,16 @@ import (
|
|||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
storeerr "k8s.io/apiserver/pkg/storage/errors"
|
||||
etcdtesting "k8s.io/apiserver/pkg/storage/etcd/testing"
|
||||
"k8s.io/kubernetes/pkg/apis/apps"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/registry/registrytest"
|
||||
)
|
||||
|
||||
const defaultReplicas = 100
|
||||
|
||||
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"}
|
||||
deploymentStorage := NewStorage(restOptions)
|
||||
return &deploymentStorage, server
|
||||
|
@ -53,17 +53,17 @@ func newStorage(t *testing.T) (*DeploymentStorage, *etcdtesting.EtcdTestServer)
|
|||
var namespace = "foo-namespace"
|
||||
var name = "foo-deployment"
|
||||
|
||||
func validNewDeployment() *extensions.Deployment {
|
||||
return &extensions.Deployment{
|
||||
func validNewDeployment() *apps.Deployment {
|
||||
return &apps.Deployment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
},
|
||||
Spec: extensions.DeploymentSpec{
|
||||
Spec: apps.DeploymentSpec{
|
||||
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"a": "b"}},
|
||||
Strategy: extensions.DeploymentStrategy{
|
||||
Type: extensions.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &extensions.RollingUpdateDeployment{
|
||||
Strategy: apps.DeploymentStrategy{
|
||||
Type: apps.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &apps.RollingUpdateDeployment{
|
||||
MaxSurge: intstr.FromInt(1),
|
||||
MaxUnavailable: intstr.FromInt(1),
|
||||
},
|
||||
|
@ -87,7 +87,7 @@ func validNewDeployment() *extensions.Deployment {
|
|||
},
|
||||
Replicas: 7,
|
||||
},
|
||||
Status: extensions.DeploymentStatus{
|
||||
Status: apps.DeploymentStatus{
|
||||
Replicas: 5,
|
||||
},
|
||||
}
|
||||
|
@ -106,8 +106,8 @@ func TestCreate(t *testing.T) {
|
|||
// valid
|
||||
deployment,
|
||||
// invalid (invalid selector)
|
||||
&extensions.Deployment{
|
||||
Spec: extensions.DeploymentSpec{
|
||||
&apps.Deployment{
|
||||
Spec: apps.DeploymentSpec{
|
||||
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{}},
|
||||
Template: validDeployment.Spec.Template,
|
||||
},
|
||||
|
@ -125,23 +125,23 @@ func TestUpdate(t *testing.T) {
|
|||
validNewDeployment(),
|
||||
// updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*extensions.Deployment)
|
||||
object := obj.(*apps.Deployment)
|
||||
object.Spec.Template.Spec.NodeSelector = map[string]string{"c": "d"}
|
||||
return object
|
||||
},
|
||||
// invalid updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*extensions.Deployment)
|
||||
object := obj.(*apps.Deployment)
|
||||
object.Name = ""
|
||||
return object
|
||||
},
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*extensions.Deployment)
|
||||
object := obj.(*apps.Deployment)
|
||||
object.Spec.Template.Spec.RestartPolicy = api.RestartPolicyOnFailure
|
||||
return object
|
||||
},
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*extensions.Deployment)
|
||||
object := obj.(*apps.Deployment)
|
||||
object.Spec.Selector = &metav1.LabelSelector{MatchLabels: map[string]string{}}
|
||||
return object
|
||||
},
|
||||
|
@ -202,7 +202,7 @@ func TestScaleGet(t *testing.T) {
|
|||
storage, server := newStorage(t)
|
||||
defer server.Terminate(t)
|
||||
defer storage.Deployment.Store.DestroyFunc()
|
||||
var deployment extensions.Deployment
|
||||
var deployment apps.Deployment
|
||||
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), namespace)
|
||||
key := "/deployments/" + namespace + "/" + name
|
||||
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)
|
||||
defer server.Terminate(t)
|
||||
defer storage.Deployment.Store.DestroyFunc()
|
||||
var deployment extensions.Deployment
|
||||
var deployment apps.Deployment
|
||||
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), namespace)
|
||||
key := "/deployments/" + namespace + "/" + name
|
||||
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 {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
update := extensions.Deployment{
|
||||
update := apps.Deployment{
|
||||
ObjectMeta: validDeployment.ObjectMeta,
|
||||
Spec: extensions.DeploymentSpec{
|
||||
Spec: apps.DeploymentSpec{
|
||||
Replicas: defaultReplicas,
|
||||
},
|
||||
Status: extensions.DeploymentStatus{
|
||||
Status: apps.DeploymentStatus{
|
||||
Replicas: defaultReplicas,
|
||||
},
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ func TestStatusUpdate(t *testing.T) {
|
|||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
deployment := obj.(*extensions.Deployment)
|
||||
deployment := obj.(*apps.Deployment)
|
||||
if deployment.Spec.Replicas != 7 {
|
||||
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)
|
||||
|
||||
testCases := map[string]struct {
|
||||
rollback extensions.DeploymentRollback
|
||||
rollback apps.DeploymentRollback
|
||||
errOK func(error) bool
|
||||
}{
|
||||
"normal": {
|
||||
rollback: extensions.DeploymentRollback{
|
||||
rollback: apps.DeploymentRollback{
|
||||
Name: name,
|
||||
UpdatedAnnotations: map[string]string{},
|
||||
RollbackTo: extensions.RollbackConfig{Revision: 1},
|
||||
RollbackTo: apps.RollbackConfig{Revision: 1},
|
||||
},
|
||||
errOK: func(err error) bool { return err == nil },
|
||||
},
|
||||
"noAnnotation": {
|
||||
rollback: extensions.DeploymentRollback{
|
||||
rollback: apps.DeploymentRollback{
|
||||
Name: name,
|
||||
RollbackTo: extensions.RollbackConfig{Revision: 1},
|
||||
RollbackTo: apps.RollbackConfig{Revision: 1},
|
||||
},
|
||||
errOK: func(err error) bool { return err == nil },
|
||||
},
|
||||
"noName": {
|
||||
rollback: extensions.DeploymentRollback{
|
||||
rollback: apps.DeploymentRollback{
|
||||
UpdatedAnnotations: map[string]string{},
|
||||
RollbackTo: extensions.RollbackConfig{Revision: 1},
|
||||
RollbackTo: apps.RollbackConfig{Revision: 1},
|
||||
},
|
||||
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{})
|
||||
if err != nil {
|
||||
t.Errorf("%s: unexpected error: %v", k, err)
|
||||
} else if !reflect.DeepEqual(*d.(*extensions.Deployment).Spec.RollbackTo, test.rollback.RollbackTo) {
|
||||
t.Errorf("%s: expected: %v, got: %v", k, *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.(*apps.Deployment).Spec.RollbackTo, test.rollback.RollbackTo)
|
||||
}
|
||||
}
|
||||
storage.Deployment.Store.DestroyFunc()
|
||||
|
@ -383,15 +383,15 @@ func TestEtcdCreateDeploymentRollbackNoDeployment(t *testing.T) {
|
|||
rollbackStorage := storage.Rollback
|
||||
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), namespace)
|
||||
|
||||
_, err := rollbackStorage.Create(ctx, &extensions.DeploymentRollback{
|
||||
_, err := rollbackStorage.Create(ctx, &apps.DeploymentRollback{
|
||||
Name: name,
|
||||
UpdatedAnnotations: map[string]string{},
|
||||
RollbackTo: extensions.RollbackConfig{Revision: 1},
|
||||
RollbackTo: apps.RollbackConfig{Revision: 1},
|
||||
}, rest.ValidateAllObjectFunc, &metav1.CreateOptions{})
|
||||
if err == nil {
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -399,7 +399,7 @@ func TestEtcdCreateDeploymentRollbackNoDeployment(t *testing.T) {
|
|||
if err == nil {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ import (
|
|||
"k8s.io/apiserver/pkg/storage/names"
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/api/pod"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions/validation"
|
||||
"k8s.io/kubernetes/pkg/apis/apps"
|
||||
"k8s.io/kubernetes/pkg/apis/apps/validation"
|
||||
)
|
||||
|
||||
// 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.
|
||||
func (deploymentStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
||||
deployment := obj.(*extensions.Deployment)
|
||||
deployment.Status = extensions.DeploymentStatus{}
|
||||
deployment := obj.(*apps.Deployment)
|
||||
deployment.Status = apps.DeploymentStatus{}
|
||||
deployment.Generation = 1
|
||||
|
||||
pod.DropDisabledAlphaFields(&deployment.Spec.Template.Spec)
|
||||
|
@ -77,7 +77,7 @@ func (deploymentStrategy) PrepareForCreate(ctx context.Context, obj runtime.Obje
|
|||
|
||||
// Validate validates a new deployment.
|
||||
func (deploymentStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
||||
deployment := obj.(*extensions.Deployment)
|
||||
deployment := obj.(*apps.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.
|
||||
func (deploymentStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||
newDeployment := obj.(*extensions.Deployment)
|
||||
oldDeployment := old.(*extensions.Deployment)
|
||||
newDeployment := obj.(*apps.Deployment)
|
||||
oldDeployment := old.(*apps.Deployment)
|
||||
newDeployment.Status = oldDeployment.Status
|
||||
|
||||
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.
|
||||
func (deploymentStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||
newDeployment := obj.(*extensions.Deployment)
|
||||
oldDeployment := old.(*extensions.Deployment)
|
||||
newDeployment := obj.(*apps.Deployment)
|
||||
oldDeployment := old.(*apps.Deployment)
|
||||
allErrs := validation.ValidateDeploymentUpdate(newDeployment, oldDeployment)
|
||||
|
||||
// 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
|
||||
func (deploymentStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||
newDeployment := obj.(*extensions.Deployment)
|
||||
oldDeployment := old.(*extensions.Deployment)
|
||||
newDeployment := obj.(*apps.Deployment)
|
||||
oldDeployment := old.(*apps.Deployment)
|
||||
newDeployment.Spec = oldDeployment.Spec
|
||||
newDeployment.Labels = oldDeployment.Labels
|
||||
}
|
||||
|
||||
// ValidateUpdate is the default update validation for an end user updating status
|
||||
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"
|
||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
"k8s.io/kubernetes/pkg/apis/apps"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -63,17 +63,17 @@ func TestStatusUpdates(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func newDeployment(labels, annotations map[string]string) *extensions.Deployment {
|
||||
return &extensions.Deployment{
|
||||
func newDeployment(labels, annotations map[string]string) *apps.Deployment {
|
||||
return &apps.Deployment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test",
|
||||
Labels: labels,
|
||||
Annotations: annotations,
|
||||
},
|
||||
Spec: extensions.DeploymentSpec{
|
||||
Spec: apps.DeploymentSpec{
|
||||
Replicas: 1,
|
||||
Strategy: extensions.DeploymentStrategy{
|
||||
Type: extensions.RecreateDeploymentStrategyType,
|
||||
Strategy: apps.DeploymentStrategy{
|
||||
Type: apps.RecreateDeploymentStrategyType,
|
||||
},
|
||||
Template: api.PodTemplateSpec{
|
||||
Spec: api.PodSpec{
|
||||
|
@ -152,21 +152,21 @@ func TestSelectorImmutability(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func newDeploymentWithSelectorLabels(selectorLabels map[string]string) *extensions.Deployment {
|
||||
return &extensions.Deployment{
|
||||
func newDeploymentWithSelectorLabels(selectorLabels map[string]string) *apps.Deployment {
|
||||
return &apps.Deployment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: deploymentName,
|
||||
Namespace: namespace,
|
||||
ResourceVersion: "1",
|
||||
},
|
||||
Spec: extensions.DeploymentSpec{
|
||||
Spec: apps.DeploymentSpec{
|
||||
Selector: &metav1.LabelSelector{
|
||||
MatchLabels: selectorLabels,
|
||||
MatchExpressions: []metav1.LabelSelectorRequirement{},
|
||||
},
|
||||
Strategy: extensions.DeploymentStrategy{
|
||||
Type: extensions.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &extensions.RollingUpdateDeployment{
|
||||
Strategy: apps.DeploymentStrategy{
|
||||
Type: apps.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &apps.RollingUpdateDeployment{
|
||||
MaxSurge: intstr.FromInt(1),
|
||||
MaxUnavailable: intstr.FromInt(1),
|
||||
},
|
||||
|
|
|
@ -29,12 +29,12 @@ import (
|
|||
"k8s.io/apiserver/pkg/registry/generic"
|
||||
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
"k8s.io/kubernetes/pkg/apis/apps"
|
||||
appsv1beta1 "k8s.io/kubernetes/pkg/apis/apps/v1beta1"
|
||||
appsv1beta2 "k8s.io/kubernetes/pkg/apis/apps/v1beta2"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
autoscalingv1 "k8s.io/kubernetes/pkg/apis/autoscaling/v1"
|
||||
autoscalingvalidation "k8s.io/kubernetes/pkg/apis/autoscaling/validation"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
extensionsv1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
||||
|
@ -67,10 +67,10 @@ type REST struct {
|
|||
// NewREST returns a RESTStorage object that will work against ReplicaSet.
|
||||
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, *StatusREST) {
|
||||
store := &genericregistry.Store{
|
||||
NewFunc: func() runtime.Object { return &extensions.ReplicaSet{} },
|
||||
NewListFunc: func() runtime.Object { return &extensions.ReplicaSetList{} },
|
||||
NewFunc: func() runtime.Object { return &apps.ReplicaSet{} },
|
||||
NewListFunc: func() runtime.Object { return &apps.ReplicaSetList{} },
|
||||
PredicateFunc: replicaset.MatchReplicaSet,
|
||||
DefaultQualifiedResource: extensions.Resource("replicasets"),
|
||||
DefaultQualifiedResource: apps.Resource("replicasets"),
|
||||
|
||||
CreateStrategy: replicaset.Strategy,
|
||||
UpdateStrategy: replicaset.Strategy,
|
||||
|
@ -116,7 +116,7 @@ type StatusREST struct {
|
|||
}
|
||||
|
||||
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.
|
||||
|
@ -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) {
|
||||
obj, err := r.store.Get(ctx, name, options)
|
||||
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)
|
||||
if err != nil {
|
||||
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) {
|
||||
obj, err := r.store.Get(ctx, name, &metav1.GetOptions{})
|
||||
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)
|
||||
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 {
|
||||
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
|
||||
|
@ -205,7 +205,7 @@ func (r *ScaleREST) Update(ctx context.Context, name string, objInfo rest.Update
|
|||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
rs = obj.(*extensions.ReplicaSet)
|
||||
rs = obj.(*apps.ReplicaSet)
|
||||
newScale, err := scaleFromReplicaSet(rs)
|
||||
if err != nil {
|
||||
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.
|
||||
func scaleFromReplicaSet(rs *extensions.ReplicaSet) (*autoscaling.Scale, error) {
|
||||
func scaleFromReplicaSet(rs *apps.ReplicaSet) (*autoscaling.Scale, error) {
|
||||
selector, err := metav1.LabelSelectorAsSelector(rs.Spec.Selector)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -31,9 +31,9 @@ import (
|
|||
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
etcdtesting "k8s.io/apiserver/pkg/storage/etcd/testing"
|
||||
"k8s.io/kubernetes/pkg/apis/apps"
|
||||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"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.
|
||||
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)
|
||||
obj, err := storage.Create(ctx, &rs, rest.ValidateAllObjectFunc, &metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
t.Errorf("Failed to create ReplicaSet, %v", err)
|
||||
}
|
||||
newRS := obj.(*extensions.ReplicaSet)
|
||||
newRS := obj.(*apps.ReplicaSet)
|
||||
return *newRS, nil
|
||||
}
|
||||
|
||||
func validNewReplicaSet() *extensions.ReplicaSet {
|
||||
return &extensions.ReplicaSet{
|
||||
func validNewReplicaSet() *apps.ReplicaSet {
|
||||
return &apps.ReplicaSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Spec: extensions.ReplicaSetSpec{
|
||||
Spec: apps.ReplicaSetSpec{
|
||||
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"a": "b"}},
|
||||
Template: api.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
@ -84,7 +84,7 @@ func validNewReplicaSet() *extensions.ReplicaSet {
|
|||
},
|
||||
Replicas: 7,
|
||||
},
|
||||
Status: extensions.ReplicaSetStatus{
|
||||
Status: apps.ReplicaSetStatus{
|
||||
Replicas: 5,
|
||||
},
|
||||
}
|
||||
|
@ -103,8 +103,8 @@ func TestCreate(t *testing.T) {
|
|||
// valid
|
||||
rs,
|
||||
// invalid (invalid selector)
|
||||
&extensions.ReplicaSet{
|
||||
Spec: extensions.ReplicaSetSpec{
|
||||
&apps.ReplicaSet{
|
||||
Spec: apps.ReplicaSetSpec{
|
||||
Replicas: 2,
|
||||
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{}},
|
||||
Template: validReplicaSet.Spec.Template,
|
||||
|
@ -123,18 +123,18 @@ func TestUpdate(t *testing.T) {
|
|||
validNewReplicaSet(),
|
||||
// valid updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*extensions.ReplicaSet)
|
||||
object := obj.(*apps.ReplicaSet)
|
||||
object.Spec.Replicas = object.Spec.Replicas + 1
|
||||
return object
|
||||
},
|
||||
// invalid updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*extensions.ReplicaSet)
|
||||
object := obj.(*apps.ReplicaSet)
|
||||
object.Name = ""
|
||||
return object
|
||||
},
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
object := obj.(*extensions.ReplicaSet)
|
||||
object := obj.(*apps.ReplicaSet)
|
||||
object.Spec.Selector = &metav1.LabelSelector{MatchLabels: map[string]string{}}
|
||||
return object
|
||||
},
|
||||
|
@ -165,7 +165,7 @@ func TestGenerationNumber(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
storedRS, _ := etcdRS.(*extensions.ReplicaSet)
|
||||
storedRS, _ := etcdRS.(*apps.ReplicaSet)
|
||||
|
||||
// Generation initialization
|
||||
if storedRS.Generation != 1 || storedRS.Status.ObservedGeneration != 0 {
|
||||
|
@ -181,7 +181,7 @@ func TestGenerationNumber(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
storedRS, _ = etcdRS.(*extensions.ReplicaSet)
|
||||
storedRS, _ = etcdRS.(*apps.ReplicaSet)
|
||||
if storedRS.Generation != 2 || storedRS.Status.ObservedGeneration != 0 {
|
||||
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 {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
storedRS, _ = etcdRS.(*extensions.ReplicaSet)
|
||||
storedRS, _ = etcdRS.(*apps.ReplicaSet)
|
||||
if storedRS.Generation != 2 || storedRS.Status.ObservedGeneration != 0 {
|
||||
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"
|
||||
|
||||
var rs extensions.ReplicaSet
|
||||
var rs apps.ReplicaSet
|
||||
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), metav1.NamespaceDefault)
|
||||
key := "/replicasets/" + metav1.NamespaceDefault + "/" + name
|
||||
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"
|
||||
|
||||
var rs extensions.ReplicaSet
|
||||
var rs apps.ReplicaSet
|
||||
ctx := genericapirequest.WithNamespace(genericapirequest.NewContext(), metav1.NamespaceDefault)
|
||||
key := "/replicasets/" + metav1.NamespaceDefault + "/" + name
|
||||
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 {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
update := extensions.ReplicaSet{
|
||||
update := apps.ReplicaSet{
|
||||
ObjectMeta: validReplicaSet.ObjectMeta,
|
||||
Spec: extensions.ReplicaSetSpec{
|
||||
Spec: apps.ReplicaSetSpec{
|
||||
Replicas: defaultReplicas,
|
||||
},
|
||||
Status: extensions.ReplicaSetStatus{
|
||||
Status: apps.ReplicaSetStatus{
|
||||
Replicas: defaultReplicas,
|
||||
},
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ func TestStatusUpdate(t *testing.T) {
|
|||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
|
||||
rs := obj.(*extensions.ReplicaSet)
|
||||
rs := obj.(*apps.ReplicaSet)
|
||||
if rs.Spec.Replicas != 7 {
|
||||
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/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/api/pod"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions/validation"
|
||||
"k8s.io/kubernetes/pkg/apis/apps"
|
||||
"k8s.io/kubernetes/pkg/apis/apps/validation"
|
||||
)
|
||||
|
||||
// rsStrategy implements verification logic for ReplicaSets.
|
||||
|
@ -74,8 +74,8 @@ func (rsStrategy) NamespaceScoped() bool {
|
|||
|
||||
// PrepareForCreate clears the status of a ReplicaSet before creation.
|
||||
func (rsStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
||||
rs := obj.(*extensions.ReplicaSet)
|
||||
rs.Status = extensions.ReplicaSetStatus{}
|
||||
rs := obj.(*apps.ReplicaSet)
|
||||
rs.Status = apps.ReplicaSetStatus{}
|
||||
|
||||
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.
|
||||
func (rsStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||
newRS := obj.(*extensions.ReplicaSet)
|
||||
oldRS := old.(*extensions.ReplicaSet)
|
||||
newRS := obj.(*apps.ReplicaSet)
|
||||
oldRS := old.(*apps.ReplicaSet)
|
||||
// update is not allowed to set status
|
||||
newRS.Status = oldRS.Status
|
||||
|
||||
|
@ -107,7 +107,7 @@ func (rsStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object)
|
|||
|
||||
// Validate validates a new ReplicaSet.
|
||||
func (rsStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
||||
rs := obj.(*extensions.ReplicaSet)
|
||||
rs := obj.(*apps.ReplicaSet)
|
||||
return validation.ValidateReplicaSet(rs)
|
||||
}
|
||||
|
||||
|
@ -123,9 +123,9 @@ func (rsStrategy) AllowCreateOnUpdate() bool {
|
|||
|
||||
// ValidateUpdate is the default update validation for an end user.
|
||||
func (rsStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||
newReplicaSet := obj.(*extensions.ReplicaSet)
|
||||
oldReplicaSet := old.(*extensions.ReplicaSet)
|
||||
allErrs := validation.ValidateReplicaSet(obj.(*extensions.ReplicaSet))
|
||||
newReplicaSet := obj.(*apps.ReplicaSet)
|
||||
oldReplicaSet := old.(*apps.ReplicaSet)
|
||||
allErrs := validation.ValidateReplicaSet(obj.(*apps.ReplicaSet))
|
||||
allErrs = append(allErrs, validation.ValidateReplicaSetUpdate(newReplicaSet, oldReplicaSet)...)
|
||||
|
||||
// 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.
|
||||
func ReplicaSetToSelectableFields(rs *extensions.ReplicaSet) fields.Set {
|
||||
func ReplicaSetToSelectableFields(rs *apps.ReplicaSet) fields.Set {
|
||||
objectMetaFieldsSet := generic.ObjectMetaFieldsSet(&rs.ObjectMeta, true)
|
||||
rsSpecificFieldsSet := fields.Set{
|
||||
"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.
|
||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
|
||||
rs, ok := obj.(*extensions.ReplicaSet)
|
||||
rs, ok := obj.(*apps.ReplicaSet)
|
||||
if !ok {
|
||||
return nil, nil, false, fmt.Errorf("given object is not a ReplicaSet.")
|
||||
}
|
||||
|
@ -186,12 +186,12 @@ type rsStatusStrategy struct {
|
|||
var StatusStrategy = rsStatusStrategy{Strategy}
|
||||
|
||||
func (rsStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||
newRS := obj.(*extensions.ReplicaSet)
|
||||
oldRS := old.(*extensions.ReplicaSet)
|
||||
newRS := obj.(*apps.ReplicaSet)
|
||||
oldRS := old.(*apps.ReplicaSet)
|
||||
// update is not allowed to set spec
|
||||
newRS.Spec = oldRS.Spec
|
||||
}
|
||||
|
||||
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"
|
||||
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
|
||||
"k8s.io/apiserver/pkg/registry/rest"
|
||||
"k8s.io/kubernetes/pkg/apis/apps"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -57,13 +57,13 @@ func TestReplicaSetStrategy(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
rs := &extensions.ReplicaSet{
|
||||
rs := &apps.ReplicaSet{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault},
|
||||
Spec: extensions.ReplicaSetSpec{
|
||||
Spec: apps.ReplicaSetSpec{
|
||||
Selector: &metav1.LabelSelector{MatchLabels: validSelector},
|
||||
Template: validPodTemplate.Template,
|
||||
},
|
||||
Status: extensions.ReplicaSetStatus{
|
||||
Status: apps.ReplicaSetStatus{
|
||||
Replicas: 1,
|
||||
ObservedGeneration: int64(10),
|
||||
},
|
||||
|
@ -81,7 +81,7 @@ func TestReplicaSetStrategy(t *testing.T) {
|
|||
t.Errorf("Unexpected error validating %v", errs)
|
||||
}
|
||||
|
||||
invalidRc := &extensions.ReplicaSet{
|
||||
invalidRc := &apps.ReplicaSet{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "bar", ResourceVersion: "4"},
|
||||
}
|
||||
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"},
|
||||
Spec: extensions.ReplicaSetSpec{
|
||||
Spec: apps.ReplicaSetSpec{
|
||||
Replicas: 3,
|
||||
Selector: &metav1.LabelSelector{MatchLabels: validSelector},
|
||||
Template: validPodTemplate.Template,
|
||||
},
|
||||
Status: extensions.ReplicaSetStatus{
|
||||
Status: apps.ReplicaSetStatus{
|
||||
Replicas: 1,
|
||||
ObservedGeneration: int64(10),
|
||||
},
|
||||
}
|
||||
newRS := &extensions.ReplicaSet{
|
||||
newRS := &apps.ReplicaSet{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "abc", Namespace: metav1.NamespaceDefault, ResourceVersion: "9"},
|
||||
Spec: extensions.ReplicaSetSpec{
|
||||
Spec: apps.ReplicaSetSpec{
|
||||
Replicas: 1,
|
||||
Selector: &metav1.LabelSelector{MatchLabels: validSelector},
|
||||
Template: validPodTemplate.Template,
|
||||
},
|
||||
Status: extensions.ReplicaSetStatus{
|
||||
Status: apps.ReplicaSetStatus{
|
||||
Replicas: 3,
|
||||
ObservedGeneration: int64(11),
|
||||
},
|
||||
|
@ -203,14 +203,14 @@ func TestSelectorImmutability(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func newReplicaSetWithSelectorLabels(selectorLabels map[string]string) *extensions.ReplicaSet {
|
||||
return &extensions.ReplicaSet{
|
||||
func newReplicaSetWithSelectorLabels(selectorLabels map[string]string) *apps.ReplicaSet {
|
||||
return &apps.ReplicaSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: replicasetName,
|
||||
Namespace: namespace,
|
||||
ResourceVersion: "1",
|
||||
},
|
||||
Spec: extensions.ReplicaSetSpec{
|
||||
Spec: apps.ReplicaSetSpec{
|
||||
Selector: &metav1.LabelSelector{
|
||||
MatchLabels: selectorLabels,
|
||||
MatchExpressions: []metav1.LabelSelectorRequirement{},
|
||||
|
|
|
@ -33,7 +33,6 @@ import (
|
|||
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
||||
autoscalingv1 "k8s.io/kubernetes/pkg/apis/autoscaling/v1"
|
||||
autoscalingvalidation "k8s.io/kubernetes/pkg/apis/autoscaling/validation"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
|
||||
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 {
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue