@openshift-assisted/ui-lib
Version:
React component library for the Assisted Installer UI
36 lines • 2.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isStorageConfigured = exports.isCIMConfigProgressing = exports.isCIMConfigured = exports.isCIMEnabled = exports.LOCAL_STORAGE_ID_LAST_UPDATE_TIMESTAMP = void 0;
const utils_1 = require("../../../utils");
const constants_1 = require("./constants");
exports.LOCAL_STORAGE_ID_LAST_UPDATE_TIMESTAMP = 'cim-config-configuring-started-at';
const isCIMEnabled = ({ agentServiceConfig, }) => !!agentServiceConfig;
exports.isCIMEnabled = isCIMEnabled;
const isCIMConfigured = ({ agentServiceConfig, }) => {
var _a;
const deploymentsHealthyCondition = (0, utils_1.getConditionByType)(((_a = agentServiceConfig === null || agentServiceConfig === void 0 ? void 0 : agentServiceConfig.status) === null || _a === void 0 ? void 0 : _a.conditions) || [], 'DeploymentsHealthy');
return (deploymentsHealthyCondition === null || deploymentsHealthyCondition === void 0 ? void 0 : deploymentsHealthyCondition.status) === 'True';
};
exports.isCIMConfigured = isCIMConfigured;
const isCIMConfigProgressing = ({ agentServiceConfig, }) => {
var _a;
if (!agentServiceConfig) {
return false;
}
const deploymentsHealthyCondition = (0, utils_1.getConditionByType)(((_a = agentServiceConfig === null || agentServiceConfig === void 0 ? void 0 : agentServiceConfig.status) === null || _a === void 0 ? void 0 : _a.conditions) || [], 'DeploymentsHealthy');
const now = Date.now();
// Potential post-creation change of the ingress controller (from No to Yes) forces the AI deployment reconciliation and so reporting "errors" during the course.
// For that reason we can not reuse AgentServiceController's creationTimestamp to report issues with a graceful delay.
// We can store timestamp into a label or simply to the localStorage - let's see if that is an issue in a multi-tenant environment.
const updateTime = new Date(
// agentServiceConfig.metadata?.creationTimestamp || 0,
window.localStorage.getItem(exports.LOCAL_STORAGE_ID_LAST_UPDATE_TIMESTAMP) || 0);
const withinProgressingTimePerion = now - updateTime.valueOf() < constants_1.CIM_CONFIG_TIMEOUT;
return (!deploymentsHealthyCondition ||
deploymentsHealthyCondition.status === 'Unknown' ||
(deploymentsHealthyCondition.status === 'False' && withinProgressingTimePerion));
};
exports.isCIMConfigProgressing = isCIMConfigProgressing;
const isStorageConfigured = ({ storageClasses, }) => !!storageClasses && storageClasses.length > 0;
exports.isStorageConfigured = isStorageConfigured;
//# sourceMappingURL=utils.js.map