Skip to content

Commit

Permalink
cleanup after reviewing
Browse files Browse the repository at this point in the history
Signed-off-by: Jeromy Cannon <[email protected]>
  • Loading branch information
jeromy-cannon committed Feb 11, 2025
1 parent 8325ce8 commit 7e3f608
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/commands/node/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {type NetworkNodeServices} from '../../core/network_node_services.js';
import {type NodeAddConfigClass} from './node_add_config.js';
import {type NamespaceName} from '../../core/kube/resources/namespace/namespace_name.js';
import {type PodRef} from '../../core/kube/resources/pod/pod_ref.js';
import {type K8Factory} from '../../core/kube/k8_factory.js';

export const PREPARE_UPGRADE_CONFIGS_NAME = 'prepareUpgradeConfig';
export const DOWNLOAD_GENERATED_FILES_CONFIGS_NAME = 'downloadGeneratedFilesConfig';
Expand All @@ -29,7 +30,7 @@ export const KEYS_CONFIGS_NAME = 'keyConfigs';
export const SETUP_CONFIGS_NAME = 'setupConfigs';
export const START_CONFIGS_NAME = 'startConfigs';

const initializeSetup = async (config, k8Factory) => {
const initializeSetup = async (config: any, k8Factory: K8Factory) => {
// compute other config parameters
config.keysDir = path.join(validatePath(config.cacheDir), 'keys');
config.stagingDir = Templates.renderStagingDir(config.cacheDir, config.releaseTag);
Expand Down
1 change: 1 addition & 0 deletions src/commands/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class NodeCommand extends BaseCommand {
await this.accountManager.close();
if (this._portForwards) {
for (const srv of this._portForwards) {
// pass null to readByRef because it isn't needed for stopPortForward()
await this.k8Factory.default().pods().readByRef(null).stopPortForward(srv);
}
}
Expand Down
12 changes: 2 additions & 10 deletions src/core/kube/k8_client/k8_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
*/
import * as k8s from '@kubernetes/client-node';
import {SoloError} from '../../errors.js';
import {type ConfigManager} from '../../config_manager.js';
import {type SoloLogger} from '../../logging.js';
import {container} from 'tsyringe-neo';
import {type K8} from '../k8.js';
import {type Namespaces} from '../resources/namespace/namespaces.js';
import {K8ClientClusters} from '../k8_client/resources/cluster/k8_client_clusters.js';
Expand All @@ -15,6 +12,7 @@ import {K8ClientConfigMaps} from '../k8_client/resources/config_map/k8_client_co
import {K8ClientContainers} from '../k8_client/resources/container/k8_client_containers.js';
import {type Containers} from '../resources/container/containers.js';
import {type Contexts} from '../resources/context/contexts.js';
import {K8ClientContexts} from '../k8_client/resources/context/k8_client_contexts.js';
import {K8ClientPods} from '../k8_client/resources/pod/k8_client_pods.js';
import {type Pods} from '../resources/pod/pods.js';
import {type Services} from '../resources/service/services.js';
Expand All @@ -30,7 +28,6 @@ import {type Secrets} from '../resources/secret/secrets.js';
import {K8ClientSecrets} from '../k8_client/resources/secret/k8_client_secrets.js';
import {type Ingresses} from '../resources/ingress/ingresses.js';
import {K8ClientIngresses} from './resources/ingress/k8_client_ingresses.js';
import {InjectTokens} from '../../dependency_injection/inject_tokens.js';

/**
* A kubernetes API wrapper class providing custom functionalities required by solo
Expand All @@ -57,17 +54,11 @@ export class K8Client implements K8 {
private k8Secrets: Secrets;
private k8Ingresses: Ingresses;

private readonly configManager: ConfigManager;
private readonly logger: SoloLogger;

/**
* Create a new k8Factory client for the given context, if context is undefined it will use the current context in kubeconfig
* @param context - The context to create the k8Factory client for
*/
constructor(private readonly context: string) {
this.configManager = container.resolve(InjectTokens.ConfigManager);
this.logger = container.resolve(InjectTokens.SoloLogger);

this.init(this.context);
}

Expand All @@ -89,6 +80,7 @@ export class K8Client implements K8 {

this.k8Clusters = new K8ClientClusters(this.kubeConfig);
this.k8ConfigMaps = new K8ClientConfigMaps(this.kubeClient);
this.k8Contexts = new K8ClientContexts(this.kubeConfig);
this.k8Services = new K8ClientServices(this.kubeClient);
this.k8Pods = new K8ClientPods(this.kubeClient, this.kubeConfig);
this.k8Containers = new K8ClientContainers(this.kubeConfig, this.k8Pods);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/commands/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {ClusterCommandTasks} from '../../../src/commands/cluster/tasks.js';
import {type BaseCommand} from '../../../src/commands/base.js';
import {LocalConfig} from '../../../src/core/config/local_config.js';
import {type CommandFlag} from '../../../src/types/flag_types.js';
import {K8Client} from '../../../src/core/kube/k8_client/k8_client.js';
import {K8ClientFactory} from '../../../src/core/kube/k8_client/k8_client_factory.js';
import {type Cluster, KubeConfig} from '@kubernetes/client-node';
import {RemoteConfigManager} from '../../../src/core/config/remote/remote_config_manager.js';
Expand All @@ -49,7 +50,6 @@ import {ClusterChecks} from '../../../src/core/cluster_checks.js';
import {K8ClientClusters} from '../../../src/core/kube/k8_client/resources/cluster/k8_client_clusters.js';
import {K8ClientContexts} from '../../../src/core/kube/k8_client/resources/context/k8_client_contexts.js';
import {InjectTokens} from '../../../src/core/dependency_injection/inject_tokens.js';
import {K8Client} from '../../../src/core/kube/k8_client/k8_client.js';

const getBaseCommandOpts = () => ({
logger: sinon.stub(),
Expand Down
2 changes: 0 additions & 2 deletions test/unit/commands/network.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import {GenesisNetworkDataConstructor} from '../../../src/core/genesis_network_m
import {container} from 'tsyringe-neo';
import {type SoloLogger} from '../../../src/core/logging.js';
import {type K8Factory} from '../../../src/core/kube/k8_factory.js';
import {PlatformInstaller} from '../../../src/core/platform_installer.js';
import {CertificateManager} from '../../../src/core/certificate_manager.js';
import {type DependencyManager} from '../../../src/core/dependency_managers/index.js';
import {type LocalConfig} from '../../../src/core/config/local_config.js';
import {resetForTest} from '../../test_container.js';
Expand Down

0 comments on commit 7e3f608

Please sign in to comment.