Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: App dupplicate #36

Merged
merged 4 commits into from
Mar 31, 2022
Merged
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
4 changes: 1 addition & 3 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { App } from "cdk8s";
import * as log4js from "log4js";
import * as Minimist from "minimist";
import { CommandManager } from './src/managers/commandManager';
Expand Down Expand Up @@ -38,6 +37,5 @@ const logLevel = LogConfig.logLevel(args.v);
log.level = logLevel;

log.debug("App Creating...");
const app = new App();
const commandManager = new CommandManager(app, commandOption);
const commandManager = new CommandManager(commandOption);
commandManager.handle(args);
5 changes: 2 additions & 3 deletions src/managers/commandManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { App } from "cdk8s"
import * as log4js from "log4js";
import * as Minimist from "minimist";
import ILevisCommand from "../interfaces";
Expand All @@ -12,11 +11,11 @@ export class CommandManager {

private command?: ILevisCommand;

constructor(app: App, commandOption: string) {
constructor(commandOption: string) {
switch(commandOption) {
case LevisCommand.CREATE: {
log.debug("create command");
this.command = new CreateCommand(app);
this.command = new CreateCommand();
break;
}
case LevisCommand.VERSION.toLowerCase(): {
Expand Down
14 changes: 5 additions & 9 deletions src/services/createCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ const log = log4js.getLogger();
export class CreateCommand implements ILevisCommand {

private command!: Command;
private app: App;

constructor(app: App){
this.app = app;
}

init(args: Minimist.ParsedArgs): Command {
log.debug("CreateCommand");
Expand All @@ -41,10 +36,11 @@ export class CreateCommand implements ILevisCommand {

process(): void {
log.debug("process");
new MicroServiceChart(this.app, this.command);
const app = new App();
new MicroServiceChart(app, this.command);
// Activate CDK8S for generating yaml file
this.app.synth();
FileUtils.Move(Path.CURRENT_PATH, this.command.outputFilePath);
app.synth();
FileUtils.Move("./dist/levis.k8s.yaml", this.command.outputFilePath);
}

}
}