Skip to content

Commit

Permalink
update PR
Browse files Browse the repository at this point in the history
Signed-off-by: Vinayak Kukreja <[email protected]>
  • Loading branch information
vinayak-kukreja committed Sep 27, 2023
1 parent 4fb10d1 commit 7171f97
Show file tree
Hide file tree
Showing 5 changed files with 1,481 additions and 27 deletions.
25 changes: 1 addition & 24 deletions src/cli/cmds/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as yargs from 'yargs';
import { readConfigSync, ImportSpec } from '../../config';
import { importDispatch } from '../../import/dispatch';
import { DEFAULT_API_VERSION } from '../../import/k8s';
import { parseImports } from '../../util';

const config = readConfigSync();

Expand Down Expand Up @@ -41,28 +42,4 @@ class Command implements yargs.CommandModule {
}
}

function parseImports(spec: string): ImportSpec {
const splitImport = spec.split(':=');

// k8s@x.y.z
// crd.yaml
// url.com/crd.yaml
if (splitImport.length === 1) {
return {
source: spec,
};
}

// crd:=crd.yaml
// crd:=url.com/crd.yaml
if (splitImport.length === 2) {
return {
moduleNamePrefix: splitImport[0],
source: splitImport[1],
};
}

throw new Error('Unable to parse import specification. Syntax is [NAME:=]SPEC');
}

module.exports = new Command();
2 changes: 0 additions & 2 deletions src/import/helm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ export class ImportHelm extends ImportBase {
} else {
this.chartSchemaPath = undefined;
}

console.log(`CHART SCHEMA PATH: ${this.chartSchemaPath}`);
}

public get moduleNames() {
Expand Down
26 changes: 25 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as path from 'path';
import { parse } from 'url';
import * as fs from 'fs-extra';
import * as yaml from 'yaml';
import { ValidationConfig } from './config';
import { ImportSpec, ValidationConfig } from './config';
import { PluginManager } from './plugins/_manager';
import { ValidationPlugin, ValidationContext, ValidationReport, Validation } from './plugins/validation';
import { SafeReviver } from './reviver';
Expand Down Expand Up @@ -255,4 +255,28 @@ export interface SynthesizedApp {
* The construct metadata file (if exists).
*/
readonly constructMetadata?: string;
}

export function parseImports(spec: string): ImportSpec {
const splitImport = spec.split(':=');

// k8s@x.y.z
// crd.yaml
// url.com/crd.yaml
if (splitImport.length === 1) {
return {
source: spec,
};
}

// crd:=crd.yaml
// crd:=url.com/crd.yaml
if (splitImport.length === 2) {
return {
moduleNamePrefix: splitImport[0],
source: splitImport[1],
};
}

throw new Error('Unable to parse import specification. Syntax is [NAME:=]SPEC');
}
Loading

0 comments on commit 7171f97

Please sign in to comment.