Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
34ed25cf
Unverified
Commit
34ed25cf
authored
Oct 05, 2017
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GC: Add check for nil interface
parent
fef3b031
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
helpers.go
pkg/registry/rbac/helpers.go
+6
-0
helpers_test.go
pkg/registry/rbac/helpers_test.go
+13
-0
No files found.
pkg/registry/rbac/helpers.go
View file @
34ed25cf
...
@@ -17,6 +17,8 @@ limitations under the License.
...
@@ -17,6 +17,8 @@ limitations under the License.
package
rbac
package
rbac
import
(
import
(
"reflect"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
...
@@ -25,6 +27,10 @@ import (
...
@@ -25,6 +27,10 @@ import (
// IsOnlyMutatingGCFields checks finalizers and ownerrefs which GC manipulates
// IsOnlyMutatingGCFields checks finalizers and ownerrefs which GC manipulates
// and indicates that only those fields are changing
// and indicates that only those fields are changing
func
IsOnlyMutatingGCFields
(
obj
,
old
runtime
.
Object
,
equalities
conversion
.
Equalities
)
bool
{
func
IsOnlyMutatingGCFields
(
obj
,
old
runtime
.
Object
,
equalities
conversion
.
Equalities
)
bool
{
if
old
==
nil
||
reflect
.
ValueOf
(
old
)
.
IsNil
()
{
return
false
}
// make a copy of the newObj so that we can stomp for comparison
// make a copy of the newObj so that we can stomp for comparison
copied
:=
obj
.
DeepCopyObject
()
copied
:=
obj
.
DeepCopyObject
()
copiedMeta
,
err
:=
meta
.
Accessor
(
copied
)
copiedMeta
,
err
:=
meta
.
Accessor
(
copied
)
...
...
pkg/registry/rbac/helpers_test.go
View file @
34ed25cf
...
@@ -128,6 +128,19 @@ func TestIsOnlyMutatingGCFields(t *testing.T) {
...
@@ -128,6 +128,19 @@ func TestIsOnlyMutatingGCFields(t *testing.T) {
},
},
expected
:
false
,
expected
:
false
,
},
},
{
name
:
"and nil"
,
obj
:
func
()
runtime
.
Object
{
obj
:=
newPod
()
obj
.
OwnerReferences
=
append
(
obj
.
OwnerReferences
,
metav1
.
OwnerReference
{
Name
:
"foo"
})
obj
.
Spec
.
RestartPolicy
=
kapi
.
RestartPolicyAlways
return
obj
},
old
:
func
()
runtime
.
Object
{
return
(
*
kapi
.
Pod
)(
nil
)
},
expected
:
false
,
},
}
}
for
_
,
tc
:=
range
tests
{
for
_
,
tc
:=
range
tests
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment