@stolostron/multicluster-sdk 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/FleetResourceLink.d.ts +1 -0
- package/lib/api/FleetResourceLink.d.ts.map +1 -1
- package/lib/api/FleetResourceLink.js +26 -9
- package/lib/api/FleetResourceLink.js.map +1 -1
- package/lib/api/fleetK8sListItems.d.ts +4 -0
- package/lib/api/fleetK8sListItems.d.ts.map +1 -0
- package/lib/api/fleetK8sListItems.js +28 -0
- package/lib/api/fleetK8sListItems.js.map +1 -0
- package/lib/api/useFleetAccessReview/access-review.d.ts +20 -0
- package/lib/api/useFleetAccessReview/access-review.d.ts.map +1 -0
- package/lib/api/useFleetAccessReview/access-review.js +47 -0
- package/lib/api/useFleetAccessReview/access-review.js.map +1 -0
- package/lib/api/useFleetAccessReview/checkAccess.d.ts +19 -0
- package/lib/api/useFleetAccessReview/checkAccess.d.ts.map +1 -0
- package/lib/api/useFleetAccessReview/checkAccess.js +54 -0
- package/lib/api/useFleetAccessReview/checkAccess.js.map +1 -0
- package/lib/api/useFleetAccessReview/index.d.ts +2 -0
- package/lib/api/useFleetAccessReview/index.d.ts.map +1 -0
- package/lib/api/useFleetAccessReview/index.js +7 -0
- package/lib/api/useFleetAccessReview/index.js.map +1 -0
- package/lib/api/useFleetK8sWatchResource copy.d.ts +35 -0
- package/lib/api/useFleetK8sWatchResource copy.d.ts.map +1 -0
- package/lib/api/useFleetK8sWatchResource copy.js +98 -0
- package/lib/api/useFleetK8sWatchResource copy.js.map +1 -0
- package/lib/api/useFleetK8sWatchResourceOld.d.ts +35 -0
- package/lib/api/useFleetK8sWatchResourceOld.d.ts.map +1 -0
- package/lib/api/useFleetK8sWatchResourceOld.js +227 -0
- package/lib/api/useFleetK8sWatchResourceOld.js.map +1 -0
- package/lib/api/useFleetPrometheusPoll/index.js +1 -1
- package/lib/api/useFleetPrometheusPoll/index.js.map +1 -1
- package/lib/components/FleetResourceEventStream/EventStream.d.ts.map +1 -1
- package/lib/components/FleetResourceEventStream/EventStream.js +2 -1
- package/lib/components/FleetResourceEventStream/EventStream.js.map +1 -1
- package/lib/internal/cachedHubClusterName.d.ts.map +1 -1
- package/lib/internal/cachedHubClusterName.js +12 -5
- package/lib/internal/cachedHubClusterName.js.map +1 -1
- package/lib/internal/components/FleetK8sWatchResourceStoreViewer.d.ts +2 -0
- package/lib/internal/components/FleetK8sWatchResourceStoreViewer.d.ts.map +1 -0
- package/lib/internal/components/FleetK8sWatchResourceStoreViewer.js +42 -0
- package/lib/internal/components/FleetK8sWatchResourceStoreViewer.js.map +1 -0
- package/lib/internal/components/FleetK8sWatchResourceStoreViewerOld.d.ts +2 -0
- package/lib/internal/components/FleetK8sWatchResourceStoreViewerOld.d.ts.map +1 -0
- package/lib/internal/components/FleetK8sWatchResourceStoreViewerOld.js +48 -0
- package/lib/internal/components/FleetK8sWatchResourceStoreViewerOld.js.map +1 -0
- package/lib/internal/fleetK8sWatchResource.d.ts +1 -1
- package/lib/internal/fleetK8sWatchResource.d.ts.map +1 -1
- package/lib/internal/fleetK8sWatchResource.js +90 -53
- package/lib/internal/fleetK8sWatchResource.js.map +1 -1
- package/lib/internal/fleetK8sWatchResourceOld.d.ts +2 -0
- package/lib/internal/fleetK8sWatchResourceOld.d.ts.map +1 -0
- package/lib/internal/fleetK8sWatchResourceOld.js +61 -0
- package/lib/internal/fleetK8sWatchResourceOld.js.map +1 -0
- package/lib/internal/fleetK8sWatchResourceStore copy.d.ts +50 -0
- package/lib/internal/fleetK8sWatchResourceStore copy.d.ts.map +1 -0
- package/lib/internal/fleetK8sWatchResourceStore copy.js +161 -0
- package/lib/internal/fleetK8sWatchResourceStore copy.js.map +1 -0
- package/lib/internal/fleetK8sWatchResourceStore.d.ts +6 -1
- package/lib/internal/fleetK8sWatchResourceStore.d.ts.map +1 -1
- package/lib/internal/fleetK8sWatchResourceStore.js +64 -24
- package/lib/internal/fleetK8sWatchResourceStore.js.map +1 -1
- package/lib/internal/fleetK8sWatchResourceStoreOld.d.ts +48 -0
- package/lib/internal/fleetK8sWatchResourceStoreOld.d.ts.map +1 -0
- package/lib/internal/fleetK8sWatchResourceStoreOld.js +158 -0
- package/lib/internal/fleetK8sWatchResourceStoreOld.js.map +1 -0
- package/lib/internal/types.d.ts +1 -0
- package/lib/internal/types.d.ts.map +1 -0
- package/lib/internal/types.js +2 -0
- package/lib/internal/types.js.map +1 -0
- package/package.json +6 -7
- package/lib/api/useBackendURL.d.ts +0 -2
- package/lib/api/useBackendURL.d.ts.map +0 -1
- package/lib/api/useBackendURL.js +0 -45
- package/lib/api/useBackendURL.js.map +0 -1
- package/lib/api/utils/api-resource-list.d.ts +0 -2
- package/lib/api/utils/api-resource-list.d.ts.map +0 -1
- package/lib/api/utils/api-resource-list.js +0 -18
- package/lib/api/utils/api-resource-list.js.map +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FleetResourceLink.d.ts","sourceRoot":"","sources":["../../src/api/FleetResourceLink.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FleetResourceLink.d.ts","sourceRoot":"","sources":["../../src/api/FleetResourceLink.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAKvD,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA+D9D,CAAA"}
|
|
@@ -10,22 +10,39 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
}
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
13
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
17
|
exports.FleetResourceLink = void 0;
|
|
15
18
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
-
/* Copyright Contributors to the Open Cluster Management project */
|
|
17
19
|
const dynamic_plugin_sdk_1 = require("@openshift-console/dynamic-plugin-sdk");
|
|
18
|
-
const
|
|
20
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
21
|
+
const react_router_dom_v5_compat_1 = require("react-router-dom-v5-compat");
|
|
22
|
+
const searchPaths_1 = require("./utils/searchPaths");
|
|
19
23
|
const FleetResourceLink = (_a) => {
|
|
20
|
-
var { cluster } = _a,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
24
|
+
var { cluster } = _a, resourceLinkProps = __rest(_a, ["cluster"]);
|
|
25
|
+
if (cluster) {
|
|
26
|
+
const { className, displayName, inline = false, groupVersionKind, name, nameSuffix, namespace, hideIcon, title, children, dataTest, onClick, truncate, } = resourceLinkProps;
|
|
27
|
+
const value = displayName ? displayName : name;
|
|
28
|
+
const classes = (0, classnames_1.default)('co-resource-item', className || '', {
|
|
29
|
+
'co-resource-item--inline': inline,
|
|
30
|
+
'co-resource-item--truncate': truncate,
|
|
31
|
+
});
|
|
32
|
+
const path = (groupVersionKind === null || groupVersionKind === void 0 ? void 0 : groupVersionKind.kind) === 'VirtualMachine' && namespace
|
|
33
|
+
? `/k8s/cluster/${cluster}/ns/${namespace}/kubevirt.io~v1~VirtualMachine/${name}`
|
|
34
|
+
: `/multicloud/search/resources${(0, searchPaths_1.getURLSearchParam)({
|
|
35
|
+
cluster,
|
|
36
|
+
kind: groupVersionKind === null || groupVersionKind === void 0 ? void 0 : groupVersionKind.kind,
|
|
37
|
+
apigroup: groupVersionKind === null || groupVersionKind === void 0 ? void 0 : groupVersionKind.group,
|
|
38
|
+
apiversion: groupVersionKind === null || groupVersionKind === void 0 ? void 0 : groupVersionKind.version,
|
|
39
|
+
name,
|
|
40
|
+
namespace,
|
|
41
|
+
})}`;
|
|
42
|
+
return ((0, jsx_runtime_1.jsxs)("span", { className: classes, children: [!hideIcon && (0, jsx_runtime_1.jsx)(dynamic_plugin_sdk_1.ResourceIcon, { groupVersionKind: groupVersionKind }), path ? ((0, jsx_runtime_1.jsxs)(react_router_dom_v5_compat_1.Link, { to: path, title: title, className: "co-resource-item__resource-name", "data-test-id": value, "data-test": dataTest !== null && dataTest !== void 0 ? dataTest : value, onClick: onClick, children: [value, nameSuffix] })) : ((0, jsx_runtime_1.jsxs)("span", { className: "co-resource-item__resource-name", "data-test-id": value, "data-test": dataTest !== null && dataTest !== void 0 ? dataTest : value, children: [value, nameSuffix] })), children] }));
|
|
26
43
|
}
|
|
27
44
|
else {
|
|
28
|
-
return (0, jsx_runtime_1.jsx)(dynamic_plugin_sdk_1.ResourceLink, Object.assign({},
|
|
45
|
+
return (0, jsx_runtime_1.jsx)(dynamic_plugin_sdk_1.ResourceLink, Object.assign({}, resourceLinkProps));
|
|
29
46
|
}
|
|
30
47
|
};
|
|
31
48
|
exports.FleetResourceLink = FleetResourceLink;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FleetResourceLink.js","sourceRoot":"","sources":["../../src/api/FleetResourceLink.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FleetResourceLink.js","sourceRoot":"","sources":["../../src/api/FleetResourceLink.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAEA,8EAAkF;AAElF,4DAAmC;AACnC,2EAAiD;AACjD,qDAAuD;AAEhD,MAAM,iBAAiB,GAAqC,CAAC,EAAiC,EAAE,EAAE;QAArC,EAAE,OAAO,OAAwB,EAAnB,iBAAiB,cAA/B,WAAiC,CAAF;IACjG,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,EACJ,SAAS,EACT,WAAW,EACX,MAAM,GAAG,KAAK,EACd,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,SAAS,EACT,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,QAAQ,GACT,GAAG,iBAAiB,CAAA;QAErB,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAA;QAC9C,MAAM,OAAO,GAAG,IAAA,oBAAU,EAAC,kBAAkB,EAAE,SAAS,IAAI,EAAE,EAAE;YAC9D,0BAA0B,EAAE,MAAM;YAClC,4BAA4B,EAAE,QAAQ;SACvC,CAAC,CAAA;QAEF,MAAM,IAAI,GACR,CAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,IAAI,MAAK,gBAAgB,IAAI,SAAS;YACtD,CAAC,CAAC,gBAAgB,OAAO,OAAO,SAAS,kCAAkC,IAAI,EAAE;YACjF,CAAC,CAAC,+BAA+B,IAAA,+BAAiB,EAAC;gBAC/C,OAAO;gBACP,IAAI,EAAE,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,IAAI;gBAC5B,QAAQ,EAAE,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,KAAK;gBACjC,UAAU,EAAE,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,OAAO;gBACrC,IAAI;gBACJ,SAAS;aACV,CAAC,EAAE,CAAA;QAEV,OAAO,CACL,kCAAM,SAAS,EAAE,OAAO,aACrB,CAAC,QAAQ,IAAI,uBAAC,iCAAY,IAAC,gBAAgB,EAAE,gBAAgB,GAAI,EACjE,IAAI,CAAC,CAAC,CAAC,CACN,wBAAC,iCAAI,IACH,EAAE,EAAE,IAAI,EACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAC,iCAAiC,kBAC7B,KAAK,eACR,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,KAAK,EAC5B,OAAO,EAAE,OAAO,aAEf,KAAK,EACL,UAAU,IACN,CACR,CAAC,CAAC,CAAC,CACF,kCAAM,SAAS,EAAC,iCAAiC,kBAAe,KAAK,eAAa,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,KAAK,aAChG,KAAK,EACL,UAAU,IACN,CACR,EACA,QAAQ,IACJ,CACR,CAAA;IACH,CAAC;SAAM,CAAC;QACN,OAAO,uBAAC,iCAAY,oBAAK,iBAAiB,EAAI,CAAA;IAChD,CAAC;AACH,CAAC,CAAA;AA/DY,QAAA,iBAAiB,qBA+D7B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FleetK8sUpdateOptions } from '../internal/apiRequests';
|
|
2
|
+
import { FleetK8sResourceCommon } from '../types';
|
|
3
|
+
export declare function fleetK8sListItems<R extends FleetK8sResourceCommon>(options: FleetK8sUpdateOptions<R>): Promise<R>;
|
|
4
|
+
//# sourceMappingURL=fleetK8sListItems.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fleetK8sListItems.d.ts","sourceRoot":"","sources":["../../src/api/fleetK8sListItems.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,qBAAqB,EAItB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAGjD,wBAAsB,iBAAiB,CAAC,CAAC,SAAS,sBAAsB,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAQvH"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.fleetK8sListItems = fleetK8sListItems;
|
|
13
|
+
/* Copyright Contributors to the Open Cluster Management project */
|
|
14
|
+
const dynamic_plugin_sdk_1 = require("@openshift-console/dynamic-plugin-sdk");
|
|
15
|
+
const dynamic_plugin_sdk_2 = require("@openshift-console/dynamic-plugin-sdk");
|
|
16
|
+
const apiRequests_1 = require("../internal/apiRequests");
|
|
17
|
+
const isHubRequest_1 = require("../internal/isHubRequest");
|
|
18
|
+
function fleetK8sListItems(options) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const cluster = (0, apiRequests_1.getClusterFromOptions)(options);
|
|
21
|
+
const optionsWithoutCluster = (0, apiRequests_1.getOptionsWithoutCluster)(options);
|
|
22
|
+
const result = (yield (0, isHubRequest_1.isHubRequest)(cluster))
|
|
23
|
+
? (0, dynamic_plugin_sdk_2.k8sUpdate)(optionsWithoutCluster)
|
|
24
|
+
: dynamic_plugin_sdk_1.consoleFetchJSON.put(yield (0, apiRequests_1.getResourceURLFromOptions)(options), optionsWithoutCluster.data);
|
|
25
|
+
return Object.assign(Object.assign({}, (yield result)), { cluster });
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=fleetK8sListItems.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fleetK8sListItems.js","sourceRoot":"","sources":["../../src/api/fleetK8sListItems.ts"],"names":[],"mappings":";;;;;;;;;;;AAYA,8CAQC;AApBD,mEAAmE;AACnE,8EAAwE;AACxE,8EAAiE;AACjE,yDAKgC;AAEhC,2DAAuD;AAEvD,SAAsB,iBAAiB,CAAmC,OAAiC;;QACzG,MAAM,OAAO,GAAG,IAAA,mCAAqB,EAAC,OAAO,CAAC,CAAA;QAC9C,MAAM,qBAAqB,GAAG,IAAA,sCAAwB,EAAC,OAAO,CAAC,CAAA;QAE/D,MAAM,MAAM,GAAG,CAAC,MAAM,IAAA,2BAAY,EAAC,OAAO,CAAC,CAAC;YAC1C,CAAC,CAAC,IAAA,8BAAS,EAAC,qBAAqB,CAAC;YAClC,CAAC,CAAE,qCAAgB,CAAC,GAAG,CAAC,MAAM,IAAA,uCAAyB,EAAC,OAAO,CAAC,EAAE,qBAAqB,CAAC,IAAI,CAAgB,CAAA;QAC9G,uCAAY,CAAC,MAAM,MAAM,CAAC,KAAE,OAAO,IAAE;IACvC,CAAC;CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AccessReviewResourceAttributes } from '@openshift-console/dynamic-plugin-sdk';
|
|
2
|
+
type FleetAccessReviewResourceAttributes = AccessReviewResourceAttributes & {
|
|
3
|
+
cluster?: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Hook that provides information about user access to a given resource.
|
|
7
|
+
* @param resourceAttributes resource attributes for access review
|
|
8
|
+
* @param resourceAttributes.group the name of the group to check access for
|
|
9
|
+
* @param resourceAttributes.resource the name of the resource to check access for
|
|
10
|
+
* @param resourceAttributes.subresource the name of the subresource to check access for
|
|
11
|
+
* @param resourceAttributes.verb the "action" to perform; one of 'create' | 'get' | 'list' | 'update' | 'patch' | 'delete' | 'deletecollection' | 'watch' | 'impersonate'
|
|
12
|
+
* @param resourceAttributes.name the name
|
|
13
|
+
* @param resourceAttributes.namespace the namespace
|
|
14
|
+
* @param resourceAttributes.cluster the cluster name to find the resource in
|
|
15
|
+
*
|
|
16
|
+
* @returns Array with `isAllowed` and `loading` values.
|
|
17
|
+
*/
|
|
18
|
+
export declare const useFleetAccessReview: ({ group, resource, subresource, verb, name, namespace, cluster, }: FleetAccessReviewResourceAttributes) => [boolean, boolean];
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=access-review.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access-review.d.ts","sourceRoot":"","sources":["../../../src/api/useFleetAccessReview/access-review.ts"],"names":[],"mappings":"AACA,OAAO,EACL,8BAA8B,EAG/B,MAAM,uCAAuC,CAAA;AAI9C,KAAK,mCAAmC,GAAG,8BAA8B,GAAG;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,GAAI,mEAQlC,mCAAmC,KAAG,CAAC,OAAO,EAAE,OAAO,CA2BzD,CAAA"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFleetAccessReview = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const checkAccess_1 = require("./checkAccess");
|
|
6
|
+
/**
|
|
7
|
+
* Hook that provides information about user access to a given resource.
|
|
8
|
+
* @param resourceAttributes resource attributes for access review
|
|
9
|
+
* @param resourceAttributes.group the name of the group to check access for
|
|
10
|
+
* @param resourceAttributes.resource the name of the resource to check access for
|
|
11
|
+
* @param resourceAttributes.subresource the name of the subresource to check access for
|
|
12
|
+
* @param resourceAttributes.verb the "action" to perform; one of 'create' | 'get' | 'list' | 'update' | 'patch' | 'delete' | 'deletecollection' | 'watch' | 'impersonate'
|
|
13
|
+
* @param resourceAttributes.name the name
|
|
14
|
+
* @param resourceAttributes.namespace the namespace
|
|
15
|
+
* @param resourceAttributes.cluster the cluster name to find the resource in
|
|
16
|
+
*
|
|
17
|
+
* @returns Array with `isAllowed` and `loading` values.
|
|
18
|
+
*/
|
|
19
|
+
const useFleetAccessReview = ({ group = '', resource = '', subresource = '', verb = '', name = '', namespace = '', cluster = '', }) => {
|
|
20
|
+
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
21
|
+
const [isAllowed, setAllowed] = (0, react_1.useState)(false);
|
|
22
|
+
const skipCheck = !group && !resource;
|
|
23
|
+
(0, react_1.useEffect)(() => {
|
|
24
|
+
if (skipCheck) {
|
|
25
|
+
setAllowed(false);
|
|
26
|
+
setLoading(false);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
(0, checkAccess_1.checkAccess)(group, resource, subresource, verb, name, namespace, cluster)
|
|
30
|
+
.then((result) => {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
setAllowed((_b = (_a = result.status) === null || _a === void 0 ? void 0 : _a.allowed) !== null && _b !== void 0 ? _b : false);
|
|
33
|
+
setLoading(false);
|
|
34
|
+
})
|
|
35
|
+
.catch((e) => {
|
|
36
|
+
console.warn('SelfSubjectAccessReview failed', e);
|
|
37
|
+
// Default to enabling the action if the access review fails so that we
|
|
38
|
+
// don't incorrectly block users from actions they can perform. The server
|
|
39
|
+
// still enforces access control.
|
|
40
|
+
setAllowed(true);
|
|
41
|
+
setLoading(false);
|
|
42
|
+
});
|
|
43
|
+
}, [setLoading, setAllowed, group, resource, subresource, verb, name, namespace, cluster, skipCheck]);
|
|
44
|
+
return [isAllowed, loading];
|
|
45
|
+
};
|
|
46
|
+
exports.useFleetAccessReview = useFleetAccessReview;
|
|
47
|
+
//# sourceMappingURL=access-review.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access-review.js","sourceRoot":"","sources":["../../../src/api/useFleetAccessReview/access-review.ts"],"names":[],"mappings":";;;AAMA,iCAA2C;AAC3C,+CAA2C;AAM3C;;;;;;;;;;;;GAYG;AACI,MAAM,oBAAoB,GAAG,CAAC,EACnC,KAAK,GAAG,EAAE,EACV,QAAQ,GAAG,EAAE,EACb,WAAW,GAAG,EAAE,EAChB,IAAI,GAAG,EAAa,EACpB,IAAI,GAAG,EAAE,EACT,SAAS,GAAG,EAAE,EACd,OAAO,GAAG,EAAE,GACwB,EAAsB,EAAE;IAC5D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,IAAI,CAAC,CAAA;IAC5C,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAA;IAE/C,MAAM,SAAS,GAAG,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAA;IACrC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,SAAS,EAAE,CAAC;YACd,UAAU,CAAC,KAAK,CAAC,CAAA;YACjB,UAAU,CAAC,KAAK,CAAC,CAAA;YACjB,OAAM;QACR,CAAC;QACD,IAAA,yBAAW,EAAC,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC;aACtE,IAAI,CAAC,CAAC,MAAmC,EAAE,EAAE;;YAC5C,UAAU,CAAC,MAAA,MAAA,MAAM,CAAC,MAAM,0CAAE,OAAO,mCAAI,KAAK,CAAC,CAAA;YAC3C,UAAU,CAAC,KAAK,CAAC,CAAA;QACnB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,CAAQ,EAAE,EAAE;YAClB,OAAO,CAAC,IAAI,CAAC,gCAAgC,EAAE,CAAC,CAAC,CAAA;YACjD,uEAAuE;YACvE,0EAA0E;YAC1E,iCAAiC;YACjC,UAAU,CAAC,IAAI,CAAC,CAAA;YAChB,UAAU,CAAC,KAAK,CAAC,CAAA;QACnB,CAAC,CAAC,CAAA;IACN,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,CAAA;IAErG,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC7B,CAAC,CAAA;AAnCY,QAAA,oBAAoB,wBAmChC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { K8sVerb, SelfSubjectAccessReviewKind, K8sModel } from '@openshift-console/dynamic-plugin-sdk';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
/**
|
|
4
|
+
* Memoizes the result so it is possible to only make the request once for each access review.
|
|
5
|
+
* This does mean that the user will have to refresh the page to see updates.
|
|
6
|
+
* Function takes in the destructured resource attributes so that the cache keys are stable.
|
|
7
|
+
* `JSON.stringify` is not guaranteed to give the same result for equivalent objects.
|
|
8
|
+
* Impersonate headers are added automatically by `k8sCreate`.
|
|
9
|
+
* @param group resource group.
|
|
10
|
+
* @param resource resource string.
|
|
11
|
+
* @param subresource subresource string.
|
|
12
|
+
* @param verb K8s verb.
|
|
13
|
+
* @param namespace namespace.
|
|
14
|
+
* @param impersonateKey parameter to include in the cache key even though it's not used in the function body.
|
|
15
|
+
* @returns Memoized result of the access review.
|
|
16
|
+
*/
|
|
17
|
+
export declare const checkAccess: ((group: string, resource: string, subresource: string, verb: K8sVerb, name: string, namespace: string, cluster: string) => Promise<SelfSubjectAccessReviewKind>) & _.MemoizedFunction;
|
|
18
|
+
export declare const SelfSubjectAccessReviewModel: K8sModel;
|
|
19
|
+
//# sourceMappingURL=checkAccess.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkAccess.d.ts","sourceRoot":"","sources":["../../../src/api/useFleetAccessReview/checkAccess.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,2BAA2B,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAA;AACtG,OAAO,CAAC,MAAM,QAAQ,CAAA;AAGtB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,WAEb,MAAM,YACH,MAAM,eACH,MAAM,QACb,OAAO,QACP,MAAM,aACD,MAAM,WACR,MAAM,KACd,OAAO,CAAC,2BAA2B,CAAC,sBAuBxC,CAAA;AAED,eAAO,MAAM,4BAA4B,EAAE,QAQ1C,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SelfSubjectAccessReviewModel = exports.checkAccess = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const apiRequests_1 = require("../apiRequests");
|
|
9
|
+
/**
|
|
10
|
+
* Memoizes the result so it is possible to only make the request once for each access review.
|
|
11
|
+
* This does mean that the user will have to refresh the page to see updates.
|
|
12
|
+
* Function takes in the destructured resource attributes so that the cache keys are stable.
|
|
13
|
+
* `JSON.stringify` is not guaranteed to give the same result for equivalent objects.
|
|
14
|
+
* Impersonate headers are added automatically by `k8sCreate`.
|
|
15
|
+
* @param group resource group.
|
|
16
|
+
* @param resource resource string.
|
|
17
|
+
* @param subresource subresource string.
|
|
18
|
+
* @param verb K8s verb.
|
|
19
|
+
* @param namespace namespace.
|
|
20
|
+
* @param impersonateKey parameter to include in the cache key even though it's not used in the function body.
|
|
21
|
+
* @returns Memoized result of the access review.
|
|
22
|
+
*/
|
|
23
|
+
exports.checkAccess = lodash_1.default.memoize((group, resource, subresource, verb, name, namespace, cluster) => {
|
|
24
|
+
const reviewNamespace = group === 'project.openshift.io' && resource === 'projects' ? name : namespace;
|
|
25
|
+
const selfSubjectAccessReview = {
|
|
26
|
+
apiVersion: 'authorization.k8s.io/v1',
|
|
27
|
+
kind: 'SelfSubjectAccessReview',
|
|
28
|
+
spec: {
|
|
29
|
+
resourceAttributes: {
|
|
30
|
+
group,
|
|
31
|
+
resource,
|
|
32
|
+
subresource,
|
|
33
|
+
verb,
|
|
34
|
+
name,
|
|
35
|
+
namespace: reviewNamespace,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
return (0, apiRequests_1.fleetK8sCreate)({
|
|
40
|
+
model: exports.SelfSubjectAccessReviewModel,
|
|
41
|
+
data: selfSubjectAccessReview,
|
|
42
|
+
cluster,
|
|
43
|
+
});
|
|
44
|
+
}, (...args) => args.join('~'));
|
|
45
|
+
exports.SelfSubjectAccessReviewModel = {
|
|
46
|
+
abbr: 'SSAR',
|
|
47
|
+
kind: 'SelfSubjectAccessReview',
|
|
48
|
+
label: 'SelfSubjectAccessReview',
|
|
49
|
+
labelPlural: 'SelfSubjectAccessReviews',
|
|
50
|
+
plural: 'selfsubjectaccessreviews',
|
|
51
|
+
apiVersion: 'v1',
|
|
52
|
+
apiGroup: 'authorization.k8s.io',
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=checkAccess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkAccess.js","sourceRoot":"","sources":["../../../src/api/useFleetAccessReview/checkAccess.ts"],"names":[],"mappings":";;;;;;AAEA,oDAAsB;AACtB,gDAA+C;AAE/C;;;;;;;;;;;;;GAaG;AACU,QAAA,WAAW,GAAG,gBAAC,CAAC,OAAO,CAClC,CACE,KAAa,EACb,QAAgB,EAChB,WAAmB,EACnB,IAAa,EACb,IAAY,EACZ,SAAiB,EACjB,OAAe,EACuB,EAAE;IACxC,MAAM,eAAe,GAAG,KAAK,KAAK,sBAAsB,IAAI,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;IACtG,MAAM,uBAAuB,GAAgC;QAC3D,UAAU,EAAE,yBAAyB;QACrC,IAAI,EAAE,yBAAyB;QAC/B,IAAI,EAAE;YACJ,kBAAkB,EAAE;gBAClB,KAAK;gBACL,QAAQ;gBACR,WAAW;gBACX,IAAI;gBACJ,IAAI;gBACJ,SAAS,EAAE,eAAe;aAC3B;SACF;KACF,CAAA;IACD,OAAO,IAAA,4BAAc,EAAC;QACpB,KAAK,EAAE,oCAA4B;QACnC,IAAI,EAAE,uBAAuB;QAC7B,OAAO;KACR,CAAC,CAAA;AACJ,CAAC,EACD,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAC5B,CAAA;AAEY,QAAA,4BAA4B,GAAa;IACpD,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,yBAAyB;IAC/B,KAAK,EAAE,yBAAyB;IAChC,WAAW,EAAE,0BAA0B;IACvC,MAAM,EAAE,0BAA0B;IAClC,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,sBAAsB;CACjC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/useFleetAccessReview/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFleetAccessReview = void 0;
|
|
4
|
+
/* Copyright Contributors to the Open Cluster Management project */
|
|
5
|
+
var access_review_1 = require("./access-review");
|
|
6
|
+
Object.defineProperty(exports, "useFleetAccessReview", { enumerable: true, get: function () { return access_review_1.useFleetAccessReview; } });
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/useFleetAccessReview/index.ts"],"names":[],"mappings":";;;AAAA,mEAAmE;AACnE,iDAAsD;AAA7C,qHAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FleetK8sResourceCommon, FleetWatchK8sResource, FleetWatchK8sResult } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* A hook for watching Kubernetes resources with support for multi-cluster environments.
|
|
4
|
+
* It is equivalent to the [`useK8sWatchResource`](https://github.com/openshift/console/blob/main/frontend/packages/console-dynamic-plugin-sdk/docs/api.md#usek8swatchresource)
|
|
5
|
+
* hook from the [OpenShift Console Dynamic Plugin SDK](https://www.npmjs.com/package/@openshift-console/dynamic-plugin-sdk)
|
|
6
|
+
* but allows you to retrieve data from any cluster managed by Red Hat Advanced Cluster Management.
|
|
7
|
+
*
|
|
8
|
+
* It automatically detects the hub cluster and handles resource watching on both hub
|
|
9
|
+
* and remote clusters using WebSocket connections for real-time updates.
|
|
10
|
+
*
|
|
11
|
+
* @param initResource - The resource to watch. Can be null to disable the watch.
|
|
12
|
+
* @param initResource.cluster - The managed cluster on which the resource resides; null for the hub cluster
|
|
13
|
+
* @returns A tuple containing the watched resource data, a boolean indicating if the data is loaded,
|
|
14
|
+
* and any error that occurred. The hook returns live-updating data.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Watch pods on a remote cluster
|
|
19
|
+
* const [pods, loaded, error] = useFleetK8sWatchResource({
|
|
20
|
+
* groupVersionKind: { version: 'v1', kind: 'Pod' },
|
|
21
|
+
* isList: true,
|
|
22
|
+
* cluster: 'remote-cluster',
|
|
23
|
+
* namespace: 'default'
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* // Watch a specific deployment on hub cluster
|
|
27
|
+
* const [deployment, loaded, error] = useFleetK8sWatchResource({
|
|
28
|
+
* groupVersionKind: { group: 'apps', version: 'v1', kind: 'Deployment' },
|
|
29
|
+
* name: 'my-app',
|
|
30
|
+
* namespace: 'default'
|
|
31
|
+
* })
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function useFleetK8sWatchResource<R extends FleetK8sResourceCommon | FleetK8sResourceCommon[]>(initResource: FleetWatchK8sResource | null): FleetWatchK8sResult<R>;
|
|
35
|
+
//# sourceMappingURL=useFleetK8sWatchResource%20copy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFleetK8sWatchResource copy.d.ts","sourceRoot":"","sources":["../../src/api/useFleetK8sWatchResource copy.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EAEpB,MAAM,UAAU,CAAA;AASjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,sBAAsB,GAAG,sBAAsB,EAAE,EAClG,YAAY,EAAE,qBAAqB,GAAG,IAAI,GACzC,mBAAmB,CAAC,CAAC,CAAC,CAiDxB"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.useFleetK8sWatchResource = useFleetK8sWatchResource;
|
|
15
|
+
/* Copyright Contributors to the Open Cluster Management project */
|
|
16
|
+
const useHubClusterName_1 = require("./useHubClusterName");
|
|
17
|
+
const dynamic_plugin_sdk_1 = require("@openshift-console/dynamic-plugin-sdk");
|
|
18
|
+
const useIsFleetAvailable_1 = require("./useIsFleetAvailable");
|
|
19
|
+
const react_1 = require("react");
|
|
20
|
+
const useDeepCompareMemoize_1 = require("../internal/hooks/useDeepCompareMemoize");
|
|
21
|
+
const constants_1 = require("../internal/constants");
|
|
22
|
+
const useFleetK8sAPIPath_1 = require("./useFleetK8sAPIPath");
|
|
23
|
+
const fleetK8sWatchResource_1 = require("../internal/fleetK8sWatchResource");
|
|
24
|
+
/**
|
|
25
|
+
* A hook for watching Kubernetes resources with support for multi-cluster environments.
|
|
26
|
+
* It is equivalent to the [`useK8sWatchResource`](https://github.com/openshift/console/blob/main/frontend/packages/console-dynamic-plugin-sdk/docs/api.md#usek8swatchresource)
|
|
27
|
+
* hook from the [OpenShift Console Dynamic Plugin SDK](https://www.npmjs.com/package/@openshift-console/dynamic-plugin-sdk)
|
|
28
|
+
* but allows you to retrieve data from any cluster managed by Red Hat Advanced Cluster Management.
|
|
29
|
+
*
|
|
30
|
+
* It automatically detects the hub cluster and handles resource watching on both hub
|
|
31
|
+
* and remote clusters using WebSocket connections for real-time updates.
|
|
32
|
+
*
|
|
33
|
+
* @param initResource - The resource to watch. Can be null to disable the watch.
|
|
34
|
+
* @param initResource.cluster - The managed cluster on which the resource resides; null for the hub cluster
|
|
35
|
+
* @returns A tuple containing the watched resource data, a boolean indicating if the data is loaded,
|
|
36
|
+
* and any error that occurred. The hook returns live-updating data.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* // Watch pods on a remote cluster
|
|
41
|
+
* const [pods, loaded, error] = useFleetK8sWatchResource({
|
|
42
|
+
* groupVersionKind: { version: 'v1', kind: 'Pod' },
|
|
43
|
+
* isList: true,
|
|
44
|
+
* cluster: 'remote-cluster',
|
|
45
|
+
* namespace: 'default'
|
|
46
|
+
* })
|
|
47
|
+
*
|
|
48
|
+
* // Watch a specific deployment on hub cluster
|
|
49
|
+
* const [deployment, loaded, error] = useFleetK8sWatchResource({
|
|
50
|
+
* groupVersionKind: { group: 'apps', version: 'v1', kind: 'Deployment' },
|
|
51
|
+
* name: 'my-app',
|
|
52
|
+
* namespace: 'default'
|
|
53
|
+
* })
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
function useFleetK8sWatchResource(initResource) {
|
|
57
|
+
const isFleetAvailable = (0, useIsFleetAvailable_1.useIsFleetAvailable)();
|
|
58
|
+
const [hubClusterName, hubClusterNameLoaded, hubClusterNameLoadedError] = (0, useHubClusterName_1.useHubClusterName)();
|
|
59
|
+
const memoizedResource = (0, useDeepCompareMemoize_1.useDeepCompareMemoize)(initResource, true);
|
|
60
|
+
const _a = memoizedResource !== null && memoizedResource !== void 0 ? memoizedResource : {}, { cluster } = _a, resource = __rest(_a, ["cluster"]);
|
|
61
|
+
const { groupVersionKind } = resource;
|
|
62
|
+
const [model, modelLoading] = (0, dynamic_plugin_sdk_1.useK8sModel)(groupVersionKind);
|
|
63
|
+
const [backendAPIPath, backendPathLoaded] = (0, useFleetK8sAPIPath_1.useFleetK8sAPIPath)(cluster);
|
|
64
|
+
const waitingForHubClusterName = !!cluster && !hubClusterNameLoaded;
|
|
65
|
+
const isFleetQuery = cluster && cluster !== hubClusterName;
|
|
66
|
+
// avoid using the fleet query if it is not available
|
|
67
|
+
// avoid using either query if we are still waiting for the hub name to compare against the supplied cluster name
|
|
68
|
+
const useFleet = isFleetQuery && isFleetAvailable && !waitingForHubClusterName;
|
|
69
|
+
const useLocal = !isFleetQuery && !waitingForHubClusterName;
|
|
70
|
+
const isResourceNull = !memoizedResource || !groupVersionKind;
|
|
71
|
+
const [fleetResult, setFleetResult] = (0, react_1.useState)((0, fleetK8sWatchResource_1.getInitialResult)(memoizedResource, model, backendAPIPath));
|
|
72
|
+
const fleetResultTuple = (0, react_1.useMemo)(() => {
|
|
73
|
+
const { data, loaded, loadError } = fleetResult;
|
|
74
|
+
return [data, loaded, loadError];
|
|
75
|
+
}, [fleetResult]);
|
|
76
|
+
const localResult = (0, dynamic_plugin_sdk_1.useK8sWatchResource)(useLocal && !isResourceNull ? resource : null);
|
|
77
|
+
(0, react_1.useEffect)(() => {
|
|
78
|
+
if (useFleet && !isResourceNull && backendPathLoaded && backendAPIPath && !modelLoading && model) {
|
|
79
|
+
(0, fleetK8sWatchResource_1.startWatch)(memoizedResource, model, backendAPIPath, setFleetResult);
|
|
80
|
+
return () => (0, fleetK8sWatchResource_1.stopWatch)(memoizedResource, model, backendAPIPath);
|
|
81
|
+
}
|
|
82
|
+
}, [backendAPIPath, backendPathLoaded, isResourceNull, memoizedResource, model, modelLoading, useFleet]);
|
|
83
|
+
if (waitingForHubClusterName) {
|
|
84
|
+
// if we are still waiting for hub name to load,
|
|
85
|
+
// there is no result, loaded is false, and we should return any error fetching the hub name
|
|
86
|
+
return [undefined, false, hubClusterNameLoadedError];
|
|
87
|
+
}
|
|
88
|
+
else if (isFleetQuery && !isFleetAvailable) {
|
|
89
|
+
// if we need to use fleet support but it it not available,
|
|
90
|
+
// we return an error
|
|
91
|
+
return [undefined, false, constants_1.NO_FLEET_AVAILABLE_ERROR];
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
// otherwise, we return the fleet or single-cluster result accordingly
|
|
95
|
+
return useFleet ? fleetResultTuple : localResult;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=useFleetK8sWatchResource%20copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFleetK8sWatchResource copy.js","sourceRoot":"","sources":["../../src/api/useFleetK8sWatchResource copy.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FleetK8sResourceCommon, FleetWatchK8sResource, FleetWatchK8sResult } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* A hook for watching Kubernetes resources with support for multi-cluster environments.
|
|
4
|
+
* It is equivalent to the [`useK8sWatchResource`](https://github.com/openshift/console/blob/main/frontend/packages/console-dynamic-plugin-sdk/docs/api.md#usek8swatchresource)
|
|
5
|
+
* hook from the [OpenShift Console Dynamic Plugin SDK](https://www.npmjs.com/package/@openshift-console/dynamic-plugin-sdk)
|
|
6
|
+
* but allows you to retrieve data from any cluster managed by Red Hat Advanced Cluster Management.
|
|
7
|
+
*
|
|
8
|
+
* It automatically detects the hub cluster and handles resource watching on both hub
|
|
9
|
+
* and remote clusters using WebSocket connections for real-time updates.
|
|
10
|
+
*
|
|
11
|
+
* @param initResource - The resource to watch. Can be null to disable the watch.
|
|
12
|
+
* @param initResource.cluster - The managed cluster on which the resource resides; null for the hub cluster
|
|
13
|
+
* @returns A tuple containing the watched resource data, a boolean indicating if the data is loaded,
|
|
14
|
+
* and any error that occurred. The hook returns live-updating data.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Watch pods on a remote cluster
|
|
19
|
+
* const [pods, loaded, error] = useFleetK8sWatchResource({
|
|
20
|
+
* groupVersionKind: { version: 'v1', kind: 'Pod' },
|
|
21
|
+
* isList: true,
|
|
22
|
+
* cluster: 'remote-cluster',
|
|
23
|
+
* namespace: 'default'
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* // Watch a specific deployment on hub cluster
|
|
27
|
+
* const [deployment, loaded, error] = useFleetK8sWatchResource({
|
|
28
|
+
* groupVersionKind: { group: 'apps', version: 'v1', kind: 'Deployment' },
|
|
29
|
+
* name: 'my-app',
|
|
30
|
+
* namespace: 'default'
|
|
31
|
+
* })
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function useFleetK8sWatchResourceOld<R extends FleetK8sResourceCommon | FleetK8sResourceCommon[]>(initResource: FleetWatchK8sResource | null): FleetWatchK8sResult<R>;
|
|
35
|
+
//# sourceMappingURL=useFleetK8sWatchResourceOld.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFleetK8sWatchResourceOld.d.ts","sourceRoot":"","sources":["../../src/api/useFleetK8sWatchResourceOld.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAW7F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,sBAAsB,GAAG,sBAAsB,EAAE,EACrG,YAAY,EAAE,qBAAqB,GAAG,IAAI,GACzC,mBAAmB,CAAC,CAAC,CAAC,CA+LxB"}
|