Skip to content

Commit

Permalink
prep for PR
Browse files Browse the repository at this point in the history
Signed-off-by: Jeromy Cannon <[email protected]>
  • Loading branch information
jeromy-cannon committed Dec 27, 2024
1 parent b52ae20 commit 3434f71
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/core/account_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {Templates} from './templates.js';
import type {NetworkNodeServices} from './network_node_services.js';
import {NetworkNodeServicesBuilder} from './network_node_services.js';
import path from 'path';

import {SoloLogger} from './logging.js';
import {K8} from './k8.js';
import {type AccountIdWithKeyPairObject, type ExtendedNetServer} from '../types/index.js';
Expand Down
1 change: 1 addition & 0 deletions src/core/certificate_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {Flags as flags} from '../commands/flags.js';
import fs from 'fs';
import {Templates} from './templates.js';
import {GrpcProxyTlsEnums} from './enumerations.js';

import {ConfigManager} from './config_manager.js';
import {K8} from './k8.js';
import {SoloLogger} from './logging.js';
Expand Down
2 changes: 1 addition & 1 deletion src/core/config_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {inject, injectable} from 'tsyringe-neo';
import {SoloError, MissingArgumentError} from './errors.js';
import {SoloLogger} from './logging.js';
import {Flags, Flags as flags} from '../commands/flags.js';
import * as helpers from './helpers.js';
import * as paths from 'path';
import * as helpers from './helpers.js';
import type * as yargs from 'yargs';
import {type CommandFlag} from '../types/flag_types.js';
import {type ListrTaskWrapper} from 'listr2';
Expand Down
12 changes: 12 additions & 0 deletions src/core/container_init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,18 @@ import {RemoteConfigManager} from './config/remote/remote_config_manager.js';
import os from 'os';
import * as version from '../../version.js';

/**
* Container class to manage the dependency injection container
*/
export class Container {
private static instance: Container = null;
private static isInitialized = false;

private constructor() {}

/**
* Get the singleton instance of the container
*/
static getInstance() {
if (!Container.instance) {
Container.instance = new Container();
Expand All @@ -51,6 +57,12 @@ export class Container {
return Container.instance;
}

/**
* Initialize the container with the default dependencies
* @param cacheDir - the cache directory to use, defaults to constants.SOLO_CACHE_DIR
* @param logLevel - the log level to use, defaults to 'debug'
* @param devMode - if true, show full stack traces in error messages
*/
init(cacheDir: string = constants.SOLO_CACHE_DIR, logLevel: string = 'debug', devMode: boolean = false) {
// SoloLogger
container.register('logLevel', {useValue: logLevel});
Expand Down
2 changes: 1 addition & 1 deletion src/core/lease/lease_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import {Flags as flags} from '../../commands/flags.js';
import {ConfigManager} from '../config_manager.js';
import {K8} from '../k8.js';
import {SoloLogger} from '../logging.js';
import {type Lease, type LeaseRenewalService} from './lease.js';
import {IntervalLease} from './interval_lease.js';
import {LeaseHolder} from './lease_holder.js';
import {LeaseAcquisitionError} from './lease_errors.js';
import {inject, injectable} from 'tsyringe-neo';
import {type Lease, type LeaseRenewalService} from './lease.js';
import {patchInject} from '../container_helper.js';

/**
Expand Down
13 changes: 1 addition & 12 deletions src/core/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const customFormat = winston.format.combine(
winston.format(data => (data.private ? false : data))(),
);

// @injectable()
@injectable()
export class SoloLogger {
private winstonLogger: winston.Logger;
Expand All @@ -71,17 +70,7 @@ export class SoloLogger {
this.winstonLogger = winston.createLogger({
level: logLevel,
format: winston.format.combine(customFormat, winston.format.json()),
// format: winston.format.json(),
// defaultMeta: { service: 'user-service' },
transports: [
//
// - Write all logs with importance level of `error` or less to `error.log`
// - Write all logs with importance level of `info` or less to `solo.log`
//
new winston.transports.File({filename: path.join(constants.SOLO_LOGS_DIR, 'solo.log')}),
// new winston.transports.File({filename: constants.TMP_DIR + "/logs/error.log", level: 'error'}),
// new winston.transports.Console({format: customFormat})
],
transports: [new winston.transports.File({filename: path.join(constants.SOLO_LOGS_DIR, 'solo.log')})],
});
}

Expand Down
1 change: 1 addition & 0 deletions src/core/platform_installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {Templates} from './templates.js';
import {Flags as flags} from '../commands/flags.js';
import * as Base64 from 'js-base64';
import chalk from 'chalk';

import {SoloLogger} from './logging.js';
import type {NodeAlias, NodeAliases, PodName} from '../types/aliases.js';
import {Duration} from './time/duration.js';
Expand Down
2 changes: 1 addition & 1 deletion src/core/profile_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class ProfileManager {
) {
this.logger = patchInject(logger, SoloLogger, this.constructor.name);
this.configManager = patchInject(configManager, ConfigManager, this.constructor.name);
this.cacheDir = patchInject(cacheDir, 'cacheDir', this.constructor.name);
this.cacheDir = path.resolve(patchInject(cacheDir, 'cacheDir', this.constructor.name));

Check warning on line 64 in src/core/profile_manager.ts

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/core/profile_manager.ts#L64

Detected possible user input going into a `path.join` or `path.resolve` function.

this.profiles = new Map();
}
Expand Down
1 change: 1 addition & 0 deletions test/unit/core/certificate_manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import {expect} from 'chai';
import {after, before, describe, it} from 'mocha';
import jest from 'jest-mock';

import {ConfigManager} from '../../../src/core/config_manager.js';
import {K8} from '../../../src/core/k8.js';
import {CertificateManager} from '../../../src/core/certificate_manager.js';
Expand Down

0 comments on commit 3434f71

Please sign in to comment.