|
| 1 | +/********************************************************************** |
| 2 | + * Copyright (C) 2025 Red Hat, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * |
| 16 | + * SPDX-License-Identifier: Apache-2.0 |
| 17 | + ***********************************************************************/ |
| 18 | + |
| 19 | +import { inject, injectable } from 'inversify'; |
| 20 | +import type { DispatcherObject } from './util/dispatcher-object'; |
| 21 | +import { AbsDispatcherObjectImpl } from './util/dispatcher-object'; |
| 22 | +import { ContextsManager } from '/@/manager/contexts-manager'; |
| 23 | +import { KubernetesProvidersInfo } from '@kubernetes-dashboard/channels/dist/model/kubernetes-providers-info'; |
| 24 | +import { RpcExtension } from '@kubernetes-dashboard/rpc'; |
| 25 | +import { KUBERNETES_PROVIDERS } from '@kubernetes-dashboard/channels'; |
| 26 | +import { KubernetesProvidersManager } from '/@/manager/kubernetes-providers'; |
| 27 | + |
| 28 | +@injectable() |
| 29 | +export class KubernetesProvidersDispatcher |
| 30 | + extends AbsDispatcherObjectImpl<void, KubernetesProvidersInfo> |
| 31 | + implements DispatcherObject<void> |
| 32 | +{ |
| 33 | + constructor( |
| 34 | + @inject(RpcExtension) rpcExtension: RpcExtension, |
| 35 | + @inject(ContextsManager) private manager: ContextsManager, |
| 36 | + @inject(KubernetesProvidersManager) private kubernetesProvidersManager: KubernetesProvidersManager, |
| 37 | + ) { |
| 38 | + super(rpcExtension, KUBERNETES_PROVIDERS); |
| 39 | + } |
| 40 | + |
| 41 | + getData(): KubernetesProvidersInfo { |
| 42 | + return { |
| 43 | + providers: this.kubernetesProvidersManager.getKubernetesProviders(), |
| 44 | + }; |
| 45 | + } |
| 46 | +} |
0 commit comments