Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nfs-subdir-external-provisioner
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Rancher商店
nfs-subdir-external-provisioner
Commits
e53fbc3d
Commit
e53fbc3d
authored
Feb 10, 2022
by
Humble Chirammal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle error in a some conditions and also correct error message
This commit also does: `Replace` string method changed to `ReplaceALL` Signed-off-by:
Humble Chirammal
<
hchiramm@redhat.com
>
parent
2417ea02
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
provisioner.go
cmd/nfs-subdir-external-provisioner/provisioner.go
+10
-6
No files found.
cmd/nfs-subdir-external-provisioner/provisioner.go
View file @
e53fbc3d
...
@@ -62,13 +62,14 @@ func (meta *pvcMetadata) stringParser(str string) string {
...
@@ -62,13 +62,14 @@ func (meta *pvcMetadata) stringParser(str string) string {
for
_
,
r
:=
range
result
{
for
_
,
r
:=
range
result
{
switch
r
[
2
]
{
switch
r
[
2
]
{
case
"labels"
:
case
"labels"
:
str
=
strings
.
Replace
(
str
,
r
[
0
],
meta
.
labels
[
r
[
3
]],
-
1
)
str
=
strings
.
Replace
All
(
str
,
r
[
0
],
meta
.
labels
[
r
[
3
]]
)
case
"annotations"
:
case
"annotations"
:
str
=
strings
.
Replace
(
str
,
r
[
0
],
meta
.
annotations
[
r
[
3
]],
-
1
)
str
=
strings
.
Replace
All
(
str
,
r
[
0
],
meta
.
annotations
[
r
[
3
]]
)
default
:
default
:
str
=
strings
.
Replace
(
str
,
r
[
0
],
meta
.
data
[
r
[
1
]],
-
1
)
str
=
strings
.
Replace
All
(
str
,
r
[
0
],
meta
.
data
[
r
[
1
]]
)
}
}
}
}
return
str
return
str
}
}
...
@@ -114,7 +115,10 @@ func (p *nfsProvisioner) Provision(ctx context.Context, options controller.Provi
...
@@ -114,7 +115,10 @@ func (p *nfsProvisioner) Provision(ctx context.Context, options controller.Provi
if
err
:=
os
.
MkdirAll
(
fullPath
,
0777
);
err
!=
nil
{
if
err
:=
os
.
MkdirAll
(
fullPath
,
0777
);
err
!=
nil
{
return
nil
,
controller
.
ProvisioningFinished
,
errors
.
New
(
"unable to create directory to provision new pv: "
+
err
.
Error
())
return
nil
,
controller
.
ProvisioningFinished
,
errors
.
New
(
"unable to create directory to provision new pv: "
+
err
.
Error
())
}
}
os
.
Chmod
(
fullPath
,
0777
)
err
:=
os
.
Chmod
(
fullPath
,
0777
)
if
err
!=
nil
{
return
nil
,
""
,
err
}
pv
:=
&
v1
.
PersistentVolume
{
pv
:=
&
v1
.
PersistentVolume
{
ObjectMeta
:
metav1
.
ObjectMeta
{
ObjectMeta
:
metav1
.
ObjectMeta
{
...
@@ -189,11 +193,11 @@ func (p *nfsProvisioner) Delete(ctx context.Context, volume *v1.PersistentVolume
...
@@ -189,11 +193,11 @@ func (p *nfsProvisioner) Delete(ctx context.Context, volume *v1.PersistentVolume
// getClassForVolume returns StorageClass
// getClassForVolume returns StorageClass
func
(
p
*
nfsProvisioner
)
getClassForVolume
(
ctx
context
.
Context
,
pv
*
v1
.
PersistentVolume
)
(
*
storage
.
StorageClass
,
error
)
{
func
(
p
*
nfsProvisioner
)
getClassForVolume
(
ctx
context
.
Context
,
pv
*
v1
.
PersistentVolume
)
(
*
storage
.
StorageClass
,
error
)
{
if
p
.
client
==
nil
{
if
p
.
client
==
nil
{
return
nil
,
fmt
.
Errorf
(
"
C
annot get kube client"
)
return
nil
,
fmt
.
Errorf
(
"
c
annot get kube client"
)
}
}
className
:=
helper
.
GetPersistentVolumeClass
(
pv
)
className
:=
helper
.
GetPersistentVolumeClass
(
pv
)
if
className
==
""
{
if
className
==
""
{
return
nil
,
fmt
.
Errorf
(
"
V
olume has no storage class"
)
return
nil
,
fmt
.
Errorf
(
"
v
olume has no storage class"
)
}
}
class
,
err
:=
p
.
client
.
StorageV1
()
.
StorageClasses
()
.
Get
(
ctx
,
className
,
metav1
.
GetOptions
{})
class
,
err
:=
p
.
client
.
StorageV1
()
.
StorageClasses
()
.
Get
(
ctx
,
className
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
if
err
!=
nil
{
...
...
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