@openshift-assisted/ui-lib
Version:
React component library for the Assisted Installer UI
30 lines • 1.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const apis_1 = require("../services/apis");
const utils_1 = require("../../common/utils");
const services_1 = require("../services");
function useInfraEnvIpxeImageUrl() {
const getIpxeImageUrl = react_1.default.useCallback((clusterId, cpuArchitecture) => tslib_1.__awaiter(this, void 0, void 0, function* () {
try {
const infraEnvId = yield services_1.InfraEnvsService.getInfraEnvId(clusterId, cpuArchitecture);
if (!infraEnvId || infraEnvId instanceof Error) {
return { url: '', error: `Failed to retrieve the infraEnv for ${clusterId}` };
}
const { data: { url }, } = yield apis_1.InfraEnvsAPI.getIpxeImageUrl(infraEnvId);
return {
url,
error: url
? ''
: 'Failed to retrieve the Ipxe image URL, the API returned an invalid URL',
};
}
catch (e) {
return { url: '', error: (0, utils_1.getErrorMessage)(e) };
}
}), []);
return { getIpxeImageUrl };
}
exports.default = useInfraEnvIpxeImageUrl;
//# sourceMappingURL=useInfraEnvIpxeImageUrl.js.map