"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var mslib_1 = require("mslib");
/**
 * 应用选项配置校验器
 * @date 2021-05-28 17:13:50
 * @author 吴锋霖
 */
var AppOptionsConfigChcker = /** @class */ (function () {
    function AppOptionsConfigChcker() {
    }
    /**
     * 校验
     * @param config
     */
    AppOptionsConfigChcker.check = function (config) {
        if (!config) {
            return mslib_1.OpResult.error('应用选项配置未设置');
        }
        var op = this.checkElasticConfig(config);
        if (!op.isSuccess()) {
            return op;
        }
        op = this.checkK8sConfig(config);
        if (!op.isSuccess()) {
            return op;
        }
        op = this.checkLogConfig(config);
        if (!op.isSuccess()) {
            return op;
        }
        op = this.checkSpecConfig(config);
        if (!op.isSuccess()) {
            return op;
        }
    };
    AppOptionsConfigChcker.checkElasticConfig = function (config) {
        if (!config.elasticConfig) {
            return mslib_1.OpResult.error('应用选项配置校验失败，未配置弹性伸缩 [elasticConfig]');
        }
        var elasticConfig = config.elasticConfig;
        if (!elasticConfig.minInstance || elasticConfig.minInstance <= 0) {
            return mslib_1.OpResult.error('应用选项配置校验失败，未配置弹性伸缩最小实例数');
        }
        if (elasticConfig.elasticType !== '0' && elasticConfig.elasticType !== '1') {
            return mslib_1.OpResult.error("\u5E94\u7528\u9009\u9879\u914D\u7F6E\u6821\u9A8C\u5931\u8D25\uFF0C\u5F39\u6027\u4F38\u7F29\u7C7B\u578B[" + elasticConfig.elasticType + "]\u65E0\u6CD5\u89E3\u6790");
        }
        return mslib_1.OpResult.success('OK');
    };
    AppOptionsConfigChcker.checkK8sConfig = function (config) {
        if (!config.k8sConfig) {
            return mslib_1.OpResult.error('应用选项配置校验失败，未配置K8S [k8sConfig]');
        }
        return mslib_1.OpResult.success('OK');
    };
    AppOptionsConfigChcker.checkLogConfig = function (config) {
        if (!config.logConfig) {
            return mslib_1.OpResult.error('应用选项配置校验失败，未配置日志服务 [logConfig]');
        }
        return mslib_1.OpResult.success('OK');
    };
    AppOptionsConfigChcker.checkSpecConfig = function (config) {
        if (!config.specConfig) {
            return mslib_1.OpResult.error('应用选项配置校验失败，未配置部署规格 [specConfig]');
        }
        return mslib_1.OpResult.success('OK');
    };
    return AppOptionsConfigChcker;
}());
exports.AppOptionsConfigChcker = AppOptionsConfigChcker;
//# sourceMappingURL=AppOptionsConfigChcker.js.map