Skip to content

Commit

Permalink
refactor(main): group kubernetes logic (#8735)
Browse files Browse the repository at this point in the history
Signed-off-by: axel7083 <[email protected]>
  • Loading branch information
axel7083 authored Sep 5, 2024
1 parent 2d71a69 commit 4c147ed
Show file tree
Hide file tree
Showing 22 changed files with 48 additions and 42 deletions.
2 changes: 1 addition & 1 deletion packages/main/src/plugin/api/KubernetesGeneratorInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* SPDX-License-Identifier: Apache-2.0
***********************************************************************/
import type { KubernetesGeneratorSelector } from '../kube-generator-registry.js';
import type { KubernetesGeneratorSelector } from '../kubernetes/kube-generator-registry.js';

export interface KubernetesGeneratorInfo {
id: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/main/src/plugin/extension-loader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { app } from 'electron';
import { beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';

import type { ContributionManager } from '/@/plugin/contribution-manager.js';
import type { KubeGeneratorRegistry } from '/@/plugin/kube-generator-registry.js';
import type { KubeGeneratorRegistry } from '/@/plugin/kubernetes/kube-generator-registry.js';
import { NavigationManager } from '/@/plugin/navigation/navigation-manager.js';
import type { WebviewRegistry } from '/@/plugin/webview/webview-registry.js';
import type { ContributionInfo } from '/@api/contribution-info.js';
Expand All @@ -54,7 +54,7 @@ import type { ImageCheckerImpl } from './image-checker.js';
import type { ImageFilesRegistry } from './image-files-registry.js';
import type { ImageRegistry } from './image-registry.js';
import type { InputQuickPickRegistry } from './input-quickpick/input-quickpick-registry.js';
import type { KubernetesClient } from './kubernetes-client.js';
import type { KubernetesClient } from './kubernetes/kubernetes-client.js';
import type { MenuRegistry } from './menu-registry.js';
import type { MessageBox } from './message-box.js';
import type { OnboardingRegistry } from './onboarding-registry.js';
Expand Down
7 changes: 5 additions & 2 deletions packages/main/src/plugin/extension-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import AdmZip from 'adm-zip';
import { app, clipboard as electronClipboard } from 'electron';

import type { ColorRegistry } from '/@/plugin/color-registry.js';
import type { KubeGeneratorRegistry, KubernetesGeneratorProvider } from '/@/plugin/kube-generator-registry.js';
import type {
KubeGeneratorRegistry,
KubernetesGeneratorProvider,
} from '/@/plugin/kubernetes/kube-generator-registry.js';
import type { MenuRegistry } from '/@/plugin/menu-registry.js';
import type { NavigationManager } from '/@/plugin/navigation/navigation-manager.js';
import type { WebviewRegistry } from '/@/plugin/webview/webview-registry.js';
Expand Down Expand Up @@ -56,7 +59,7 @@ import type { ImageFilesRegistry } from './image-files-registry.js';
import type { ImageRegistry } from './image-registry.js';
import type { InputQuickPickRegistry } from './input-quickpick/input-quickpick-registry.js';
import { InputBoxValidationSeverity, QuickPickItemKind } from './input-quickpick/input-quickpick-registry.js';
import type { KubernetesClient } from './kubernetes-client.js';
import type { KubernetesClient } from './kubernetes/kubernetes-client.js';
import type { MessageBox } from './message-box.js';
import { ModuleLoader } from './module-loader.js';
import type { OnboardingRegistry } from './onboarding-registry.js';
Expand Down
8 changes: 4 additions & 4 deletions packages/main/src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ import type {
GenerateKubeResult,
KubernetesGeneratorArgument,
KubernetesGeneratorSelector,
} from '/@/plugin/kube-generator-registry.js';
import { KubeGeneratorRegistry } from '/@/plugin/kube-generator-registry.js';
} from '/@/plugin/kubernetes/kube-generator-registry.js';
import { KubeGeneratorRegistry } from '/@/plugin/kubernetes/kube-generator-registry.js';
import type { Menu } from '/@/plugin/menu-registry.js';
import { MenuRegistry } from '/@/plugin/menu-registry.js';
import { NavigationManager } from '/@/plugin/navigation/navigation-manager.js';
Expand Down Expand Up @@ -147,8 +147,8 @@ import { ImageFilesRegistry } from './image-files-registry.js';
import { ImageRegistry } from './image-registry.js';
import { InputQuickPickRegistry } from './input-quickpick/input-quickpick-registry.js';
import { ExtensionInstaller } from './install/extension-installer.js';
import { KubernetesClient } from './kubernetes-client.js';
import type { ContextGeneralState, ResourceName } from './kubernetes-context-state.js';
import { KubernetesClient } from './kubernetes/kubernetes-client.js';
import type { ContextGeneralState, ResourceName } from './kubernetes/kubernetes-context-state.js';
import { downloadGuideList } from './learning-center/learning-center.js';
import { LibpodApiInit } from './libpod-api-enable/libpod-api-init.js';
import type { MessageBoxOptions, MessageBoxReturnValue } from './message-box.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import { expect, test, vi } from 'vitest';

import type { KubernetesGeneratorSelector } from '/@/plugin/kube-generator-registry.js';
import { KubeGeneratorRegistry } from '/@/plugin/kube-generator-registry.js';
import type { KubernetesGeneratorSelector } from './kube-generator-registry.js';
import { KubeGeneratorRegistry } from './kube-generator-registry.js';

test('Creating KubeGeneratorRegistry and getting KubeGeneratorsInfos', async () => {
const result = new KubeGeneratorRegistry().getKubeGeneratorsInfos();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*
* SPDX-License-Identifier: Apache-2.0
***********************************************************************/
import type { KubernetesGeneratorInfo } from './api/KubernetesGeneratorInfo.js';
import { Disposable } from './types/disposable.js';
import type { KubernetesGeneratorInfo } from '../api/KubernetesGeneratorInfo.js';
import { Disposable } from '../types/disposable.js';

export type KubernetesGeneratorType = 'Compose' | 'Pod' | 'Container';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import type { Cluster, Context, KubeConfig, User } from '@kubernetes/client-node';
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';

import type { ApiSenderType } from './api.js';
import type { ConfigurationRegistry } from './configuration-registry.js';
import { FilesystemMonitoring } from './filesystem-monitoring.js';
import type { ApiSenderType } from '../api.js';
import type { ConfigurationRegistry } from '../configuration-registry.js';
import { FilesystemMonitoring } from '../filesystem-monitoring.js';
import type { Telemetry } from '../telemetry/telemetry.js';
import { KubernetesClient } from './kubernetes-client.js';
import type { Telemetry } from './telemetry/telemetry.js';

// WARNING: Do not import anything from kubernetes-client.spec.ts
// or it will execute the modules mocks from there, incompatibles with tests in this file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ import * as clientNode from '@kubernetes/client-node';
import type { FileSystemWatcher } from '@podman-desktop/api';
import { beforeAll, beforeEach, describe, expect, type Mock, test, vi } from 'vitest';

import { ResizableTerminalWriter } from '/@/plugin/kubernetes-exec-transmitter.js';
import type { Telemetry } from '/@/plugin/telemetry/telemetry.js';
import type { V1Route } from '/@api/openshift-types.js';

import type { ApiSenderType } from './api.js';
import type { ConfigurationRegistry } from './configuration-registry.js';
import { FilesystemMonitoring } from './filesystem-monitoring.js';
import type { ApiSenderType } from '../api.js';
import type { ConfigurationRegistry } from '../configuration-registry.js';
import { FilesystemMonitoring } from '../filesystem-monitoring.js';
import type { Telemetry } from '../telemetry/telemetry.js';
import type { PodCreationSource, ScalableControllerType } from './kubernetes-client.js';
import { KubernetesClient } from './kubernetes-client.js';
import { ResizableTerminalWriter } from './kubernetes-exec-transmitter.js';

const configurationRegistry: ConfigurationRegistry = {} as unknown as ConfigurationRegistry;
const fileSystemMonitoring: FilesystemMonitoring = new FilesystemMonitoring();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,19 @@ import type * as containerDesktopAPI from '@podman-desktop/api';
import * as jsYaml from 'js-yaml';
import { parseAllDocuments } from 'yaml';

import type { Telemetry } from '/@/plugin/telemetry/telemetry.js';
import type { KubeContext } from '/@api/kubernetes-context.js';
import type { V1Route } from '/@api/openshift-types.js';

import type { ApiSenderType } from './api.js';
import type { PodInfo } from './api/pod-info.js';
import type { ConfigurationRegistry, IConfigurationNode } from './configuration-registry.js';
import { Emitter } from './events/emitter.js';
import type { FilesystemMonitoring } from './filesystem-monitoring.js';
import type { ApiSenderType } from '../api.js';
import type { PodInfo } from '../api/pod-info.js';
import type { ConfigurationRegistry, IConfigurationNode } from '../configuration-registry.js';
import { Emitter } from '../events/emitter.js';
import type { FilesystemMonitoring } from '../filesystem-monitoring.js';
import type { Telemetry } from '../telemetry/telemetry.js';
import { Uri } from '../types/uri.js';
import type { ContextGeneralState, ResourceName } from './kubernetes-context-state.js';
import { ContextsManager } from './kubernetes-context-state.js';
import { BufferedStreamWriter, ResizableTerminalWriter, StringLineReader } from './kubernetes-exec-transmitter.js';
import { Uri } from './types/uri.js';

interface KubernetesObjectWithKind extends KubernetesObject {
kind: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from 'vi

import type { KubeContext } from '/@api/kubernetes-context.js';

import type { ApiSenderType } from './api.js';
import type { ApiSenderType } from '../api.js';
import type { CheckingState, ContextGeneralState, ResourceName } from './kubernetes-context-state.js';
import { ContextsManager, ContextsStates } from './kubernetes-context-state.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import {
import type { KubeContext } from '/@api/kubernetes-context.js';
import type { V1Route } from '/@api/openshift-types.js';

import type { ApiSenderType } from './api.js';
import type { ApiSenderType } from '../api.js';
import {
backoffInitialValue,
backoffJitter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

import { expect, test } from 'vitest';

import type { TerminalSize } from '/@/plugin/kubernetes-exec-transmitter.js';
import type { TerminalSize } from './kubernetes-exec-transmitter.js';
import {
BufferedStreamWriter,
DEFAULT_COLUMNS,
DEFAULT_ROWS,
ResizableTerminalWriter,
StringLineReader,
} from '/@/plugin/kubernetes-exec-transmitter.js';
} from './kubernetes-exec-transmitter.js';

test('Test should verify string line reader', () => {
const reader = new StringLineReader();
Expand Down
4 changes: 2 additions & 2 deletions packages/preload/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ import type {
GenerateKubeResult,
KubernetesGeneratorArgument,
KubernetesGeneratorSelector,
} from '../../main/src/plugin/kube-generator-registry';
import type { ContextGeneralState, ResourceName } from '../../main/src/plugin/kubernetes-context-state.js';
} from '../../main/src/plugin/kubernetes/kube-generator-registry';
import type { ContextGeneralState, ResourceName } from '../../main/src/plugin/kubernetes/kubernetes-context-state';
import type { Guide } from '../../main/src/plugin/learning-center/learning-center-api';
import type { Menu } from '../../main/src/plugin/menu-registry';
import type { MessageBoxOptions, MessageBoxReturnValue } from '../../main/src/plugin/message-box';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { beforeEach, expect, test, vi } from 'vitest';
import * as kubeContextStore from '/@/stores/kubernetes-contexts-state';
import type { V1Route } from '/@api/openshift-types';

import type { ContextGeneralState } from '../../../../main/src/plugin/kubernetes-context-state';
import type { ContextGeneralState } from '../../../../main/src/plugin/kubernetes/kubernetes-context-state';
import IngressesRoutesList from './IngressesRoutesList.svelte';

vi.mock('/@/stores/kubernetes-contexts-state', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/lib/node/NodeEmptyScreen.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import '@testing-library/jest-dom/vitest';
import { render, screen } from '@testing-library/svelte';
import { beforeEach, expect, test, vi } from 'vitest';

import type { ContextGeneralState } from '../../../../main/src/plugin/kubernetes-context-state';
import type { ContextGeneralState } from '../../../../main/src/plugin/kubernetes/kubernetes-context-state';
import NodeEmptyScreen from './NodeEmptyScreen.svelte';

const mocks = vi.hoisted(() => ({
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/lib/node/NodeEmptyScreen.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { EmptyScreen } from '@podman-desktop/ui-svelte';
import { kubernetesCurrentContextState } from '/@/stores/kubernetes-contexts-state';
import type { ContextGeneralState } from '../../../../main/src/plugin/kubernetes-context-state';
import type { ContextGeneralState } from '../../../../main/src/plugin/kubernetes/kubernetes-context-state';
import NodeIcon from '../images/NodeIcon.svelte';
// If the current context is CONNECTED and we are on this empty screen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ import { kubernetesContexts } from '/@/stores/kubernetes-contexts';
import * as kubernetesContextsState from '/@/stores/kubernetes-contexts-state';
import type { KubeContext } from '/@api/kubernetes-context';

import type { CheckingState, ContextGeneralState } from '../../../../main/src/plugin/kubernetes-context-state';
import type {
CheckingState,
ContextGeneralState,
} from '../../../../main/src/plugin/kubernetes/kubernetes-context-state';
import PreferencesKubernetesContextsRendering from './PreferencesKubernetesContextsRendering.svelte';

vi.mock('/@/stores/kubernetes-contexts-state', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { beforeEach, expect, test, vi } from 'vitest';

import KubernetesCurrentContextConnectionBadge from '/@/lib/ui/KubernetesCurrentContextConnectionBadge.svelte';

import type { ContextGeneralState } from '../../../../main/src/plugin/kubernetes-context-state';
import type { ContextGeneralState } from '../../../../main/src/plugin/kubernetes/kubernetes-context-state';

const mocks = vi.hoisted(() => ({
subscribeMock: vi.fn(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { kubernetesCurrentContextState } from '/@/stores/kubernetes-contexts-state';
import type { ContextGeneralState } from '../../../../main/src/plugin/kubernetes-context-state';
import type { ContextGeneralState } from '../../../../main/src/plugin/kubernetes/kubernetes-context-state';
import Label from './Label.svelte';
function getText(state?: ContextGeneralState): string {
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/stores/kubernetes-contexts-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import type { KubernetesObject } from '@kubernetes/client-node';
import { derived, readable, writable } from 'svelte/store';

import type { CheckingState, ContextGeneralState } from '../../../main/src/plugin/kubernetes-context-state';
import type { CheckingState, ContextGeneralState } from '../../../main/src/plugin/kubernetes/kubernetes-context-state';
import { findMatchInLeaves } from './search-util';

export const kubernetesContextsCheckingState = readable(new Map<string, CheckingState>(), set => {
Expand Down

0 comments on commit 4c147ed

Please sign in to comment.