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
42b40ddc
Commit
42b40ddc
authored
Aug 15, 2017
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
admission plugins: simplify deepcopy calls
parent
ce559394
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
23 deletions
+7
-23
admission_test.go
plugin/pkg/admission/podpreset/admission_test.go
+4
-12
controller.go
plugin/pkg/admission/resourcequota/controller.go
+1
-5
admission_test.go
...n/pkg/admission/storageclass/setdefault/admission_test.go
+2
-6
No files found.
plugin/pkg/admission/podpreset/admission_test.go
View file @
42b40ddc
...
@@ -729,12 +729,8 @@ func TestExclusionNoAdmit(t *testing.T) {
...
@@ -729,12 +729,8 @@ func TestExclusionNoAdmit(t *testing.T) {
},
},
},
},
}
}
originalPod
,
err
:=
api
.
Scheme
.
Copy
(
pod
)
originalPod
:=
pod
.
DeepCopy
()
if
err
!=
nil
{
err
:=
admitPod
(
pod
,
pip
)
t
.
Fatal
(
err
)
}
err
=
admitPod
(
pod
,
pip
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
@@ -797,12 +793,8 @@ func TestAdmitEmptyPodNamespace(t *testing.T) {
...
@@ -797,12 +793,8 @@ func TestAdmitEmptyPodNamespace(t *testing.T) {
},
},
},
},
}
}
originalPod
,
err
:=
api
.
Scheme
.
Copy
(
pod
)
originalPod
:=
pod
.
DeepCopy
()
if
err
!=
nil
{
err
:=
admitPod
(
pod
,
pip
)
t
.
Fatal
(
err
)
}
err
=
admitPod
(
pod
,
pip
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
...
plugin/pkg/admission/resourcequota/controller.go
View file @
42b40ddc
...
@@ -320,11 +320,7 @@ func (e *quotaEvaluator) checkQuotas(quotas []api.ResourceQuota, admissionAttrib
...
@@ -320,11 +320,7 @@ func (e *quotaEvaluator) checkQuotas(quotas []api.ResourceQuota, admissionAttrib
func
copyQuotas
(
in
[]
api
.
ResourceQuota
)
([]
api
.
ResourceQuota
,
error
)
{
func
copyQuotas
(
in
[]
api
.
ResourceQuota
)
([]
api
.
ResourceQuota
,
error
)
{
out
:=
make
([]
api
.
ResourceQuota
,
0
,
len
(
in
))
out
:=
make
([]
api
.
ResourceQuota
,
0
,
len
(
in
))
for
_
,
quota
:=
range
in
{
for
_
,
quota
:=
range
in
{
copied
,
err
:=
api
.
Scheme
.
Copy
(
&
quota
)
out
=
append
(
out
,
*
quota
.
DeepCopy
())
if
err
!=
nil
{
return
nil
,
err
}
out
=
append
(
out
,
*
copied
.
(
*
api
.
ResourceQuota
))
}
}
return
out
,
nil
return
out
,
nil
...
...
plugin/pkg/admission/storageclass/setdefault/admission_test.go
View file @
42b40ddc
...
@@ -191,11 +191,7 @@ func TestAdmission(t *testing.T) {
...
@@ -191,11 +191,7 @@ func TestAdmission(t *testing.T) {
glog
.
V
(
4
)
.
Infof
(
"starting test %q"
,
test
.
name
)
glog
.
V
(
4
)
.
Infof
(
"starting test %q"
,
test
.
name
)
// clone the claim, it's going to be modified
// clone the claim, it's going to be modified
clone
,
err
:=
api
.
Scheme
.
DeepCopy
(
test
.
claim
)
claim
:=
test
.
claim
.
DeepCopy
()
if
err
!=
nil
{
t
.
Fatalf
(
"Cannot clone claim: %v"
,
err
)
}
claim
:=
clone
.
(
*
api
.
PersistentVolumeClaim
)
ctrl
:=
newPlugin
()
ctrl
:=
newPlugin
()
informerFactory
:=
informers
.
NewSharedInformerFactory
(
nil
,
controller
.
NoResyncPeriodFunc
())
informerFactory
:=
informers
.
NewSharedInformerFactory
(
nil
,
controller
.
NoResyncPeriodFunc
())
...
@@ -214,7 +210,7 @@ func TestAdmission(t *testing.T) {
...
@@ -214,7 +210,7 @@ func TestAdmission(t *testing.T) {
admission
.
Create
,
admission
.
Create
,
nil
,
// userInfo
nil
,
// userInfo
)
)
err
=
ctrl
.
Admit
(
attrs
)
err
:
=
ctrl
.
Admit
(
attrs
)
glog
.
Infof
(
"Got %v"
,
err
)
glog
.
Infof
(
"Got %v"
,
err
)
if
err
!=
nil
&&
!
test
.
expectError
{
if
err
!=
nil
&&
!
test
.
expectError
{
t
.
Errorf
(
"Test %q: unexpected error received: %v"
,
test
.
name
,
err
)
t
.
Errorf
(
"Test %q: unexpected error received: %v"
,
test
.
name
,
err
)
...
...
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