Skip to content

Commit c49890f

Browse files
committed
removed search/replace errors
Signed-off-by: Jeromy Cannon <jeromy@swirldslabs.com>
1 parent 2df6ad2 commit c49890f

13 files changed

+46
-37
lines changed

src/commands/cluster/tasks.ts

+21-13
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ export class ClusterCommandTasks {
4646
if (!context) {
4747
const isQuiet = self.parent.getConfigManager().getFlag(flags.quiet);
4848
if (isQuiet) {
49-
context = self.parent.getK8Factory().contexts().readCurrent();
49+
context = self.parent.getK8Factory().default().contexts().readCurrent();
5050
} else {
5151
context = await self.promptForContext(parentTask, cluster);
5252
}
5353

5454
localConfig.clusterContextMapping[cluster] = context;
5555
}
56-
if (!(await self.parent.getK8Factory().contexts().testContextConnection(context))) {
56+
if (!(await self.parent.getK8Factory().default().contexts().testContextConnection(context))) {
5757
subTask.title = `${subTask.title} - ${chalk.red('Cluster connection failed')}`;
5858
throw new SoloError(`${ErrorMessages.INVALID_CONTEXT_FOR_CLUSTER_DETAILED(context, cluster)}`);
5959
}
@@ -72,7 +72,7 @@ export class ClusterCommandTasks {
7272
title: `Pull and validate remote configuration for cluster: ${chalk.cyan(cluster)}`,
7373
task: async (_, subTask: ListrTaskWrapper<any, any, any>) => {
7474
const context = localConfig.clusterContextMapping[cluster];
75-
self.parent.getK8Factory().contexts().updateCurrent(context);
75+
self.parent.getK8Factory().default().contexts().updateCurrent(context);
7676
const remoteConfigFromOtherCluster = await self.parent.getRemoteConfigManager().get();
7777
if (!RemoteConfigManager.compare(currentRemoteConfig, remoteConfigFromOtherCluster)) {
7878
throw new SoloError(ErrorMessages.REMOTE_CONFIGS_DO_NOT_MATCH(currentClusterName, cluster));
@@ -87,7 +87,7 @@ export class ClusterCommandTasks {
8787
title: 'Read clusters from remote config',
8888
task: async (ctx, task) => {
8989
const localConfig = this.parent.getLocalConfig();
90-
const currentClusterName = this.parent.getK8Factory().clusters().readCurrent();
90+
const currentClusterName = this.parent.getK8Factory().default().clusters().readCurrent();
9191
const currentRemoteConfig: RemoteConfigDataWrapper = await this.parent.getRemoteConfigManager().get();
9292
const subTasks = [];
9393
const remoteConfigClusters = Object.keys(currentRemoteConfig.clusters);
@@ -162,7 +162,11 @@ export class ClusterCommandTasks {
162162
} else if (!localConfig.clusterContextMapping[cluster]) {
163163
// In quiet mode, use the currently selected context to update the mapping
164164
if (isQuiet) {
165-
localConfig.clusterContextMapping[cluster] = this.parent.getK8Factory().contexts().readCurrent();
165+
localConfig.clusterContextMapping[cluster] = this.parent
166+
.getK8Factory()
167+
.default()
168+
.contexts()
169+
.readCurrent();
166170
}
167171

168172
// Prompt the user to select a context if mapping value is missing
@@ -185,7 +189,7 @@ export class ClusterCommandTasks {
185189
) {
186190
let selectedContext;
187191
if (isQuiet) {
188-
selectedContext = this.parent.getK8Factory().contexts().readCurrent();
192+
selectedContext = this.parent.getK8Factory().default().contexts().readCurrent();
189193
} else {
190194
selectedContext = await this.promptForContext(task, selectedCluster);
191195
localConfig.clusterContextMapping[selectedCluster] = selectedContext;
@@ -194,7 +198,7 @@ export class ClusterCommandTasks {
194198
}
195199

196200
private async promptForContext(task: SoloListrTaskWrapper<SelectClusterContextContext>, cluster: string) {
197-
const kubeContexts = this.parent.getK8Factory().contexts().list();
201+
const kubeContexts = this.parent.getK8Factory().default().contexts().list();
198202
return flags.context.prompt(task, kubeContexts, cluster);
199203
}
200204

@@ -306,8 +310,8 @@ export class ClusterCommandTasks {
306310
else {
307311
// Add the deployment to the LocalConfig with the currently selected cluster and context in KubeConfig
308312
if (isQuiet) {
309-
selectedContext = this.parent.getK8Factory().contexts().readCurrent();
310-
selectedCluster = this.parent.getK8Factory().clusters().readCurrent();
313+
selectedContext = this.parent.getK8Factory().default().contexts().readCurrent();
314+
selectedCluster = this.parent.getK8Factory().default().clusters().readCurrent();
311315
localConfig.deployments[deploymentName] = {
312316
clusters: [selectedCluster],
313317
namespace: namespace ? namespace.name : '',
@@ -335,11 +339,15 @@ export class ClusterCommandTasks {
335339
}
336340
}
337341

338-
const connectionValid = await this.parent.getK8Factory().contexts().testContextConnection(selectedContext);
342+
const connectionValid = await this.parent
343+
.getK8Factory()
344+
.default()
345+
.contexts()
346+
.testContextConnection(selectedContext);
339347
if (!connectionValid) {
340348
throw new SoloError(ErrorMessages.INVALID_CONTEXT_FOR_CLUSTER(selectedContext, selectedCluster));
341349
}
342-
this.parent.getK8Factory().contexts().updateCurrent(selectedContext);
350+
this.parent.getK8Factory().default().contexts().updateCurrent(selectedContext);
343351
this.parent.getConfigManager().setFlag(flags.context, selectedContext);
344352
},
345353
};
@@ -361,14 +369,14 @@ export class ClusterCommandTasks {
361369

362370
showClusterList() {
363371
return new Task('List all available clusters', async (ctx: any, task: ListrTaskWrapper<any, any, any>) => {
364-
this.parent.logger.showList('Clusters', this.parent.getK8Factory().clusters().list());
372+
this.parent.logger.showList('Clusters', this.parent.getK8Factory().default().clusters().list());
365373
});
366374
}
367375

368376
getClusterInfo() {
369377
return new Task('Get cluster info', async (ctx: any, task: ListrTaskWrapper<any, any, any>) => {
370378
try {
371-
const clusterName = this.parent.getK8Factory().clusters().readCurrent();
379+
const clusterName = this.parent.getK8Factory().default().clusters().readCurrent();
372380
this.parent.logger.showUser(`Cluster Name (${clusterName})`);
373381
this.parent.logger.showUser('\n');
374382
} catch (e: Error | unknown) {

src/core/certificate_manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class CertificateManager {
2828
@inject(InjectTokens.SoloLogger) private readonly logger?: SoloLogger,
2929
@inject(InjectTokens.ConfigManager) private readonly configManager?: ConfigManager,
3030
) {
31-
this.k8Factory = patchInject(K8Factory, InjectTokens.K8Factory, this.constructor.name);
31+
this.k8Factory = patchInject(k8Factory, InjectTokens.K8Factory, this.constructor.name);
3232
this.logger = patchInject(logger, InjectTokens.SoloLogger, this.constructor.name);
3333
this.configManager = patchInject(configManager, InjectTokens.ConfigManager, this.constructor.name);
3434
}

src/core/cluster_checks.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class ClusterChecks {
2222
@inject(InjectTokens.K8Factory) private readonly k8Factory?: K8Factory,
2323
) {
2424
this.logger = patchInject(logger, InjectTokens.SoloLogger, this.constructor.name);
25-
this.k8Factory = patchInject(K8Factory, InjectTokens.K8Factory, this.constructor.name);
25+
this.k8Factory = patchInject(k8Factory, InjectTokens.K8Factory, this.constructor.name);
2626
}
2727

2828
/**

src/core/config/remote/remote_config_manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class RemoteConfigManager {
4949
@inject(InjectTokens.LocalConfig) private readonly localConfig?: LocalConfig,
5050
@inject(InjectTokens.ConfigManager) private readonly configManager?: ConfigManager,
5151
) {
52-
this.k8Factory = patchInject(K8Factory, InjectTokens.K8Factory, this.constructor.name);
52+
this.k8Factory = patchInject(k8Factory, InjectTokens.K8Factory, this.constructor.name);
5353
this.logger = patchInject(logger, InjectTokens.SoloLogger, this.constructor.name);
5454
this.localConfig = patchInject(localConfig, InjectTokens.LocalConfig, this.constructor.name);
5555
this.configManager = patchInject(configManager, InjectTokens.ConfigManager, this.constructor.name);

src/core/dependency_injection/container_init.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ export class Container {
8080

8181
container.register(InjectTokens.ChartManager, {useClass: ChartManager}, {lifecycle: Lifecycle.Singleton});
8282
container.register(InjectTokens.ConfigManager, {useClass: ConfigManager}, {lifecycle: Lifecycle.Singleton});
83-
container.register(InjectTokens.K8Factory, {useClass: K8Client}, {lifecycle: Lifecycle.Singleton}); // TODO remove
84-
container.register(InjectTokens.K8FactoryFactory, {useClass: K8ClientFactory}, {lifecycle: Lifecycle.Singleton});
83+
container.register(InjectTokens.K8Factory, {useClass: K8ClientFactory}, {lifecycle: Lifecycle.Singleton});
8584
container.register(InjectTokens.AccountManager, {useClass: AccountManager}, {lifecycle: Lifecycle.Singleton});
8685
container.register(InjectTokens.PlatformInstaller, {useClass: PlatformInstaller}, {lifecycle: Lifecycle.Singleton});
8786
container.register(InjectTokens.KeyManager, {useClass: KeyManager}, {lifecycle: Lifecycle.Singleton});

src/core/kube/k8_client/k8_client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {SoloError} from '../../errors.js';
66
import {type ConfigManager} from '../../config_manager.js';
77
import {type SoloLogger} from '../../logging.js';
88
import {container} from 'tsyringe-neo';
9-
import {type K8Factory} from '../k8_factory.js';
9+
import {type K8} from '../k8.js';
1010
import {type Namespaces} from '../resources/namespace/namespaces.js';
1111
import {K8ClientClusters} from '../k8_client/resources/cluster/k8_client_clusters.js';
1212
import {type Clusters} from '../resources/cluster/clusters.js';

src/core/kube/k8_client/k8_client_factory.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* SPDX-License-Identifier: Apache-2.0
33
*/
44
import {type K8Factory} from '../k8_factory.js';
5-
import {type K8Factory} from '../k8.js';
5+
import {type K8} from '../k8.js';
66
import {K8Client} from './k8_client.js';
77
import {injectable} from 'tsyringe-neo';
88

src/core/lease/lease_manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class LeaseManager {
3535
) {
3636
this._renewalService = patchInject(_renewalService, InjectTokens.LeaseRenewalService, this.constructor.name);
3737
this._logger = patchInject(_logger, InjectTokens.SoloLogger, this.constructor.name);
38-
this.k8Factory = patchInject(K8Factory, InjectTokens.K8Factory, this.constructor.name);
38+
this.k8Factory = patchInject(k8Factory, InjectTokens.K8Factory, this.constructor.name);
3939
this.configManager = patchInject(configManager, InjectTokens.ConfigManager, this.constructor.name);
4040
}
4141

src/core/network_nodes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class NetworkNodes {
2828
@inject(InjectTokens.K8Factory) private readonly k8Factory?: K8Factory,
2929
) {
3030
this.logger = patchInject(logger, InjectTokens.SoloLogger, this.constructor.name);
31-
this.k8Factory = patchInject(K8Factory, InjectTokens.K8Factory, this.constructor.name);
31+
this.k8Factory = patchInject(k8Factory, InjectTokens.K8Factory, this.constructor.name);
3232
}
3333

3434
/**

src/core/platform_installer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class PlatformInstaller {
3434
@inject(InjectTokens.ConfigManager) private configManager?: ConfigManager,
3535
) {
3636
this.logger = patchInject(logger, InjectTokens.SoloLogger, this.constructor.name);
37-
this.k8Factory = patchInject(K8Factory, InjectTokens.K8Factory, this.constructor.name);
37+
this.k8Factory = patchInject(k8Factory, InjectTokens.K8Factory, this.constructor.name);
3838
this.configManager = patchInject(configManager, InjectTokens.ConfigManager, this.constructor.name);
3939
}
4040

test/e2e/commands/node_local_hedera.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ e2eTestSuite(
105105
it('get the logs and delete the namespace', async () => {
106106
await accountManager.close();
107107
await container.resolve<NetworkNodes>(InjectTokens.NetworkNodes).getLogs(LOCAL_HEDERA);
108-
await k8Factory.namespaces().delete(LOCAL_HEDERA);
108+
await k8Factory.default().namespaces().delete(LOCAL_HEDERA);
109109
}).timeout(Duration.ofMinutes(10).toMillis());
110110
});
111111
},

test/e2e/commands/node_local_ptt.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ e2eTestSuite(
5151

5252
it('get the logs and delete the namespace', async () => {
5353
await container.resolve<NetworkNodes>(InjectTokens.NetworkNodes).getLogs(LOCAL_PTT);
54-
await k8Factory.namespaces().delete(LOCAL_PTT);
54+
await k8Factory.default().namespaces().delete(LOCAL_PTT);
5555
}).timeout(Duration.ofMinutes(2).toMillis());
5656
});
5757
},

test/unit/commands/cluster.test.ts

+14-12
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ describe('ClusterCommand unit tests', () => {
468468
const opts = getBaseCommandOpts(sandbox, {}, [[flags.deployment, 'deployment-4']]);
469469

470470
command = await runSelectContextTask(opts);
471-
expect(command.getK8().contexts().updateCurrent).to.have.been.calledWith('context-3');
471+
expect(command.getK8Factory().default().contexts().updateCurrent).to.have.been.calledWith('context-3');
472472
});
473473

474474
it('should use clusters and contexts from kubeConfig if selected deployment is not found in local config and quiet=true', async () => {
@@ -478,7 +478,9 @@ describe('ClusterCommand unit tests', () => {
478478
]);
479479

480480
command = await runSelectContextTask(opts);
481-
expect(command.getK8().contexts().updateCurrent).to.have.been.calledWith('context-from-kubeConfig');
481+
expect(command.getK8Factory().default().contexts().updateCurrent).to.have.been.calledWith(
482+
'context-from-kubeConfig',
483+
);
482484
});
483485

484486
it('throws error when context is invalid', async () => {
@@ -562,9 +564,9 @@ describe('ClusterCommand unit tests', () => {
562564
expect(subTasks.length).to.eq(2);
563565
await runSubTasks(subTasks);
564566
expect(contextPromptStub).not.called;
565-
expect(command.getK8().contexts().updateCurrent).to.have.been.calledWith('context-2');
566-
expect(command.getK8().contexts().testContextConnection).calledOnce;
567-
expect(command.getK8().contexts().testContextConnection).calledWith('context-2');
567+
expect(command.getK8Factory().default().contexts().updateCurrent).to.have.been.calledWith('context-2');
568+
expect(command.getK8Factory().default().contexts().testContextConnection).calledOnce;
569+
expect(command.getK8Factory().default().contexts().testContextConnection).calledWith('context-2');
568570
});
569571

570572
it('should prompt for context when reading unknown cluster', async () => {
@@ -581,9 +583,9 @@ describe('ClusterCommand unit tests', () => {
581583
expect(subTasks.length).to.eq(2);
582584
await runSubTasks(subTasks);
583585
expect(contextPromptStub).calledOnce;
584-
expect(command.getK8().contexts().updateCurrent).to.have.been.calledWith('prompted-context');
585-
expect(command.getK8().contexts().testContextConnection).calledOnce;
586-
expect(command.getK8().contexts().testContextConnection).calledWith('prompted-context');
586+
expect(command.getK8Factory().default().contexts().updateCurrent).to.have.been.calledWith('prompted-context');
587+
expect(command.getK8Factory().default().contexts().testContextConnection).calledOnce;
588+
expect(command.getK8Factory().default().contexts().testContextConnection).calledWith('prompted-context');
587589
});
588590

589591
it('should throw error for invalid prompted context', async () => {
@@ -604,8 +606,8 @@ describe('ClusterCommand unit tests', () => {
604606
} catch (e) {
605607
expect(e.message).to.eq(ErrorMessages.INVALID_CONTEXT_FOR_CLUSTER_DETAILED('prompted-context', 'cluster-4'));
606608
expect(contextPromptStub).calledOnce;
607-
expect(command.getK8().contexts().testContextConnection).calledOnce;
608-
expect(command.getK8().contexts().testContextConnection).calledWith('prompted-context');
609+
expect(command.getK8Factory().default().contexts().testContextConnection).calledOnce;
610+
expect(command.getK8Factory().default().contexts().testContextConnection).calledWith('prompted-context');
609611
}
610612
});
611613

@@ -633,8 +635,8 @@ describe('ClusterCommand unit tests', () => {
633635
} catch (e) {
634636
expect(e.message).to.eq(ErrorMessages.REMOTE_CONFIGS_DO_NOT_MATCH('cluster-3', 'cluster-4'));
635637
expect(contextPromptStub).calledOnce;
636-
expect(command.getK8().contexts().testContextConnection).calledOnce;
637-
expect(command.getK8().contexts().testContextConnection).calledWith('prompted-context');
638+
expect(command.getK8Factory().default().contexts().testContextConnection).calledOnce;
639+
expect(command.getK8Factory().default().contexts().testContextConnection).calledWith('prompted-context');
638640
}
639641
});
640642
});

0 commit comments

Comments
 (0)