Skip to content

Commit 807f12b

Browse files
committed
complete validation function and remove old checks
1 parent 0d829ae commit 807f12b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

scala/src/main/scala/Osconfig.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,6 @@ class CloudObjectStorage(sc: SparkContext, credentials: HashMap[String, String],
156156
// check for valid credentials
157157
_validate_credentials(credentials, cosType, authMethod)
158158

159-
val requiredValues = Array("endPoint", "accessKey", "secretKey")
160-
for ( key <- requiredValues ) {
161-
if (!credentials.contains(key)) {
162-
throw new IllegalArgumentException("Invalid input: missing required input [" + key + "]")
163-
}
164-
}
165-
166159
// set config
167160
val hadoopConf = sc.hadoopConfiguration
168161
val prefix = "fs.cos." + _getConfigurationName()
@@ -179,11 +172,18 @@ class CloudObjectStorage(sc: SparkContext, credentials: HashMap[String, String],
179172
}
180173
}
181174

182-
private def _validate_credentials(credentials, cosType, authMethod) : Array {
183-
val requiredKeys = _get_required_key_array()
175+
private def _validate_credentials(credentials, cosType, authMethod) {
176+
val requiredKeys = _get_required_key_array(cosType, authMethod)
177+
178+
// check the existence of all required values in credentials
179+
for ( key <- requiredKeys ) {
180+
if (!credentials.contains(key)) {
181+
throw new IllegalArgumentException("Invalid input: missing required input [" + key + "]")
182+
}
183+
}
184184
}
185185

186-
private def _get_required_key_array(credentials, cosType, authMethod) {
186+
private def _get_required_key_array(cosType, authMethod) : Array {
187187
val required_key_softlayer_cos = Array("endPoint", "accessKey", "secretKey")
188188
val required_key_list_iam_api_key = Array("endPoint", "apiKey", "serviceId")
189189
val required_key_list_iam_token = Array("endPoint", "iamToken", "serviceId")

0 commit comments

Comments
 (0)