mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-12 20:57:20 +00:00
rename ResetBeforeCreate to PrepareForCreate
This commit is contained in:
@@ -42,8 +42,8 @@ func (rcStrategy) NamespaceScoped() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// ResetBeforeCreate clears the status of a replication controller before creation.
|
||||
func (rcStrategy) ResetBeforeCreate(obj runtime.Object) {
|
||||
// PrepareForCreate clears the status of a replication controller before creation.
|
||||
func (rcStrategy) PrepareForCreate(obj runtime.Object) {
|
||||
controller := obj.(*api.ReplicationController)
|
||||
controller.Status = api.ReplicationControllerStatus{}
|
||||
}
|
||||
|
@@ -43,8 +43,8 @@ func (endpointsStrategy) NamespaceScoped() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// ResetBeforeCreate clears fields that are not allowed to be set by end users on creation.
|
||||
func (endpointsStrategy) ResetBeforeCreate(obj runtime.Object) {
|
||||
// PrepareForCreate clears fields that are not allowed to be set by end users on creation.
|
||||
func (endpointsStrategy) PrepareForCreate(obj runtime.Object) {
|
||||
_ = obj.(*api.Endpoints)
|
||||
}
|
||||
|
||||
|
@@ -43,7 +43,7 @@ type testRESTStrategy struct {
|
||||
func (t *testRESTStrategy) NamespaceScoped() bool { return t.namespaceScoped }
|
||||
func (t *testRESTStrategy) AllowCreateOnUpdate() bool { return t.allowCreateOnUpdate }
|
||||
|
||||
func (t *testRESTStrategy) ResetBeforeCreate(obj runtime.Object) {}
|
||||
func (t *testRESTStrategy) PrepareForCreate(obj runtime.Object) {}
|
||||
func (t *testRESTStrategy) Validate(obj runtime.Object) fielderrors.ValidationErrorList {
|
||||
return nil
|
||||
}
|
||||
|
@@ -53,8 +53,8 @@ func (nodeStrategy) AllowCreateOnUpdate() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// ResetBeforeCreate clears fields that are not allowed to be set by end users on creation.
|
||||
func (nodeStrategy) ResetBeforeCreate(obj runtime.Object) {
|
||||
// PrepareForCreate clears fields that are not allowed to be set by end users on creation.
|
||||
func (nodeStrategy) PrepareForCreate(obj runtime.Object) {
|
||||
_ = obj.(*api.Node)
|
||||
// Nodes allow *all* fields, including status, to be set.
|
||||
}
|
||||
|
@@ -43,8 +43,8 @@ func (namespaceStrategy) NamespaceScoped() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// ResetBeforeCreate clears fields that are not allowed to be set by end users on creation.
|
||||
func (namespaceStrategy) ResetBeforeCreate(obj runtime.Object) {
|
||||
// PrepareForCreate clears fields that are not allowed to be set by end users on creation.
|
||||
func (namespaceStrategy) PrepareForCreate(obj runtime.Object) {
|
||||
// on create, status is active
|
||||
namespace := obj.(*api.Namespace)
|
||||
namespace.Status = api.NamespaceStatus{
|
||||
|
@@ -33,7 +33,7 @@ func TestNamespaceStrategy(t *testing.T) {
|
||||
ObjectMeta: api.ObjectMeta{Name: "foo"},
|
||||
Status: api.NamespaceStatus{Phase: api.NamespaceTerminating},
|
||||
}
|
||||
Strategy.ResetBeforeCreate(namespace)
|
||||
Strategy.PrepareForCreate(namespace)
|
||||
if namespace.Status.Phase != api.NamespaceActive {
|
||||
t.Errorf("Namespaces do not allow setting phase on create")
|
||||
}
|
||||
|
@@ -50,8 +50,8 @@ func (podStrategy) NamespaceScoped() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// ResetBeforeCreate clears fields that are not allowed to be set by end users on creation.
|
||||
func (podStrategy) ResetBeforeCreate(obj runtime.Object) {
|
||||
// PrepareForCreate clears fields that are not allowed to be set by end users on creation.
|
||||
func (podStrategy) PrepareForCreate(obj runtime.Object) {
|
||||
pod := obj.(*api.Pod)
|
||||
pod.Status = api.PodStatus{
|
||||
Host: pod.Spec.Host,
|
||||
|
@@ -43,8 +43,8 @@ func (resourcequotaStrategy) NamespaceScoped() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// ResetBeforeCreate clears fields that are not allowed to be set by end users on creation.
|
||||
func (resourcequotaStrategy) ResetBeforeCreate(obj runtime.Object) {
|
||||
// PrepareForCreate clears fields that are not allowed to be set by end users on creation.
|
||||
func (resourcequotaStrategy) PrepareForCreate(obj runtime.Object) {
|
||||
resourcequota := obj.(*api.ResourceQuota)
|
||||
resourcequota.Status = api.ResourceQuotaStatus{}
|
||||
}
|
||||
|
@@ -51,7 +51,7 @@ func TestResourceQuotaStrategy(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
Strategy.ResetBeforeCreate(resourceQuota)
|
||||
Strategy.PrepareForCreate(resourceQuota)
|
||||
if resourceQuota.Status.Used != nil {
|
||||
t.Errorf("ResourceQuota does not allow setting status on create")
|
||||
}
|
||||
|
Reference in New Issue
Block a user