Skip to content

Commit 124a506

Browse files
committed
encapsulate createIssue service
1 parent 5f415ce commit 124a506

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/commands/create-issue.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fs from "node:fs";
33

44
import CreateIssueOpt from "./opts/create-issue-opt.js";
55
import {SleekCommand} from "../sleek-command.js";
6-
import {createIssue, getRepoName, getRepoOwner, validateInputFileSchema} from "../service/create-issue-svc.js";
6+
import {createIssue, validateInputFileSchema} from "../service/create-issue-svc.js";
77
import {issueData} from "../types/issue.js";
88

99
const Ajv = _Ajv as unknown as typeof _Ajv.default;
@@ -31,11 +31,9 @@ export default class CreateIssue extends SleekCommand {
3131
// validateChart(helmCharName, helmChartVersion);
3232

3333
// create issue base in the file input
34-
const repo = flags.repo || getRepoName();
35-
const owner = flags.repoOwner || getRepoOwner();
3634
const title = `Onboarding ${(data.body as issueData).sellerMarketPlaceAlias} ${(data.body as issueData).addon.name}@${(data.body as issueData).addon.version}`;
3735
const body= `Issue body:\n\n\`\`\`yaml\n${fileContents}\`\`\`\n`;
38-
const createIssueResponse = await createIssue(repo, owner, title, body,this, ['pending'])
36+
const createIssueResponse = await createIssue(title, body,this, ['pending'])
3937

4038
this.log(`Issue created: ${createIssueResponse.body?.data.html_url}`)
4139
}

src/service/create-issue-svc.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import type {OctokitResponse} from "@octokit/types/dist-types/OctokitResponse.js
88

99
const Ajv = _Ajv as unknown as typeof _Ajv.default;
1010

11-
export async function createIssue(repo: string, owner: string, title: string, body: string, callerCommand: SleekCommand, labels: string[] = []): Promise<svcResponse<OctokitResponse<any>>> {
11+
export const createIssue = async (title: string, body: string, callerCommand: SleekCommand, labels: string[] = []): Promise<svcResponse<OctokitResponse<any>>> => {
12+
return createIssueOnRepo(getRepoName(), getRepoOwner(), title, body, callerCommand, labels)
13+
}
14+
const createIssueOnRepo = async (repo: string, owner: string, title: string, body: string, callerCommand: SleekCommand, labels: string[]): Promise<svcResponse<OctokitResponse<any>>> => {
1215
const octokitOptions = {
1316
auth: process.env.GITHUB_TOKEN,
1417
};
@@ -67,10 +70,10 @@ function getSchemaUrl(): string {
6770
return 'https://raw.githubusercontent.com/elamaran11/aws-sleek-transformer/f96009d3feb4967b4d92fd57f4d1bd2cf148e1a9/src/schemas/issue-creation.schema.json'
6871
}
6972

70-
export function getRepoOwner() {
73+
function getRepoOwner() {
7174
return 'cloudsoft-fusion';
7275
}
7376

74-
export function getRepoName() {
77+
function getRepoName() {
7578
return 'aws-k8s-addons'
7679
}

0 commit comments

Comments
 (0)