mirror of https://github.com/k3s-io/k3s
Merge pull request #38460 from xilabao/remove-duplicate-wrapUpdatedObjectInfo
Automatic merge from submit-queue remove wrapUpdatedObjectInfo from rbac storage update by TODOpull/6/head
commit
1d7538f87e
|
@ -57,7 +57,7 @@ func (s *Storage) Update(ctx api.Context, name string, obj rest.UpdatedObjectInf
|
|||
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)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue