MCPcopy
hub / github.com/scality/cloudserver / azureLocationConstraintAssert

Function azureLocationConstraintAssert

lib/Config.js:262–292  ·  view source on GitHub ↗
(location, locationObj)

Source from the content-addressed store, hash-verified

260}
261
262function azureLocationConstraintAssert(location, locationObj) {
263 const locationParams = {
264 ...azureGetLocationCredentials(location, locationObj.details),
265 azureStorageEndpoint:
266 process.env[`${location}_AZURE_STORAGE_ENDPOINT`] ||
267 locationObj.details.azureStorageEndpoint,
268 azureContainerName: locationObj.details.azureContainerName,
269 };
270
271 Object.keys(locationParams).forEach(param => {
272 const value = locationParams[param];
273 assert.notEqual(value, undefined,
274 `bad location constraint: "${location}" ${param} ` +
275 'must be set in locationConfig or environment variable');
276 assert.strictEqual(typeof value, 'string',
277 `bad location constraint: "${location}" ${param} ` +
278 `"${value}" must be a string`);
279 });
280
281 if (locationParams.authMethod === 'shared-key') {
282 assert(azureAccountNameRegex.test(locationParams.storageAccountName),
283 `bad location constraint: "${location}" azureStorageAccountName ` +
284 `"${locationParams.storageAccountName}" is an invalid value`);
285 assert(base64Regex.test(locationParams.storageAccessKey),
286 `bad location constraint: "${location}" ` +
287 'azureStorageAccessKey is not a valid base64 string');
288 }
289 assert(isValidBucketName(locationParams.azureContainerName, []),
290 `bad location constraint: "${location}" ` +
291 'azureContainerName is an invalid container name');
292}
293
294function hdClientLocationConstraintAssert(configHd) {
295 const hdclientFields = [];

Callers 1

locationConstraintAssertFunction · 0.85

Calls 1

Tested by

no test coverage detected