Skip to content

Commit 4fe088a

Browse files
committed
update req params with secretMap values
1 parent 8225175 commit 4fe088a

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

pkg/driver/controllerserver.go

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,13 @@ func (cs *controllerServer) CreateVolume(_ context.Context, req *csi.CreateVolum
133133
secretMap = secretMapCustom
134134
}
135135

136+
klog.Info("SecretMap Parameters:\n\t", maskSecretkeys(secretMap))
137+
136138
endPoint = secretMap["cosEndpoint"]
137139
if endPoint == "" {
138140
endPoint = params["cosEndpoint"]
141+
} else {
142+
params["cosEndpoint"] = secretMap["cosEndpoint"]
139143
}
140144
if endPoint == "" {
141145
return nil, status.Error(codes.InvalidArgument, "cosEndpoint unknown")
@@ -144,28 +148,26 @@ func (cs *controllerServer) CreateVolume(_ context.Context, req *csi.CreateVolum
144148
locationConstraint = secretMap["locationConstraint"]
145149
if locationConstraint == "" {
146150
locationConstraint = params["locationConstraint"]
151+
} else {
152+
params["locationConstraint"] = secretMap["locationConstraint"]
147153
}
148154
if locationConstraint == "" {
149155
return nil, status.Error(codes.InvalidArgument, "locationConstraint unknown")
150156
}
151157

152158
kpRootKeyCrn = secretMap["kpRootKeyCRN"]
153-
if kpRootKeyCrn == "" {
154-
kpRootKeyCrn = secretMapCustom["kpRootKeyCRN"]
155-
}
156159
if kpRootKeyCrn != "" {
157160
klog.Infof("key protect root key crn provided for bucket creation")
158161
}
159162

160163
mounter := secretMap["mounter"]
161164
if mounter == "" {
162165
mounter = params["mounter"]
166+
} else {
167+
params["mounter"] = secretMap["mounter"]
163168
}
164169

165170
bucketName = secretMap["bucketName"]
166-
if bucketName == "" {
167-
bucketName = secretMapCustom["bucketName"]
168-
}
169171

170172
// Check for bucketVersioning parameter
171173
if val, ok := secretMap[constants.BucketVersioning]; ok && val != "" {
@@ -189,7 +191,7 @@ func (cs *controllerServer) CreateVolume(_ context.Context, req *csi.CreateVolum
189191
if err != nil {
190192
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("Error in getting credentials %v", err))
191193
}
192-
194+
klog.Infof("endPoint and locationConstraint getting paased to ObjectStorageSession: %s, %s", endPoint, locationConstraint)
193195
sess := cs.cosSession.NewObjectStorageSession(endPoint, locationConstraint, creds, cs.Logger)
194196

195197
params["userProvidedBucket"] = "true"
@@ -553,6 +555,18 @@ func parseCustomSecret(secret *v1.Secret) map[string]string {
553555
return secretMapCustom
554556
}
555557

558+
func maskSecretkeys(secretMap map[string]string) map[string]string {
559+
maskedSecretMap := make(map[string]string)
560+
for k, v := range secretMap {
561+
if k == "accessKey" || k == "secretKey" || k == "apiKey" || k == "kpRootKeyCRN" {
562+
maskedSecretMap[k] = "xxxxxxx"
563+
continue
564+
}
565+
maskedSecretMap[k] = v
566+
}
567+
return maskedSecretMap
568+
}
569+
556570
func getTempBucketName(mounterType, volumeID string) string {
557571
klog.Infof("mounterType: %v", mounterType)
558572
currentTime := time.Now()

0 commit comments

Comments
 (0)