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
c2d836fc
Commit
c2d836fc
authored
Jun 12, 2019
by
j-griffith
Committed by
Jordan Liggitt
Jun 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix nil pointer
add back lost test Fix nil pointer
parent
d0bfb70f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
6 deletions
+27
-6
util.go
pkg/api/persistentvolumeclaim/util.go
+11
-6
util_test.go
pkg/api/persistentvolumeclaim/util_test.go
+16
-0
No files found.
pkg/api/persistentvolumeclaim/util.go
View file @
c2d836fc
...
...
@@ -60,15 +60,20 @@ func dataSourceInUse(oldPVCSpec *core.PersistentVolumeClaimSpec) bool {
func
dataSourceIsEnabled
(
pvcSpec
*
core
.
PersistentVolumeClaimSpec
)
bool
{
if
pvcSpec
.
DataSource
!=
nil
{
if
pvcSpec
.
DataSource
.
Kind
==
pvc
&&
*
pvcSpec
.
DataSource
.
APIGroup
==
""
&&
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumePVCDataSource
)
{
apiGroup
:=
""
if
pvcSpec
.
DataSource
.
APIGroup
!=
nil
{
apiGroup
=
*
pvcSpec
.
DataSource
.
APIGroup
}
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumePVCDataSource
)
&&
pvcSpec
.
DataSource
.
Kind
==
pvc
&&
apiGroup
==
""
{
return
true
}
if
pvcSpec
.
DataSource
.
Kind
==
volumeSnapshot
&&
*
pvcSpec
.
DataSource
.
APIGroup
==
"snapshot.storage.k8s.io"
&&
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeSnapshotDataSource
)
{
if
utilfeature
.
DefaultFeatureGate
.
Enabled
(
features
.
VolumeSnapshotDataSource
)
&&
pvcSpec
.
DataSource
.
Kind
==
volumeSnapshot
&&
apiGroup
==
"snapshot.storage.k8s.io"
{
return
true
}
}
...
...
pkg/api/persistentvolumeclaim/util_test.go
View file @
c2d836fc
...
...
@@ -221,6 +221,12 @@ func TestPVCDataSourceSpecFilter(t *testing.T) {
Name
:
"test_clone"
,
},
}
validSpecNilAPIGroup
:=
core
.
PersistentVolumeClaimSpec
{
DataSource
:
&
core
.
TypedLocalObjectReference
{
Kind
:
"PersistentVolumeClaim"
,
Name
:
"test_clone"
,
},
}
invalidAPIGroup
:=
"invalid.pvc.api.group"
invalidSpec
:=
core
.
PersistentVolumeClaimSpec
{
...
...
@@ -266,6 +272,16 @@ func TestPVCDataSourceSpecFilter(t *testing.T) {
gateEnabled
:
false
,
want
:
nil
,
},
"enabled with valid spec but nil APIGroup"
:
{
spec
:
validSpecNilAPIGroup
,
gateEnabled
:
true
,
want
:
validSpecNilAPIGroup
.
DataSource
,
},
"disabled with valid spec but nil APIGroup"
:
{
spec
:
validSpecNilAPIGroup
,
gateEnabled
:
false
,
want
:
nil
,
},
}
for
testName
,
test
:=
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