@stolostron/multicluster-sdk
Version:
Provides extensions and APIs that dynamic plugins can use to leverage multicluster capabilities provided by Red Hat Advanced Cluster Management.
22 lines • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.useFleetK8sAPIPath = useFleetK8sAPIPath;
/* Copyright Contributors to the Open Cluster Management project */
const constants_1 = require("../internal/constants");
const getFleetK8sAPIPath_1 = require("../internal/getFleetK8sAPIPath");
const useHubConfigurationItem_1 = require("../internal/useHubConfigurationItem");
/**
* Hook that provides the k8s API path for the fleet.
*
* @param cluster - The cluster name.
* @returns Array with `k8sAPIPath`, `loaded` and `error` values.
*/
function useFleetK8sAPIPath(cluster) {
const [hubClusterName, loaded, error] = (0, useHubConfigurationItem_1.useHubConfigurationItem)('localHubName');
if (!loaded)
return [undefined, false, error];
if (!cluster || cluster === hubClusterName)
return [constants_1.BASE_K8S_API_PATH, true, undefined];
return [(0, getFleetK8sAPIPath_1.getFleetK8sAPIPath)(hubClusterName, cluster), loaded, error];
}
//# sourceMappingURL=useFleetK8sAPIPath.js.map