Skip to content

Commit 54942a3

Browse files
authored
Delete workflow_create.ts (#75)
1 parent 519c1f3 commit 54942a3

File tree

8 files changed

+12
-133
lines changed

8 files changed

+12
-133
lines changed

ts/create-kpt-functions/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ts/create-kpt-functions/src/cli.ts

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ import { functionCreate } from './cmd/function_create';
2323
import { dockerCreate } from './cmd/docker_create';
2424
import { dockerBuild } from './cmd/docker_build';
2525
import { dockerPush } from './cmd/docker_push';
26-
import { workflowCreate } from './cmd/workflow_create';
2726

2827
async function main() {
29-
// TODO: Add usage examples.
3028
const parser = new ArgumentParser({
3129
version: '0.0.1',
3230
addHelp: true,
@@ -88,48 +86,33 @@ async function main() {
8886
help: typeCreateHelp,
8987
});
9088

91-
const workflowCreateHelp =
92-
'Generate workflow configs for all functions. Overwrite configs if they exist.';
93-
const wc = subparsers.addParser('workflow-create', {
94-
addHelp: true,
95-
description: workflowCreateHelp,
96-
help: workflowCreateHelp,
97-
});
98-
wc.addArgument('--tag', {
99-
defaultValue: 'dev',
100-
help: 'Docker tag used for all function images.',
101-
});
102-
10389
// There doesn't seem to be any other way to mark subcommands
10490
// as optional, so manually add package-create to argv.
10591
if (process.argv.length === 2) {
10692
process.argv.push('package-create');
10793
}
10894

10995
const args = parser.parseArgs();
96+
const packageDir = resolve('.');
11097

111-
// TODO(b/141943296): Ensure subcommands handle choosing the package directory
11298
switch (args.subcommand) {
11399
case 'package-create':
114100
await packageCreate();
115101
break;
116102
case 'type-create':
117-
await typeCreate(resolve('.'));
103+
await typeCreate(packageDir);
118104
break;
119105
case 'function-create':
120-
functionCreate(resolve('.'));
106+
functionCreate(packageDir);
121107
break;
122108
case 'docker-create':
123-
dockerCreate(resolve('.'));
109+
dockerCreate(packageDir);
124110
break;
125111
case 'docker-build':
126-
dockerBuild(resolve('.'), args.get('tag'));
112+
dockerBuild(packageDir, args.get('tag'));
127113
break;
128114
case 'docker-push':
129-
dockerPush(resolve('.'), args.get('tag'));
130-
break;
131-
case 'workflow-create':
132-
workflowCreate(resolve('.'), args.get('tag'));
115+
dockerPush(packageDir, args.get('tag'));
133116
break;
134117
default:
135118
parser.exit(1, 'invalid args');

ts/create-kpt-functions/src/cmd/function_create.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ export function functionCreate(appDir: string) {
3232
validator.isValidFuncName,
3333
defaultFuncName,
3434
);
35-
3635
log(`Using function name "${funcName}".\n`);
3736

3837
const tsFuncName = validator.toTSName(funcName);
39-
4038
const srcDir = path.join(appDir, USER_PACKAGE.src);
4139

4240
new Templates([

ts/create-kpt-functions/src/cmd/package_create.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,13 @@ import * as validator from '../utils/validator';
2626

2727
export async function packageCreate() {
2828
const pkgDir = initPackage();
29-
30-
// TODO(b/142241787): Don't just crash if type generation fails. Handle this gracefully.
31-
// TODO(b/142242496): Add option to skip type generation.
3229
await typeCreate(pkgDir);
33-
3430
functionCreate(pkgDir);
3531
dockerCreate(pkgDir);
3632

3733
log(
3834
format.success('\nSuccess!') +
39-
' Run `npm install` next to install dependencies and build the package.\n',
35+
' Run `npm install` to install dependencies and build the package.\n',
4036
);
4137
}
4238

@@ -56,7 +52,6 @@ function initPackage() {
5652
defaultPackageDir,
5753
),
5854
);
59-
6055
log(`Using package path ${packageDir}.\n`);
6156

6257
// Prompt for package name.
@@ -66,7 +61,6 @@ function initPackage() {
6661
validator.isValidPackageName,
6762
defaultPackageName,
6863
);
69-
7064
log(`Using package name ${packageName}.\n`);
7165

7266
// Prompt for docker registry url.
@@ -79,7 +73,6 @@ function initPackage() {
7973
validator.isValidDockerRepo,
8074
defaultDockerRepoBase,
8175
);
82-
8376
log(`Using docker repository prefix ${defaultDockerRepoBase}.\n`);
8477

8578
new Templates([

ts/create-kpt-functions/src/cmd/type_create.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@ export async function typeCreate(packageDir: string) {
3535
// Get the kubeconfig context the user wants to use.
3636
const kc = new KubeConfig();
3737
kc.loadFromDefault();
38-
3938
const contexts = kc.contexts;
4039
if (contexts.length == 0) {
4140
log(failure('No contexts found in kubeconfig file. Please set a context entry in kubeconfig.'));
4241
process.exit(1);
4342
}
44-
4543
const currentContext = kc.currentContext;
4644
const contextIdx = chooseContext(contexts, currentContext);
4745
const useContext = contexts[contextIdx];
@@ -50,26 +48,26 @@ export async function typeCreate(packageDir: string) {
5048
throw new Error('Cluster for specified context not found.');
5149
}
5250

51+
// Download the swagger file from the cluster.
5352
const opts: request.Options = {
5453
url: `${cluster.server}/openapi/v2`,
5554
};
5655
kc.setCurrentContext(useContext.name);
5756
kc.applyToRequest(opts);
58-
5957
const out = await request.get(opts);
6058
const tmp = mkdtempSync(resolve(tmpdir(), 'kpt-init'));
6159
const swaggerFile = resolve(tmp, 'swagger.json');
62-
const typegenOutDir = resolve(packageDir, 'src', 'gen');
63-
6460
writeFileSync(swaggerFile, out);
61+
62+
// Run typegen binary.
63+
const typegenOutDir = resolve(packageDir, 'src', 'gen');
6564
const typegen = spawnSync('typegen', [swaggerFile, typegenOutDir], {
6665
env: {
6766
PATH: `${CLI_PACKAGE.binDir}${delimiter}${process.env.PATH}`,
6867
},
6968
stdio: 'inherit',
7069
});
7170
unlinkSync(swaggerFile);
72-
7371
if (typegen.status !== 0) {
7472
let msg = 'Failed to run typegen';
7573
if (typegen.error) {

ts/create-kpt-functions/src/cmd/workflow_create.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.

ts/create-kpt-functions/templates/argo.mustache

Lines changed: 0 additions & 20 deletions
This file was deleted.

ts/create-kpt-functions/templates/tekton.mustache

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)