Skip to content

Commit d4cf33e

Browse files
authored
feat: enable new provider huawei (#20)
feat: enable new provider huawei #20 - serverlessInsight is able to specify new provider `huawei` - basic terraform template are generate Refs: #19 --------- Signed-off-by: seven <zilisheng1996@gmail.com>
1 parent b96d863 commit d4cf33e

File tree

12 files changed

+397
-76
lines changed

12 files changed

+397
-76
lines changed

package-lock.json

Lines changed: 159 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commands/template.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ export const template = (
1010
) => {
1111
const context = constructActionContext({ ...options, stackName });
1212
const iac = parseYaml(context);
13-
const { template } = generateStackTemplate(stackName, iac, context);
14-
15-
const output =
16-
options.format === TemplateFormat.JSON
17-
? JSON.stringify(template, null, 2)
18-
: yaml.stringify(template);
1913

20-
logger.info(`\n${output}`);
14+
const { template } = generateStackTemplate(stackName, iac, context);
15+
if (typeof template === 'string') {
16+
logger.info(`\n${template}`);
17+
} else {
18+
const output =
19+
options.format === TemplateFormat.JSON
20+
? JSON.stringify(template, null, 2)
21+
: yaml.stringify(template);
22+
logger.info(`\n${output}`);
23+
}
2124
};

src/common/provider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export enum PROVIDER {
2-
HUAWEI = 'HUAWEI',
3-
ALIBABA = 'ALIBABA',
1+
export enum Provider {
2+
HUAWEI = 'huawei',
3+
ALIYUN = 'aliyun',
44
// TENCENT = 'TENCENT',
55
// AWS = 'AZURE',
66
// AZURE = 'AZURE',

src/parser/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { parseDatabase } from './databaseParser';
66
import { parseTag } from './tagParser';
77
import { parse } from 'yaml';
88
import { validateYaml } from '../validator';
9+
import { Provider } from '../common';
910

1011
const validateExistence = (path: string) => {
1112
if (!existsSync(path)) {
@@ -17,7 +18,7 @@ const transformYaml = (iacJson: ServerlessIacRaw): ServerlessIac => {
1718
return {
1819
service: iacJson.service,
1920
version: iacJson.version,
20-
provider: iacJson.provider,
21+
provider: iacJson.provider as Provider,
2122
vars: iacJson.vars,
2223
stages: iacJson.stages,
2324
functions: parseFunction(iacJson.functions),

0 commit comments

Comments
 (0)