@@ -78,10 +78,34 @@ func (d DirectoryProvisioner) Provision(ctx context.Context, req *csi.CreateVolu
78
78
}
79
79
}
80
80
81
- klog .V (5 ).Infof ("Provisioning directory with permissions %s" , perms )
81
+ var uid int
82
+ if value , ok := volumeParams [Uid ]; ok {
83
+ id , err := strconv .ParseInt (value , 10 , 32 )
84
+ if err != nil {
85
+ return nil , status .Errorf (codes .InvalidArgument , "Failed to parse invalid %v: %v" , Uid , err )
86
+ }
87
+ if id < 0 {
88
+ return nil , status .Errorf (codes .InvalidArgument , "%v must be greater or equal than 0" , Uid )
89
+ }
90
+ uid = int (id )
91
+ }
92
+
93
+ var gid int
94
+ if value , ok := volumeParams [Gid ]; ok {
95
+ id , err := strconv .ParseInt (value , 10 , 32 )
96
+ if err != nil {
97
+ return nil , status .Errorf (codes .InvalidArgument , "Failed to parse invalid %v: %v" , Gid , err )
98
+ }
99
+ if id < 0 {
100
+ return nil , status .Errorf (codes .InvalidArgument , "%v must be greater or equal than 0" , Gid )
101
+ }
102
+ gid = int (id )
103
+ }
104
+
105
+ klog .V (5 ).Infof ("Provisioning directory with permissions %s, uid %d, gid %d" , perms , uid , gid )
82
106
83
107
provisionedDirectory := path .Join (target , provisionedPath )
84
- err = d .osClient .MkDirAllWithPermsNoOwnership (provisionedDirectory , perms )
108
+ err = d .osClient .MkDirAllWithPerms (provisionedDirectory , perms , uid , gid )
85
109
if err != nil {
86
110
return nil , status .Errorf (codes .Internal , "Could not provision directory: %v" , err )
87
111
}
0 commit comments