@stolostron/multicluster-sdk 0.1.0-alpha.5 → 0.2.0-alpha.2
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/LICENSE +201 -0
- package/README.md +52 -0
- package/lib/api/FleetResourceLink.d.ts +3 -0
- package/lib/api/FleetResourceLink.d.ts.map +1 -0
- package/lib/api/FleetResourceLink.js +50 -0
- package/lib/api/FleetResourceLink.js.map +1 -0
- package/lib/api/FleetSupport.d.ts +6 -0
- package/lib/api/FleetSupport.d.ts.map +1 -0
- package/lib/api/FleetSupport.js +45 -0
- package/lib/api/FleetSupport.js.map +1 -0
- package/lib/api/apiRequests.d.ts +69 -0
- package/lib/api/apiRequests.d.ts.map +1 -0
- package/lib/api/apiRequests.js +188 -0
- package/lib/api/apiRequests.js.map +1 -0
- package/lib/api/constants.d.ts +4 -0
- package/lib/api/constants.d.ts.map +1 -0
- package/lib/api/constants.js +8 -0
- package/lib/api/constants.js.map +1 -0
- package/lib/api/fleet-resource-link.d.ts +1 -1
- package/lib/api/fleet-resource-link.d.ts.map +1 -1
- package/lib/api/fleet-resource-link.js +1 -1
- package/lib/api/fleet-resource-link.js.map +1 -1
- package/lib/api/fleet-support.d.ts +1 -1
- package/lib/api/fleet-support.d.ts.map +1 -1
- package/lib/api/fleet-support.js +1 -2
- package/lib/api/fleet-support.js.map +1 -1
- package/lib/api/index.d.ts +9 -5
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +9 -5
- package/lib/api/index.js.map +1 -1
- package/lib/api/search/search-client.d.ts +3 -0
- package/lib/api/search/search-client.d.ts.map +1 -0
- package/lib/api/search/search-client.js +52 -0
- package/lib/api/search/search-client.js.map +1 -0
- package/lib/api/search/search-sdk.d.ts +502 -0
- package/lib/api/search/search-sdk.d.ts.map +1 -0
- package/lib/api/search/search-sdk.js +344 -0
- package/lib/api/search/search-sdk.js.map +1 -0
- package/lib/api/search/searchUtils.d.ts +10 -0
- package/lib/api/search/searchUtils.d.ts.map +1 -0
- package/lib/api/search/searchUtils.js +34 -0
- package/lib/api/search/searchUtils.js.map +1 -0
- package/lib/api/search/types.d.ts +8 -0
- package/lib/api/search/types.d.ts.map +1 -0
- package/lib/api/search/types.js +3 -0
- package/lib/api/search/types.js.map +1 -0
- package/lib/api/search/useMulticlusterSearchWatch.d.ts +3 -0
- package/lib/api/search/useMulticlusterSearchWatch.d.ts.map +1 -0
- package/lib/api/search/useMulticlusterSearchWatch.js +67 -0
- package/lib/api/search/useMulticlusterSearchWatch.js.map +1 -0
- package/lib/api/use-fleet-access-review.d.ts +2 -0
- package/lib/api/use-fleet-access-review.d.ts.map +1 -0
- package/lib/api/use-fleet-access-review.js +10 -0
- package/lib/api/use-fleet-access-review.js.map +1 -0
- package/lib/api/use-fleet-k8s-api-path.d.ts +1 -1
- package/lib/api/use-fleet-k8s-api-path.d.ts.map +1 -1
- package/lib/api/use-fleet-k8s-api-path.js +1 -1
- package/lib/api/use-fleet-k8s-api-path.js.map +1 -1
- package/lib/api/use-fleet-k8s-watch-resource/use-fleet-k8s-watch-resource.d.ts +4 -0
- package/lib/api/use-fleet-k8s-watch-resource/use-fleet-k8s-watch-resource.d.ts.map +1 -0
- package/lib/api/use-fleet-k8s-watch-resource/use-fleet-k8s-watch-resource.js +123 -0
- package/lib/api/use-fleet-k8s-watch-resource/use-fleet-k8s-watch-resource.js.map +1 -0
- package/lib/api/use-fleet-k8s-watch-resource/utils.d.ts +2 -0
- package/lib/api/use-fleet-k8s-watch-resource/utils.d.ts.map +1 -0
- package/lib/api/use-fleet-k8s-watch-resource/utils.js +56 -0
- package/lib/api/use-fleet-k8s-watch-resource/utils.js.map +1 -0
- package/lib/api/use-fleet-k8s-watch-resource.d.ts +1 -1
- package/lib/api/use-fleet-k8s-watch-resource.d.ts.map +1 -1
- package/lib/api/use-fleet-k8s-watch-resource.js +1 -1
- package/lib/api/use-fleet-k8s-watch-resource.js.map +1 -1
- package/lib/api/use-hub-cluster-name.d.ts +1 -1
- package/lib/api/use-hub-cluster-name.d.ts.map +1 -1
- package/lib/api/useBackendURL.d.ts +2 -0
- package/lib/api/useBackendURL.d.ts.map +1 -0
- package/lib/api/useBackendURL.js +45 -0
- package/lib/api/useBackendURL.js.map +1 -0
- package/lib/api/useFleetClusterNames.d.ts +3 -0
- package/lib/api/useFleetClusterNames.d.ts.map +1 -0
- package/lib/api/useFleetClusterNames.js +20 -0
- package/lib/api/useFleetClusterNames.js.map +1 -0
- package/lib/api/useFleetK8sAPIPath.d.ts +4 -0
- package/lib/api/useFleetK8sAPIPath.d.ts.map +1 -0
- package/lib/api/useFleetK8sAPIPath.js +34 -0
- package/lib/api/useFleetK8sAPIPath.js.map +1 -0
- package/lib/api/useFleetK8sWatchResource.d.ts +3 -0
- package/lib/api/useFleetK8sWatchResource.d.ts.map +1 -0
- package/lib/api/useFleetK8sWatchResource.js +12 -0
- package/lib/api/useFleetK8sWatchResource.js.map +1 -0
- package/lib/api/useFleetPrometheusPoll/constants.d.ts +8 -0
- package/lib/api/useFleetPrometheusPoll/constants.d.ts.map +1 -0
- package/lib/api/useFleetPrometheusPoll/constants.js +12 -0
- package/lib/api/useFleetPrometheusPoll/constants.js.map +1 -0
- package/lib/api/useFleetPrometheusPoll/index.d.ts +7 -0
- package/lib/api/useFleetPrometheusPoll/index.d.ts.map +1 -0
- package/lib/api/useFleetPrometheusPoll/index.js +41 -0
- package/lib/api/useFleetPrometheusPoll/index.js.map +1 -0
- package/lib/api/useFleetPrometheusPoll/usePoll.d.ts +2 -0
- package/lib/api/useFleetPrometheusPoll/usePoll.d.ts.map +1 -0
- package/lib/api/useFleetPrometheusPoll/usePoll.js +27 -0
- package/lib/api/useFleetPrometheusPoll/usePoll.js.map +1 -0
- package/lib/api/useFleetPrometheusPoll/useSafeFetch.d.ts +2 -0
- package/lib/api/useFleetPrometheusPoll/useSafeFetch.d.ts.map +1 -0
- package/lib/api/useFleetPrometheusPoll/useSafeFetch.js +23 -0
- package/lib/api/useFleetPrometheusPoll/useSafeFetch.js.map +1 -0
- package/lib/api/useFleetPrometheusPoll/useURLPoll.d.ts +4 -0
- package/lib/api/useFleetPrometheusPoll/useURLPoll.d.ts.map +1 -0
- package/lib/api/useFleetPrometheusPoll/useURLPoll.js +40 -0
- package/lib/api/useFleetPrometheusPoll/useURLPoll.js.map +1 -0
- package/lib/api/useFleetPrometheusPoll/utils.d.ts +13 -0
- package/lib/api/useFleetPrometheusPoll/utils.d.ts.map +1 -0
- package/lib/api/useFleetPrometheusPoll/utils.js +67 -0
- package/lib/api/useFleetPrometheusPoll/utils.js.map +1 -0
- package/lib/api/useHubClusterName.d.ts +3 -0
- package/lib/api/useHubClusterName.d.ts.map +1 -0
- package/lib/api/useHubClusterName.js +8 -0
- package/lib/api/useHubClusterName.js.map +1 -0
- package/lib/api/utils/api-resource-list.d.ts +2 -0
- package/lib/api/utils/api-resource-list.d.ts.map +1 -0
- package/lib/api/utils/api-resource-list.js +18 -0
- package/lib/api/utils/api-resource-list.js.map +1 -0
- package/lib/api/utils/requirements.d.ts +6 -0
- package/lib/api/utils/requirements.d.ts.map +1 -0
- package/lib/api/utils/requirements.js +60 -0
- package/lib/api/utils/requirements.js.map +1 -0
- package/lib/api/utils/searchPaths.d.ts +2 -0
- package/lib/api/utils/searchPaths.d.ts.map +1 -0
- package/lib/api/utils/searchPaths.js +28 -0
- package/lib/api/utils/searchPaths.js.map +1 -0
- package/lib/components/FleetResourceEventStream/EventComponent.d.ts +5 -0
- package/lib/components/FleetResourceEventStream/EventComponent.d.ts.map +1 -0
- package/lib/components/FleetResourceEventStream/EventComponent.js +50 -0
- package/lib/components/FleetResourceEventStream/EventComponent.js.map +1 -0
- package/lib/components/FleetResourceEventStream/EventStream.d.ts +6 -0
- package/lib/components/FleetResourceEventStream/EventStream.d.ts.map +1 -0
- package/lib/components/FleetResourceEventStream/EventStream.js +171 -0
- package/lib/components/FleetResourceEventStream/EventStream.js.map +1 -0
- package/lib/components/FleetResourceEventStream/EventStreamList.d.ts +17 -0
- package/lib/components/FleetResourceEventStream/EventStreamList.d.ts.map +1 -0
- package/lib/components/FleetResourceEventStream/EventStreamList.js +82 -0
- package/lib/components/FleetResourceEventStream/EventStreamList.js.map +1 -0
- package/lib/components/FleetResourceEventStream/TogglePlay.d.ts +8 -0
- package/lib/components/FleetResourceEventStream/TogglePlay.d.ts.map +1 -0
- package/lib/components/FleetResourceEventStream/TogglePlay.js +15 -0
- package/lib/components/FleetResourceEventStream/TogglePlay.js.map +1 -0
- package/lib/components/FleetResourceEventStream/WithScrollContainer.d.ts +7 -0
- package/lib/components/FleetResourceEventStream/WithScrollContainer.d.ts.map +1 -0
- package/lib/components/FleetResourceEventStream/WithScrollContainer.js +41 -0
- package/lib/components/FleetResourceEventStream/WithScrollContainer.js.map +1 -0
- package/lib/components/FleetResourceEventStream/constants.d.ts +30 -0
- package/lib/components/FleetResourceEventStream/constants.d.ts.map +1 -0
- package/lib/components/FleetResourceEventStream/constants.js +6 -0
- package/lib/components/FleetResourceEventStream/constants.js.map +1 -0
- package/lib/components/FleetResourceEventStream/utils.d.ts +16 -0
- package/lib/components/FleetResourceEventStream/utils.d.ts.map +1 -0
- package/lib/components/FleetResourceEventStream/utils.js +133 -0
- package/lib/components/FleetResourceEventStream/utils.js.map +1 -0
- package/lib/components/ResourceEventStream/EventComponent.d.ts +5 -0
- package/lib/components/ResourceEventStream/EventComponent.d.ts.map +1 -0
- package/lib/components/ResourceEventStream/EventComponent.js +50 -0
- package/lib/components/ResourceEventStream/EventComponent.js.map +1 -0
- package/lib/components/ResourceEventStream/EventStream.d.ts +6 -0
- package/lib/components/ResourceEventStream/EventStream.d.ts.map +1 -0
- package/lib/components/ResourceEventStream/EventStream.js +174 -0
- package/lib/components/ResourceEventStream/EventStream.js.map +1 -0
- package/lib/components/ResourceEventStream/EventStreamList.d.ts +17 -0
- package/lib/components/ResourceEventStream/EventStreamList.d.ts.map +1 -0
- package/lib/components/ResourceEventStream/EventStreamList.js +82 -0
- package/lib/components/ResourceEventStream/EventStreamList.js.map +1 -0
- package/lib/components/ResourceEventStream/TogglePlay.d.ts +8 -0
- package/lib/components/ResourceEventStream/TogglePlay.d.ts.map +1 -0
- package/lib/components/ResourceEventStream/TogglePlay.js +15 -0
- package/lib/components/ResourceEventStream/TogglePlay.js.map +1 -0
- package/lib/components/ResourceEventStream/WithScrollContainer.d.ts +7 -0
- package/lib/components/ResourceEventStream/WithScrollContainer.d.ts.map +1 -0
- package/lib/components/ResourceEventStream/WithScrollContainer.js +41 -0
- package/lib/components/ResourceEventStream/WithScrollContainer.js.map +1 -0
- package/lib/components/ResourceEventStream/constants.d.ts +2 -0
- package/lib/components/ResourceEventStream/constants.d.ts.map +1 -0
- package/lib/components/ResourceEventStream/constants.js +6 -0
- package/lib/components/ResourceEventStream/constants.js.map +1 -0
- package/lib/components/ResourceEventStream/utils.d.ts +16 -0
- package/lib/components/ResourceEventStream/utils.d.ts.map +1 -0
- package/lib/components/ResourceEventStream/utils.js +133 -0
- package/lib/components/ResourceEventStream/utils.js.map +1 -0
- package/lib/components/index.d.ts +2 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/components/index.js +10 -0
- package/lib/components/index.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/internal/context/FleetSupportContext.d.ts +7 -0
- package/lib/internal/context/FleetSupportContext.d.ts.map +1 -0
- package/lib/internal/context/FleetSupportContext.js +7 -0
- package/lib/internal/context/FleetSupportContext.js.map +1 -0
- package/lib/internal/context/fleet-support.d.ts +1 -1
- package/lib/internal/context/fleet-support.d.ts.map +1 -1
- package/lib/internal/context/fleet-support.js.map +1 -1
- package/lib/internal/hooks/index.d.ts +1 -1
- package/lib/internal/hooks/index.d.ts.map +1 -1
- package/lib/internal/hooks/index.js +1 -1
- package/lib/internal/hooks/index.js.map +1 -1
- package/lib/internal/hooks/multicluster-sdk.js.map +1 -1
- package/lib/internal/hooks/useFleetSupport.d.ts +2 -0
- package/lib/internal/hooks/useFleetSupport.d.ts.map +1 -0
- package/lib/internal/hooks/useFleetSupport.js +10 -0
- package/lib/internal/hooks/useFleetSupport.js.map +1 -0
- package/lib/internal/types/multicluster-sdk.d.ts.map +1 -1
- package/lib/internal/types/multicluster-sdk.js.map +1 -1
- package/lib/internal/utils/should-use-fleet-support.d.ts +1 -1
- package/lib/internal/utils/should-use-fleet-support.d.ts.map +1 -1
- package/lib/internal/utils/should-use-fleet-support.js.map +1 -1
- package/lib/internal/utils/shouldUseFleetSupport.d.ts +3 -0
- package/lib/internal/utils/shouldUseFleetSupport.d.ts.map +1 -0
- package/lib/internal/utils/shouldUseFleetSupport.js +8 -0
- package/lib/internal/utils/shouldUseFleetSupport.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/fleet.d.ts +4 -3
- package/lib/types/fleet.d.ts.map +1 -1
- package/package.json +19 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Multicluster SDK for OpenShift Console
|
|
2
|
+
|
|
3
|
+
<!-- Copyright Contributors to the Open Cluster Management project -->
|
|
4
|
+
|
|
5
|
+
A React SDK for working with multicluster OpenShift/Kubernetes resources from the OpenShift Console.
|
|
6
|
+
|
|
7
|
+
This SDK provides extensions and APIs that dynamic plugins can use to leverage multicluster capabilities provided by Red Hat Advanced Cluster Management. It aims to provide similar functionality to the dynamic plugin(<https://www.npmjs.com/package/@openshift-console/dynamic-plugin-sdk>) SDK but for multicluster scenarios.
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
- Red Hat Advanced Cluster Management for Kubernetes 2.15+
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @stolostron/multicluster-sdk
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
The multicluster-sdk provides components and hooks that enable your dynamic plugins to work with resources across multiple clusters.
|
|
23
|
+
|
|
24
|
+
## Basic Setup
|
|
25
|
+
|
|
26
|
+
// Example code will be added after API stabilization
|
|
27
|
+
|
|
28
|
+
## Working with Resources
|
|
29
|
+
|
|
30
|
+
// Example code will be added after API stabilization
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## API Reference
|
|
34
|
+
|
|
35
|
+
### Components
|
|
36
|
+
|
|
37
|
+
- `<FleetResourceLink>`: Component for linking to the resource details page in ACM for a resource from a managed cluster, or to the OpenShift console resource page for a resource from the hub cluster
|
|
38
|
+
|
|
39
|
+
### Hooks
|
|
40
|
+
|
|
41
|
+
- `useFleetK8sWatchResource`: Watch Kubernetes resources across clusters
|
|
42
|
+
- `useFleetK8sAPIPath`: Get the API path for a specific cluster
|
|
43
|
+
- `useHubClusterName`: Get the name of the hub cluster
|
|
44
|
+
- `useFleetClusterNames`: Get the list of managed cluster names
|
|
45
|
+
|
|
46
|
+
### Utilities
|
|
47
|
+
|
|
48
|
+
- Fleet resource typing support through TypeScript interfaces
|
|
49
|
+
|
|
50
|
+
## Contributing
|
|
51
|
+
|
|
52
|
+
All contributions to the repository must be submitted under the terms of the [Apache Public License 2.0](https://www.apache.org/licenses/LICENSE-2.0). For contribution guidelines, see [CONTRIBUTING.md](https://github.com/stolostron/console/blob/main/CONTRIBUTING.md).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FleetResourceLink.d.ts","sourceRoot":"","sources":["../../src/api/FleetResourceLink.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAKvD,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA+D9D,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.FleetResourceLink = void 0;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
/* Copyright Contributors to the Open Cluster Management project */
|
|
20
|
+
const dynamic_plugin_sdk_1 = require("@openshift-console/dynamic-plugin-sdk");
|
|
21
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
22
|
+
const react_router_dom_v5_compat_1 = require("react-router-dom-v5-compat");
|
|
23
|
+
const searchPaths_1 = require("./utils/searchPaths");
|
|
24
|
+
const FleetResourceLink = (_a) => {
|
|
25
|
+
var { cluster } = _a, resourceLinkProps = __rest(_a, ["cluster"]);
|
|
26
|
+
if (cluster) {
|
|
27
|
+
const { className, displayName, inline = false, groupVersionKind, name, nameSuffix, namespace, hideIcon, title, children, dataTest, onClick, truncate, } = resourceLinkProps;
|
|
28
|
+
const value = displayName ? displayName : name;
|
|
29
|
+
const classes = (0, classnames_1.default)('co-resource-item', className || '', {
|
|
30
|
+
'co-resource-item--inline': inline,
|
|
31
|
+
'co-resource-item--truncate': truncate,
|
|
32
|
+
});
|
|
33
|
+
const path = (groupVersionKind === null || groupVersionKind === void 0 ? void 0 : groupVersionKind.kind) === 'VirtualMachine'
|
|
34
|
+
? `/multicloud/infrastructure/virtualmachines/${cluster}/${namespace}/${name}`
|
|
35
|
+
: (0, searchPaths_1.getURLSearchParam)({
|
|
36
|
+
cluster,
|
|
37
|
+
kind: groupVersionKind === null || groupVersionKind === void 0 ? void 0 : groupVersionKind.kind,
|
|
38
|
+
apigroup: groupVersionKind === null || groupVersionKind === void 0 ? void 0 : groupVersionKind.group,
|
|
39
|
+
apiversion: groupVersionKind === null || groupVersionKind === void 0 ? void 0 : groupVersionKind.version,
|
|
40
|
+
name,
|
|
41
|
+
namespace,
|
|
42
|
+
});
|
|
43
|
+
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] }));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return (0, jsx_runtime_1.jsx)(dynamic_plugin_sdk_1.ResourceLink, Object.assign({}, resourceLinkProps));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.FleetResourceLink = FleetResourceLink;
|
|
50
|
+
//# sourceMappingURL=FleetResourceLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FleetResourceLink.js","sourceRoot":"","sources":["../../src/api/FleetResourceLink.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,mEAAmE;AACnE,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;YACzC,CAAC,CAAC,8CAA8C,OAAO,IAAI,SAAS,IAAI,IAAI,EAAE;YAC9E,CAAC,CAAC,IAAA,+BAAiB,EAAC;gBAChB,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,CAAA;QAER,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 @@
|
|
|
1
|
+
{"version":3,"file":"FleetSupport.d.ts","sourceRoot":"","sources":["../../src/api/FleetSupport.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAA4C,MAAM,OAAO,CAAA;AAGlG,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAAC;IAAE,OAAO,EAAE,SAAS,CAAA;CAAE,CAAC,CAyBtE,CAAA;AAED,eAAO,MAAM,mBAAmB,eAE/B,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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.useIsFleetSupported = exports.FleetSupport = void 0;
|
|
13
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
14
|
+
/* Copyright Contributors to the Open Cluster Management project */
|
|
15
|
+
const dynamic_plugin_sdk_1 = require("@openshift-console/dynamic-plugin-sdk");
|
|
16
|
+
const internal_1 = require("../internal");
|
|
17
|
+
const react_1 = require("react");
|
|
18
|
+
const FleetSupportContext_1 = require("../internal/context/FleetSupportContext");
|
|
19
|
+
const FleetSupport = ({ children, loading }) => {
|
|
20
|
+
const [multiclusterSDKs, extensionsResolved] = (0, dynamic_plugin_sdk_1.useResolvedExtensions)(internal_1.isMulticlusterSDK);
|
|
21
|
+
const [hubClusterName, setHubClusterName] = (0, react_1.useState)();
|
|
22
|
+
const sdkProvider = (0, react_1.useMemo)(() => {
|
|
23
|
+
// TODO: Choose best compatible version
|
|
24
|
+
return extensionsResolved && multiclusterSDKs.length ? multiclusterSDKs[0].properties.sdkProvider : undefined;
|
|
25
|
+
}, [extensionsResolved, multiclusterSDKs]);
|
|
26
|
+
(0, react_1.useEffect)(() => {
|
|
27
|
+
function resolveHubClusterName() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
if (sdkProvider && !hubClusterName) {
|
|
30
|
+
setHubClusterName(yield sdkProvider.fetchHubClusterName());
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
resolveHubClusterName();
|
|
35
|
+
}, [sdkProvider, hubClusterName]);
|
|
36
|
+
const ready = (extensionsResolved && !sdkProvider) || hubClusterName;
|
|
37
|
+
const contextValue = (0, react_1.useMemo)(() => (sdkProvider && hubClusterName ? { sdkProvider, hubClusterName } : undefined), [sdkProvider, hubClusterName]);
|
|
38
|
+
return ready ? (0, jsx_runtime_1.jsx)(FleetSupportContext_1.FleetSupportContext.Provider, { value: contextValue, children: children }) : loading;
|
|
39
|
+
};
|
|
40
|
+
exports.FleetSupport = FleetSupport;
|
|
41
|
+
const useIsFleetSupported = () => {
|
|
42
|
+
return !!(0, react_1.useContext)(FleetSupportContext_1.FleetSupportContext);
|
|
43
|
+
};
|
|
44
|
+
exports.useIsFleetSupported = useIsFleetSupported;
|
|
45
|
+
//# sourceMappingURL=FleetSupport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FleetSupport.js","sourceRoot":"","sources":["../../src/api/FleetSupport.tsx"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mEAAmE;AACnE,8EAA6E;AAC7E,0CAA+C;AAC/C,iCAAkG;AAClG,iFAA6E;AAEtE,MAAM,YAAY,GAAkD,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;IACnG,MAAM,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,GAAG,IAAA,0CAAqB,EAAC,4BAAiB,CAAC,CAAA;IACvF,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,GAAU,CAAA;IAE9D,MAAM,WAAW,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QAC/B,uCAAuC;QACvC,OAAO,kBAAkB,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAA;IAC/G,CAAC,EAAE,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC,CAAA;IAE1C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,SAAe,qBAAqB;;gBAClC,IAAI,WAAW,IAAI,CAAC,cAAc,EAAE,CAAC;oBACnC,iBAAiB,CAAC,MAAM,WAAW,CAAC,mBAAmB,EAAE,CAAC,CAAA;gBAC5D,CAAC;YACH,CAAC;SAAA;QACD,qBAAqB,EAAE,CAAA;IACzB,CAAC,EAAE,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,CAAA;IAEjC,MAAM,KAAK,GAAG,CAAC,kBAAkB,IAAI,CAAC,WAAW,CAAC,IAAI,cAAc,CAAA;IACpE,MAAM,YAAY,GAAG,IAAA,eAAO,EAC1B,GAAG,EAAE,CAAC,CAAC,WAAW,IAAI,cAAc,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EACnF,CAAC,WAAW,EAAE,cAAc,CAAC,CAC9B,CAAA;IAED,OAAO,KAAK,CAAC,CAAC,CAAC,uBAAC,yCAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YAAG,QAAQ,GAAgC,CAAC,CAAC,CAAC,OAAO,CAAA;AACvH,CAAC,CAAA;AAzBY,QAAA,YAAY,gBAyBxB;AAEM,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,OAAO,CAAC,CAAC,IAAA,kBAAU,EAAC,yCAAmB,CAAC,CAAA;AAC1C,CAAC,CAAA;AAFY,QAAA,mBAAmB,uBAE/B"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { K8sModel, Patch, QueryParams, Selector } from '@openshift-console/dynamic-plugin-sdk';
|
|
2
|
+
export type BaseOptions = {
|
|
3
|
+
name?: string;
|
|
4
|
+
ns?: string;
|
|
5
|
+
path?: string;
|
|
6
|
+
cluster?: string;
|
|
7
|
+
queryParams?: QueryParams;
|
|
8
|
+
};
|
|
9
|
+
export type OptionsCreate<R extends K8sResourceCommon> = BaseOptions & {
|
|
10
|
+
model: K8sModel;
|
|
11
|
+
data: R;
|
|
12
|
+
};
|
|
13
|
+
export type OptionsGet = BaseOptions & {
|
|
14
|
+
model: K8sModel;
|
|
15
|
+
requestInit?: RequestInit;
|
|
16
|
+
};
|
|
17
|
+
export type OptionsUpdate<R extends K8sResourceCommon> = BaseOptions & {
|
|
18
|
+
model: K8sModel;
|
|
19
|
+
data: R;
|
|
20
|
+
};
|
|
21
|
+
export type OptionsPatch<R> = BaseOptions & {
|
|
22
|
+
model: K8sModel;
|
|
23
|
+
resource: R;
|
|
24
|
+
data: Patch[];
|
|
25
|
+
};
|
|
26
|
+
export type OptionsDelete<R> = BaseOptions & {
|
|
27
|
+
model: K8sModel;
|
|
28
|
+
resource: R;
|
|
29
|
+
requestInit?: RequestInit;
|
|
30
|
+
json?: Record<string, any>;
|
|
31
|
+
};
|
|
32
|
+
type GetResourceURL = (params: {
|
|
33
|
+
model: K8sModel;
|
|
34
|
+
ns?: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
cluster?: string;
|
|
37
|
+
queryParams?: QueryParams;
|
|
38
|
+
}) => Promise<string>;
|
|
39
|
+
export type Options = {
|
|
40
|
+
ns?: string;
|
|
41
|
+
name?: string;
|
|
42
|
+
path?: string;
|
|
43
|
+
queryParams?: QueryParams;
|
|
44
|
+
cluster?: string;
|
|
45
|
+
};
|
|
46
|
+
export declare const getResourcePath: (model: K8sModel, options: Options) => string;
|
|
47
|
+
export declare const buildResourceURL: (params: {
|
|
48
|
+
model: K8sModel;
|
|
49
|
+
ns?: string;
|
|
50
|
+
name?: string;
|
|
51
|
+
cluster?: string;
|
|
52
|
+
queryParams?: QueryParams;
|
|
53
|
+
basePath: string;
|
|
54
|
+
}) => string;
|
|
55
|
+
export declare const getResourceURL: GetResourceURL;
|
|
56
|
+
export declare function fleetK8sGet<R extends K8sResourceCommon>(options: OptionsGet): Promise<R>;
|
|
57
|
+
export declare function fleetUpdateResource<R extends K8sResourceCommon>(options: OptionsUpdate<R>): Promise<R>;
|
|
58
|
+
export declare function fleetK8sPatch<R extends K8sResourceCommon>(options: OptionsPatch<R>): Promise<R>;
|
|
59
|
+
export declare function fleetK8sCreate<R extends K8sResourceCommon>(options: OptionsCreate<R>): Promise<R>;
|
|
60
|
+
export declare function fleetK8sDelete<R extends K8sResourceCommon>(options: OptionsDelete<R>): Promise<R>;
|
|
61
|
+
export declare const fleetWatch: (model: K8sModel, query: {
|
|
62
|
+
labelSelector?: Selector;
|
|
63
|
+
resourceVersion?: string;
|
|
64
|
+
ns?: string;
|
|
65
|
+
fieldSelector?: string;
|
|
66
|
+
cluster?: string;
|
|
67
|
+
} | undefined, backendURL: string) => WebSocket;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=apiRequests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiRequests.d.ts","sourceRoot":"","sources":["../../src/api/apiRequests.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,188 @@
|
|
|
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.fleetWatch = exports.getResourceURL = exports.buildResourceURL = exports.getResourcePath = void 0;
|
|
13
|
+
exports.fleetK8sGet = fleetK8sGet;
|
|
14
|
+
exports.fleetUpdateResource = fleetUpdateResource;
|
|
15
|
+
exports.fleetK8sPatch = fleetK8sPatch;
|
|
16
|
+
exports.fleetK8sCreate = fleetK8sCreate;
|
|
17
|
+
exports.fleetK8sDelete = fleetK8sDelete;
|
|
18
|
+
/* Copyright Contributors to the Open Cluster Management project */
|
|
19
|
+
const dynamic_plugin_sdk_1 = require("@openshift-console/dynamic-plugin-sdk");
|
|
20
|
+
const requirements_1 = require("./utils/requirements");
|
|
21
|
+
const api_resource_list_1 = require("./utils/api-resource-list");
|
|
22
|
+
const constants_1 = require("./constants");
|
|
23
|
+
const commonHeaders = {
|
|
24
|
+
'Content-Type': 'application/json',
|
|
25
|
+
};
|
|
26
|
+
const getK8sAPIPath = ({ apiGroup = 'core', apiVersion }) => {
|
|
27
|
+
const isLegacy = apiGroup === 'core' && apiVersion === 'v1';
|
|
28
|
+
let p = isLegacy ? '/api/' : '/apis/';
|
|
29
|
+
if (!isLegacy && apiGroup) {
|
|
30
|
+
p += `${apiGroup}/`;
|
|
31
|
+
}
|
|
32
|
+
p += apiVersion;
|
|
33
|
+
return p;
|
|
34
|
+
};
|
|
35
|
+
const getResourcePath = (model, options) => {
|
|
36
|
+
let url = getK8sAPIPath(model);
|
|
37
|
+
if (options.ns) {
|
|
38
|
+
url += `/namespaces/${options.ns}`;
|
|
39
|
+
}
|
|
40
|
+
url += `/${model.plural}`;
|
|
41
|
+
if (options.name) {
|
|
42
|
+
// Some resources like Users can have special characters in the name.
|
|
43
|
+
url += `/${encodeURIComponent(options.name)}`;
|
|
44
|
+
}
|
|
45
|
+
if (options.path) {
|
|
46
|
+
url += `/${options.path}`;
|
|
47
|
+
}
|
|
48
|
+
if (Object.keys((options === null || options === void 0 ? void 0 : options.queryParams) || {}).length > 0) {
|
|
49
|
+
const queryString = new URLSearchParams(options.queryParams).toString();
|
|
50
|
+
url += `?${queryString}`;
|
|
51
|
+
}
|
|
52
|
+
return url;
|
|
53
|
+
};
|
|
54
|
+
exports.getResourcePath = getResourcePath;
|
|
55
|
+
const buildResourceURL = (params) => {
|
|
56
|
+
const { model, ns, name, cluster, queryParams, basePath = constants_1.BASE_K8S_API_PATH } = params;
|
|
57
|
+
const resourcePath = (0, exports.getResourcePath)(model, { ns, name, queryParams, cluster });
|
|
58
|
+
return `${basePath}${resourcePath}`;
|
|
59
|
+
};
|
|
60
|
+
exports.buildResourceURL = buildResourceURL;
|
|
61
|
+
const getResourceURL = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
+
const backendURL = yield (0, api_resource_list_1.getBackendUrl)();
|
|
63
|
+
return (0, exports.buildResourceURL)(Object.assign(Object.assign({}, params), { basePath: backendURL }));
|
|
64
|
+
});
|
|
65
|
+
exports.getResourceURL = getResourceURL;
|
|
66
|
+
function fleetK8sGet(options) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const { model, name, ns, cluster } = options;
|
|
69
|
+
if (cluster === undefined) {
|
|
70
|
+
return (0, dynamic_plugin_sdk_1.k8sGet)(options);
|
|
71
|
+
}
|
|
72
|
+
const requestPath = yield (0, exports.getResourceURL)({ model, ns, name, cluster, queryParams: options.queryParams });
|
|
73
|
+
return (0, dynamic_plugin_sdk_1.consoleFetchJSON)(requestPath, 'GET');
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function fleetUpdateResource(options) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
var _a, _b;
|
|
79
|
+
const { model, name, ns, data } = options;
|
|
80
|
+
const cluster = options.cluster || data.cluster;
|
|
81
|
+
if (cluster === undefined) {
|
|
82
|
+
return (0, dynamic_plugin_sdk_1.k8sUpdate)(options);
|
|
83
|
+
}
|
|
84
|
+
const requestPath = yield (0, exports.getResourceURL)({
|
|
85
|
+
model,
|
|
86
|
+
ns: ((_a = data === null || data === void 0 ? void 0 : data.metadata) === null || _a === void 0 ? void 0 : _a.namespace) || ns,
|
|
87
|
+
name: ((_b = data === null || data === void 0 ? void 0 : data.metadata) === null || _b === void 0 ? void 0 : _b.name) || name,
|
|
88
|
+
cluster: cluster,
|
|
89
|
+
queryParams: options.queryParams,
|
|
90
|
+
});
|
|
91
|
+
return (0, dynamic_plugin_sdk_1.consoleFetchJSON)(requestPath, 'PUT');
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function fleetK8sPatch(options) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
var _a, _b;
|
|
97
|
+
const { resource, model, ns, name } = options !== null && options !== void 0 ? options : {};
|
|
98
|
+
const cluster = options.cluster || resource.cluster;
|
|
99
|
+
if (cluster === undefined) {
|
|
100
|
+
return (0, dynamic_plugin_sdk_1.k8sPatch)(options);
|
|
101
|
+
}
|
|
102
|
+
const headers = {};
|
|
103
|
+
if (Array.isArray(options.data)) {
|
|
104
|
+
headers['Content-Type'] = 'application/json-patch+json';
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
headers['Content-Type'] = 'application/merge-patch+json';
|
|
108
|
+
}
|
|
109
|
+
const requestPath = yield (0, exports.getResourceURL)({
|
|
110
|
+
model,
|
|
111
|
+
ns: ((_a = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _a === void 0 ? void 0 : _a.namespace) || ns,
|
|
112
|
+
name: ((_b = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _b === void 0 ? void 0 : _b.name) || name,
|
|
113
|
+
cluster,
|
|
114
|
+
queryParams: options.queryParams,
|
|
115
|
+
});
|
|
116
|
+
return (0, dynamic_plugin_sdk_1.consoleFetchJSON)(requestPath, 'PATCH', { body: JSON.stringify(options.data), headers });
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function fleetK8sCreate(options) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
var _a, _b;
|
|
122
|
+
const { data, model, ns, name } = options;
|
|
123
|
+
const cluster = options.cluster || data.cluster;
|
|
124
|
+
if (cluster === undefined) {
|
|
125
|
+
return (0, dynamic_plugin_sdk_1.k8sCreate)(options);
|
|
126
|
+
}
|
|
127
|
+
const requestPath = yield (0, exports.getResourceURL)({
|
|
128
|
+
model,
|
|
129
|
+
ns: ((_a = data === null || data === void 0 ? void 0 : data.metadata) === null || _a === void 0 ? void 0 : _a.namespace) || ns,
|
|
130
|
+
name: ((_b = data.metadata) === null || _b === void 0 ? void 0 : _b.name) || name,
|
|
131
|
+
cluster,
|
|
132
|
+
queryParams: options.queryParams,
|
|
133
|
+
});
|
|
134
|
+
return (0, dynamic_plugin_sdk_1.consoleFetchJSON)(requestPath, 'POST', {
|
|
135
|
+
body: JSON.stringify(data),
|
|
136
|
+
headers: commonHeaders,
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function fleetK8sDelete(options) {
|
|
141
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
var _a, _b;
|
|
143
|
+
const { model, name, ns, json, resource } = options;
|
|
144
|
+
const cluster = (resource === null || resource === void 0 ? void 0 : resource.cluster) || (options === null || options === void 0 ? void 0 : options.cluster);
|
|
145
|
+
if (cluster === undefined) {
|
|
146
|
+
return (0, dynamic_plugin_sdk_1.k8sDelete)(options);
|
|
147
|
+
}
|
|
148
|
+
const { propagationPolicy } = model;
|
|
149
|
+
const jsonData = json !== null && json !== void 0 ? json : (propagationPolicy && { kind: 'DeleteOptions', apiVersion: 'v1', propagationPolicy });
|
|
150
|
+
const requestPath = yield (0, exports.getResourceURL)({
|
|
151
|
+
model,
|
|
152
|
+
ns: ns || ((_a = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _a === void 0 ? void 0 : _a.namespace),
|
|
153
|
+
name: name || ((_b = resource === null || resource === void 0 ? void 0 : resource.metadata) === null || _b === void 0 ? void 0 : _b.name),
|
|
154
|
+
cluster,
|
|
155
|
+
queryParams: options === null || options === void 0 ? void 0 : options.queryParams,
|
|
156
|
+
});
|
|
157
|
+
return (0, dynamic_plugin_sdk_1.consoleFetchJSON)(requestPath, 'DELETE', {
|
|
158
|
+
headers: commonHeaders,
|
|
159
|
+
body: JSON.stringify(jsonData),
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
const fleetWatch = (model, query = {}, backendURL) => {
|
|
164
|
+
const queryParams = { watch: 'true' };
|
|
165
|
+
const { labelSelector } = query;
|
|
166
|
+
if (labelSelector) {
|
|
167
|
+
const encodedSelector = (0, requirements_1.selectorToString)(labelSelector);
|
|
168
|
+
if (encodedSelector) {
|
|
169
|
+
queryParams.labelSelector = encodedSelector;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (query.fieldSelector) {
|
|
173
|
+
queryParams.fieldSelector = query.fieldSelector;
|
|
174
|
+
}
|
|
175
|
+
if (query.resourceVersion) {
|
|
176
|
+
queryParams.resourceVersion = query.resourceVersion;
|
|
177
|
+
}
|
|
178
|
+
const requestPath = (0, exports.buildResourceURL)({
|
|
179
|
+
model,
|
|
180
|
+
cluster: query.cluster,
|
|
181
|
+
queryParams,
|
|
182
|
+
ns: query.ns,
|
|
183
|
+
basePath: backendURL,
|
|
184
|
+
});
|
|
185
|
+
return new WebSocket(requestPath);
|
|
186
|
+
};
|
|
187
|
+
exports.fleetWatch = fleetWatch;
|
|
188
|
+
//# sourceMappingURL=apiRequests.js.map
|