@@ -57,28 +57,35 @@ const (
5757 barNamespace = "bucketAccessRequestNamespace"
5858)
5959
60- func bucketAccessRequestNameNamespace (volCtx map [string ]string ) (name , ns string , err error ) {
60+ func parseValue (key string , ctx map [string ]string ) (string , error ) {
61+ value , ok := ctx [key ]
62+ if ! ok {
63+ return "" , fmt .Errorf ("required volume context key unset: %v" , key )
64+ }
65+ klog .Infof ("got value: %v" , value )
66+ return value , nil
67+ }
68+
69+ func parseVolumeContext (volCtx map [string ]string ) (name , ns string , err error ) {
6170 klog .Info ("parsing bucketAccessRequest namespace/name from volume context" )
62- e := func (m string ) error { return fmt .Errorf ("required volume context key unset: %v" , m ) }
6371
64- var ok bool
65- name , ok = volCtx [barName ]
66- if ! ok {
67- return "" , "" , e (barName )
72+ name , err = parseValue (barName , volCtx )
73+ if err != nil {
74+ return "" , "" , err
6875 }
69- klog . Infof ( "got name: %v" , name )
70- ns , ok = volCtx [ barNamespace ]
71- if ! ok {
72- return "" , "" , e ( barNamespace )
76+
77+ ns , err = parseValue ( barNamespace , volCtx )
78+ if err != nil {
79+ return "" , "" , err
7380 }
74- klog . Infof ( "got namespace: %v" , ns )
81+
7582 return
7683}
7784
7885func (n NodeServer ) NodePublishVolume (ctx context.Context , request * csi.NodePublishVolumeRequest ) (* csi.NodePublishVolumeResponse , error ) {
7986 klog .Infof ("NodePublishVolume: volId: %v, targetPath: %v\n " , request .GetVolumeId (), request .GetTargetPath ())
8087
81- name , ns , err := bucketAccessRequestNameNamespace (request .VolumeContext )
88+ name , ns , err := parseVolumeContext (request .VolumeContext )
8289 if err != nil {
8390 return nil , err
8491 }
0 commit comments