in lib/Utils/YamlValidationUtil.js [278:331]
function validateAppComponentAndServerMetricsConfig(appComponents) {
var _a, _b, _c, _d, _e;
let appComponentsParsed = appComponents;
for (let i = 0; i < appComponentsParsed.length; i++) {
if (!isDictionary(appComponentsParsed[i])) {
return { valid: false, error: `The value "${appComponentsParsed[i].toString()}" for AppComponents in the index "${i}" is invalid. Provide a valid dictionary.` };
}
let resourceId = appComponentsParsed[i].resourceId;
if (isInvalidString(resourceId)) {
return { valid: false, error: `The value "${appComponentsParsed[i].resourceId}" for resourceId in appComponents is invalid. Provide a valid resourceId.` };
}
resourceId = resourceId.toLowerCase();
let subscriptionId = (0, CommonUtils_1.getSubscriptionIdFromResourceId)(resourceId);
let resourceType = (0, CommonUtils_1.getResourceTypeFromResourceId)(resourceId);
let name = (0, CommonUtils_1.getResourceNameFromResourceId)(resourceId);
let resourceGroup = (0, CommonUtils_1.getResourceGroupFromResourceId)(resourceId);
if ((0, util_1.isNullOrUndefined)(resourceGroup) || (0, util_1.isNullOrUndefined)(subscriptionId)
|| (0, util_1.isNullOrUndefined)(resourceType) || (0, util_1.isNullOrUndefined)(name)
|| !isValidGUID(subscriptionId)) {
return { valid: false, error: `The value "${resourceId}" for resourceId in appComponents is invalid. Provide a valid resourceId.` };
}
if (isInvalidString(appComponentsParsed[i].kind, true)) {
return { valid: false, error: `The value "${(_a = appComponentsParsed[i].kind) === null || _a === void 0 ? void 0 : _a.toString()}" for kind in appComponents is invalid. Provide a valid string.` };
}
if (isInvalidString(appComponentsParsed[i].resourceName, true)) {
return { valid: false, error: `The value "${(_b = appComponentsParsed[i].resourceName) === null || _b === void 0 ? void 0 : _b.toString()}" for resourceName in appComponents is invalid. Provide a valid string.` };
}
let resourceName = appComponentsParsed[i].resourceName || name;
if (!(0, util_1.isNullOrUndefined)(appComponentsParsed[i].metrics)) {
let metrics = appComponentsParsed[i].metrics;
if (!Array.isArray(metrics)) {
return { valid: false, error: `The value "${metrics === null || metrics === void 0 ? void 0 : metrics.toString()}" for metrics in the appComponent with resourceName "${resourceName}" is invalid. Provide a valid list of metrics.` };
}
for (let metric of metrics) {
if (!isDictionary(metric)) {
return { valid: false, error: `The value "${metric === null || metric === void 0 ? void 0 : metric.toString()}" for metrics in the appComponent with resourceName "${resourceName}" is invalid. Provide a valid dictionary.` };
}
if (metric && isInvalidString(metric.name)) {
return { valid: false, error: `The value "${(_c = metric.name) === null || _c === void 0 ? void 0 : _c.toString()}" for name in the appComponent with resourceName "${resourceName}" is invalid. Provide a valid string.` };
}
if (isInvalidString(metric.aggregation)) {
return { valid: false, error: `The value "${(_d = metric.aggregation) === null || _d === void 0 ? void 0 : _d.toString()}" for aggregation in the appComponent with resourceName "${resourceName}" is invalid. Provide a valid string.` };
}
if (isInvalidString(metric.namespace, true)) {
return { valid: false, error: `The value "${(_e = metric.namespace) === null || _e === void 0 ? void 0 : _e.toString()}" for namespace in the appComponent with resourceName "${resourceName}" is invalid. Provide a valid string.` };
}
}
}
else {
console.log(`Metrics not provided for the appComponent "${resourceName}", default metrics will be enabled for the same.`);
}
}
return { valid: true, error: "" };
}