@gorizond/catalog-backend-module-fleet
Version:
Backstage catalog backend module for Rancher Fleet GitOps entities
52 lines (51 loc) • 1.4 kB
JavaScript
;
/**
* Fleet Custom Resource Types
* Based on fleet.cattle.io/v1alpha1
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.FLEET_STATUS_PRIORITY = void 0;
exports.getWorstStatus = getWorstStatus;
exports.statusToLifecycle = statusToLifecycle;
// ============================================================================
// Fleet Status Utilities
// ============================================================================
exports.FLEET_STATUS_PRIORITY = {
Ready: 0,
NotReady: 1,
Pending: 2,
OutOfSync: 3,
Modified: 4,
WaitApplied: 5,
ErrApplied: 6,
};
function getWorstStatus(statuses) {
let worst = "Ready";
let worstPriority = 0;
for (const status of statuses) {
if (!status)
continue;
const priority = exports.FLEET_STATUS_PRIORITY[status] ?? 99;
if (priority > worstPriority) {
worstPriority = priority;
worst = status;
}
}
return worst;
}
function statusToLifecycle(status) {
switch (status) {
case "Ready":
return "production";
case "Pending":
case "WaitApplied":
return "experimental";
case "NotReady":
case "OutOfSync":
case "Modified":
case "ErrApplied":
return "deprecated";
default:
return "production";
}
}