Plumb context to strategy methods

This commit is contained in:
Jordan Liggitt
2016-08-08 16:15:33 -04:00
parent 16621cd32d
commit 4db004972a
58 changed files with 166 additions and 165 deletions

View File

@@ -59,13 +59,13 @@ func (nodeStrategy) AllowCreateOnUpdate() bool {
}
// PrepareForCreate clears fields that are not allowed to be set by end users on creation.
func (nodeStrategy) PrepareForCreate(obj runtime.Object) {
func (nodeStrategy) PrepareForCreate(ctx api.Context, obj runtime.Object) {
_ = obj.(*api.Node)
// Nodes allow *all* fields, including status, to be set on create.
}
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
func (nodeStrategy) PrepareForUpdate(obj, old runtime.Object) {
func (nodeStrategy) PrepareForUpdate(ctx api.Context, obj, old runtime.Object) {
newNode := obj.(*api.Node)
oldNode := old.(*api.Node)
newNode.Status = oldNode.Status
@@ -91,13 +91,13 @@ func (nodeStrategy) AllowUnconditionalUpdate() bool {
return true
}
func (ns nodeStrategy) Export(obj runtime.Object, exact bool) error {
func (ns nodeStrategy) Export(ctx api.Context, obj runtime.Object, exact bool) error {
n, ok := obj.(*api.Node)
if !ok {
// unexpected programmer error
return fmt.Errorf("unexpected object: %v", obj)
}
ns.PrepareForCreate(obj)
ns.PrepareForCreate(ctx, obj)
if exact {
return nil
}
@@ -113,12 +113,12 @@ type nodeStatusStrategy struct {
var StatusStrategy = nodeStatusStrategy{Strategy}
func (nodeStatusStrategy) PrepareForCreate(obj runtime.Object) {
func (nodeStatusStrategy) PrepareForCreate(ctx api.Context, obj runtime.Object) {
_ = obj.(*api.Node)
// Nodes allow *all* fields, including status, to be set on create.
}
func (nodeStatusStrategy) PrepareForUpdate(obj, old runtime.Object) {
func (nodeStatusStrategy) PrepareForUpdate(ctx api.Context, obj, old runtime.Object) {
newNode := obj.(*api.Node)
oldNode := old.(*api.Node)
newNode.Spec = oldNode.Spec