Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions packages/api/src/kubernetes-dashboard-extension-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,76 @@
* SPDX-License-Identifier: Apache-2.0
***********************************************************************/

import type { Disposable } from '@podman-desktop/api';

export interface ContextHealth {
contextName: string;
// is the health of the cluster being checked?
checking: boolean;
// was the health check successful?
reachable: boolean;
// is one of the informers marked offline (disconnect after being connected, the cache still being populated)
offline: boolean;
// description in case of error (other than health check)
// currently detected errors:
// - user.exec.command not found
errorMessage?: string;
}

export interface ContextsHealthsInfo {
healths: ContextHealth[];
}

export interface ContextPermission {
contextName: string;
// the resource name is a generic string type and not a string literal type, as we want to handle CRDs names
resourceName: string;
// permitted if allowed and not denied
// > When multiple authorization modules are configured, each is checked in sequence.
// > If any authorizer approves or denies a request, that decision is immediately returned
// > and no other authorizer is consulted. If all modules have no opinion on the request,
// > then the request is denied. An overall deny verdict means that the API server rejects
// > the request and responds with an HTTP 403 (Forbidden) status.
// (source: https://kubernetes.io/docs/reference/access-authn-authz/authorization/)
permitted: boolean;
// A free-form and optional text reason for the resource being allowed or denied.
// We cannot rely on having a reason for every request.
// For exemple on Kind cluster, a reason is given only when the access is allowed, no reason is done for denial.
reason?: string;
}

export interface ContextsPermissionsInfo {
permissions: ContextPermission[];
}

export interface AvailableContextsInfo {
contextNames: string[];
}

export interface CurrentContextInfo {
contextName?: string;
namespace?: string;
}

export interface ResourceCount {
contextName: string;
resourceName: string;
count: number;
}

export interface ResourcesCountInfo {
counts: ResourceCount[];
}

/**
* The subscriber for the events emitted by the Kubernetes Dashboard extension.
*/
export interface KubernetesDashboardSubscriber {
onContextsHealth(listener: (event: ContextsHealthsInfo) => void): Disposable;
onContextsPermissions(listener: (event: ContextsPermissionsInfo) => void): Disposable;
onAvailableContexts(listener: (event: AvailableContextsInfo) => void): Disposable;
onCurrentContext(listener: (event: CurrentContextInfo) => void): Disposable;
onResourcesCount(listener: (event: ResourcesCountInfo) => void): Disposable;
/**
* Disposes the subscriber and unsubscribes from all the events emitted by the Kubernetes Dashboard extension.
*/
Expand Down
12 changes: 7 additions & 5 deletions packages/channels/src/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,22 @@ import type { PortForwardApi } from './interface/port-forward-api';
import type { SubscribeApi } from './interface/subscribe-api';
import type { SystemApi } from './interface/system-api';
import type { ActiveResourcesCountInfo } from './model/active-resources-count-info';
import type { AvailableContextsInfo } from './model/available-contexts-info';
import type { ContextsHealthsInfo } from './model/contexts-healths-info';
import type { ContextsPermissionsInfo } from './model/contexts-permissions-info';
import type { CurrentContextInfo } from './model/current-context-info';
import type { EndpointsInfo } from './model/endpoints-info';
import type { KubernetesProvidersInfo } from './model/kubernetes-providers-info';
import type { PodLogsChunk } from './model/pod-logs-chunk';
import type { PodTerminalChunk } from './model/pod-terminal-chunk';
import type { PortForwardsInfo } from './model/port-forward-info';
import type { ResourceDetailsInfo } from './model/resource-details-info';
import type { ResourceEventsInfo } from './model/resource-events-info';
import type { ResourcesCountInfo } from './model/resources-count-info';
import type { UpdateResourceInfo } from './model/update-resource-info';
import { createRpcChannel } from '@kubernetes-dashboard/rpc';
import type {
AvailableContextsInfo,
ContextsHealthsInfo,
ContextsPermissionsInfo,
CurrentContextInfo,
ResourcesCountInfo,
} from '@podman-desktop/kubernetes-dashboard-extension-api';

// RPC channels (used by the webview to send requests to the extension)
export const API_CONTEXTS = createRpcChannel<ContextsApi>('ContextsApi');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* SPDX-License-Identifier: Apache-2.0
***********************************************************************/

import type { ResourceCount } from './kubernetes-resource-count';
import type { ResourceCount } from '@podman-desktop/kubernetes-dashboard-extension-api';

export interface ActiveResourcesCountInfo {
counts: ResourceCount[];
Expand Down
21 changes: 0 additions & 21 deletions packages/channels/src/model/available-contexts-info.ts

This file was deleted.

23 changes: 0 additions & 23 deletions packages/channels/src/model/contexts-healths-info.ts

This file was deleted.

23 changes: 0 additions & 23 deletions packages/channels/src/model/contexts-permissions-info.ts

This file was deleted.

22 changes: 0 additions & 22 deletions packages/channels/src/model/current-context-info.ts

This file was deleted.

8 changes: 0 additions & 8 deletions packages/channels/src/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,13 @@
***********************************************************************/

export * from './active-resources-count-info';
export * from './available-contexts-info';
export * from './context-resource-events';
export * from './context-resources-details';
export * from './context-resources-items';
export * from './contexts-healths-info';
export * from './contexts-permissions-info';
export * from './current-context-info';
export * from './endpoint';
export * from './endpoints-info';
export * from './endpoints-options';
export * from './kubernetes-contexts-healths';
export * from './kubernetes-contexts-permissions';
export * from './kubernetes-providers-info';
export * from './kubernetes-resource-count';
export * from './kubernetes-troubleshooting';
export * from './openshift-types';
export * from './pod-logs-chunk';
Expand All @@ -41,7 +34,6 @@ export * from './resource-details-info';
export * from './resource-details-options';
export * from './resource-events-info';
export * from './resource-events-options';
export * from './resources-count-info';
export * from './target-ref';
export * from './update-resource-info';
export * from './update-resource-options';
31 changes: 0 additions & 31 deletions packages/channels/src/model/kubernetes-contexts-healths.ts

This file was deleted.

35 changes: 0 additions & 35 deletions packages/channels/src/model/kubernetes-contexts-permissions.ts

This file was deleted.

23 changes: 0 additions & 23 deletions packages/channels/src/model/kubernetes-resource-count.ts

This file was deleted.

23 changes: 0 additions & 23 deletions packages/channels/src/model/resources-count-info.ts

This file was deleted.

Loading