remove wrapUpdatedObjectInfo from rbac storage
This commit is contained in:
		@@ -57,7 +57,7 @@ func (s *Storage) Update(ctx api.Context, name string, obj rest.UpdatedObjectInf
 | 
				
			|||||||
		return s.StandardStorage.Update(ctx, name, obj)
 | 
							return s.StandardStorage.Update(ctx, name, obj)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	nonEscalatingInfo := wrapUpdatedObjectInfo(obj, func(ctx api.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) {
 | 
						nonEscalatingInfo := rest.WrapUpdatedObjectInfo(obj, func(ctx api.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) {
 | 
				
			||||||
		clusterRole := obj.(*rbac.ClusterRole)
 | 
							clusterRole := obj.(*rbac.ClusterRole)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		rules := clusterRole.Rules
 | 
							rules := clusterRole.Rules
 | 
				
			||||||
@@ -69,26 +69,3 @@ func (s *Storage) Update(ctx api.Context, name string, obj rest.UpdatedObjectInf
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	return s.StandardStorage.Update(ctx, name, nonEscalatingInfo)
 | 
						return s.StandardStorage.Update(ctx, name, nonEscalatingInfo)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
// TODO(ericchiang): This logic is copied from #26240. Replace with once that PR is merged into master.
 | 
					 | 
				
			||||||
type wrappedUpdatedObjectInfo struct {
 | 
					 | 
				
			||||||
	objInfo rest.UpdatedObjectInfo
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	transformFunc rest.TransformFunc
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func wrapUpdatedObjectInfo(objInfo rest.UpdatedObjectInfo, transformFunc rest.TransformFunc) rest.UpdatedObjectInfo {
 | 
					 | 
				
			||||||
	return &wrappedUpdatedObjectInfo{objInfo, transformFunc}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (i *wrappedUpdatedObjectInfo) Preconditions() *api.Preconditions {
 | 
					 | 
				
			||||||
	return i.objInfo.Preconditions()
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (i *wrappedUpdatedObjectInfo) UpdatedObject(ctx api.Context, oldObj runtime.Object) (runtime.Object, error) {
 | 
					 | 
				
			||||||
	obj, err := i.objInfo.UpdatedObject(ctx, oldObj)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return obj, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return i.transformFunc(ctx, obj, oldObj)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,7 +60,7 @@ func (s *Storage) Update(ctx api.Context, name string, obj rest.UpdatedObjectInf
 | 
				
			|||||||
		return s.StandardStorage.Update(ctx, name, obj)
 | 
							return s.StandardStorage.Update(ctx, name, obj)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	nonEscalatingInfo := wrapUpdatedObjectInfo(obj, func(ctx api.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) {
 | 
						nonEscalatingInfo := rest.WrapUpdatedObjectInfo(obj, func(ctx api.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) {
 | 
				
			||||||
		clusterRoleBinding := obj.(*rbac.ClusterRoleBinding)
 | 
							clusterRoleBinding := obj.(*rbac.ClusterRoleBinding)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		rules, err := s.ruleResolver.GetRoleReferenceRules(clusterRoleBinding.RoleRef, clusterRoleBinding.Namespace)
 | 
							rules, err := s.ruleResolver.GetRoleReferenceRules(clusterRoleBinding.RoleRef, clusterRoleBinding.Namespace)
 | 
				
			||||||
@@ -75,26 +75,3 @@ func (s *Storage) Update(ctx api.Context, name string, obj rest.UpdatedObjectInf
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	return s.StandardStorage.Update(ctx, name, nonEscalatingInfo)
 | 
						return s.StandardStorage.Update(ctx, name, nonEscalatingInfo)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
// TODO(ericchiang): This logic is copied from #26240. Replace with once that PR is merged into master.
 | 
					 | 
				
			||||||
type wrappedUpdatedObjectInfo struct {
 | 
					 | 
				
			||||||
	objInfo rest.UpdatedObjectInfo
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	transformFunc rest.TransformFunc
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func wrapUpdatedObjectInfo(objInfo rest.UpdatedObjectInfo, transformFunc rest.TransformFunc) rest.UpdatedObjectInfo {
 | 
					 | 
				
			||||||
	return &wrappedUpdatedObjectInfo{objInfo, transformFunc}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (i *wrappedUpdatedObjectInfo) Preconditions() *api.Preconditions {
 | 
					 | 
				
			||||||
	return i.objInfo.Preconditions()
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (i *wrappedUpdatedObjectInfo) UpdatedObject(ctx api.Context, oldObj runtime.Object) (runtime.Object, error) {
 | 
					 | 
				
			||||||
	obj, err := i.objInfo.UpdatedObject(ctx, oldObj)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return obj, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return i.transformFunc(ctx, obj, oldObj)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -57,7 +57,7 @@ func (s *Storage) Update(ctx api.Context, name string, obj rest.UpdatedObjectInf
 | 
				
			|||||||
		return s.StandardStorage.Update(ctx, name, obj)
 | 
							return s.StandardStorage.Update(ctx, name, obj)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	nonEscalatingInfo := wrapUpdatedObjectInfo(obj, func(ctx api.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) {
 | 
						nonEscalatingInfo := rest.WrapUpdatedObjectInfo(obj, func(ctx api.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) {
 | 
				
			||||||
		role := obj.(*rbac.Role)
 | 
							role := obj.(*rbac.Role)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		rules := role.Rules
 | 
							rules := role.Rules
 | 
				
			||||||
@@ -69,26 +69,3 @@ func (s *Storage) Update(ctx api.Context, name string, obj rest.UpdatedObjectInf
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	return s.StandardStorage.Update(ctx, name, nonEscalatingInfo)
 | 
						return s.StandardStorage.Update(ctx, name, nonEscalatingInfo)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
// TODO(ericchiang): This logic is copied from #26240. Replace with once that PR is merged into master.
 | 
					 | 
				
			||||||
type wrappedUpdatedObjectInfo struct {
 | 
					 | 
				
			||||||
	objInfo rest.UpdatedObjectInfo
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	transformFunc rest.TransformFunc
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func wrapUpdatedObjectInfo(objInfo rest.UpdatedObjectInfo, transformFunc rest.TransformFunc) rest.UpdatedObjectInfo {
 | 
					 | 
				
			||||||
	return &wrappedUpdatedObjectInfo{objInfo, transformFunc}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (i *wrappedUpdatedObjectInfo) Preconditions() *api.Preconditions {
 | 
					 | 
				
			||||||
	return i.objInfo.Preconditions()
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (i *wrappedUpdatedObjectInfo) UpdatedObject(ctx api.Context, oldObj runtime.Object) (runtime.Object, error) {
 | 
					 | 
				
			||||||
	obj, err := i.objInfo.UpdatedObject(ctx, oldObj)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return obj, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return i.transformFunc(ctx, obj, oldObj)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -60,7 +60,7 @@ func (s *Storage) Update(ctx api.Context, name string, obj rest.UpdatedObjectInf
 | 
				
			|||||||
		return s.StandardStorage.Update(ctx, name, obj)
 | 
							return s.StandardStorage.Update(ctx, name, obj)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	nonEscalatingInfo := wrapUpdatedObjectInfo(obj, func(ctx api.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) {
 | 
						nonEscalatingInfo := rest.WrapUpdatedObjectInfo(obj, func(ctx api.Context, obj runtime.Object, oldObj runtime.Object) (runtime.Object, error) {
 | 
				
			||||||
		roleBinding := obj.(*rbac.RoleBinding)
 | 
							roleBinding := obj.(*rbac.RoleBinding)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		rules, err := s.ruleResolver.GetRoleReferenceRules(roleBinding.RoleRef, roleBinding.Namespace)
 | 
							rules, err := s.ruleResolver.GetRoleReferenceRules(roleBinding.RoleRef, roleBinding.Namespace)
 | 
				
			||||||
@@ -75,26 +75,3 @@ func (s *Storage) Update(ctx api.Context, name string, obj rest.UpdatedObjectInf
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	return s.StandardStorage.Update(ctx, name, nonEscalatingInfo)
 | 
						return s.StandardStorage.Update(ctx, name, nonEscalatingInfo)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
// TODO(ericchiang): This logic is copied from #26240. Replace with once that PR is merged into master.
 | 
					 | 
				
			||||||
type wrappedUpdatedObjectInfo struct {
 | 
					 | 
				
			||||||
	objInfo rest.UpdatedObjectInfo
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	transformFunc rest.TransformFunc
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func wrapUpdatedObjectInfo(objInfo rest.UpdatedObjectInfo, transformFunc rest.TransformFunc) rest.UpdatedObjectInfo {
 | 
					 | 
				
			||||||
	return &wrappedUpdatedObjectInfo{objInfo, transformFunc}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (i *wrappedUpdatedObjectInfo) Preconditions() *api.Preconditions {
 | 
					 | 
				
			||||||
	return i.objInfo.Preconditions()
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func (i *wrappedUpdatedObjectInfo) UpdatedObject(ctx api.Context, oldObj runtime.Object) (runtime.Object, error) {
 | 
					 | 
				
			||||||
	obj, err := i.objInfo.UpdatedObject(ctx, oldObj)
 | 
					 | 
				
			||||||
	if err != nil {
 | 
					 | 
				
			||||||
		return obj, err
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return i.transformFunc(ctx, obj, oldObj)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user