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
4a3bdbec
Commit
4a3bdbec
authored
Mar 11, 2018
by
mlmhl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set readOnly for CSI mounter
parent
f7d9fb47
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
csi_plugin.go
pkg/volume/csi/csi_plugin.go
+14
-0
No files found.
pkg/volume/csi/csi_plugin.go
View file @
4a3bdbec
...
...
@@ -98,6 +98,10 @@ func (p *csiPlugin) NewMounter(
if
err
!=
nil
{
return
nil
,
err
}
readOnly
,
err
:=
getReadOnlyFromSpec
(
spec
)
if
err
!=
nil
{
return
nil
,
err
}
// before it is used in any paths such as socket etc
addr
:=
fmt
.
Sprintf
(
csiAddrTemplate
,
pvSource
.
Driver
)
...
...
@@ -120,6 +124,7 @@ func (p *csiPlugin) NewMounter(
volumeID
:
pvSource
.
VolumeHandle
,
specVolumeID
:
spec
.
Name
(),
csiClient
:
client
,
readOnly
:
readOnly
,
}
return
mounter
,
nil
}
...
...
@@ -217,6 +222,15 @@ func getCSISourceFromSpec(spec *volume.Spec) (*api.CSIPersistentVolumeSource, er
return
nil
,
fmt
.
Errorf
(
"CSIPersistentVolumeSource not defined in spec"
)
}
func
getReadOnlyFromSpec
(
spec
*
volume
.
Spec
)
(
bool
,
error
)
{
if
spec
.
PersistentVolume
!=
nil
&&
spec
.
PersistentVolume
.
Spec
.
CSI
!=
nil
{
return
spec
.
ReadOnly
,
nil
}
return
false
,
fmt
.
Errorf
(
"CSIPersistentVolumeSource not defined in spec"
)
}
// log prepends log string with `kubernetes.io/csi`
func
log
(
msg
string
,
parts
...
interface
{})
string
{
return
fmt
.
Sprintf
(
fmt
.
Sprintf
(
"%s: %s"
,
csiPluginName
,
msg
),
parts
...
)
...
...
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