Skip to content

Commit

Permalink
feat: enable new provider huawei (#20)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Blankll authored Dec 14, 2024
1 parent b96d863 commit d4cf33e
Show file tree
Hide file tree
Showing 12 changed files with 397 additions and 76 deletions.
172 changes: 159 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions src/commands/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ export const template = (
) => {
const context = constructActionContext({ ...options, stackName });
const iac = parseYaml(context);
const { template } = generateStackTemplate(stackName, iac, context);

const output =
options.format === TemplateFormat.JSON
? JSON.stringify(template, null, 2)
: yaml.stringify(template);

logger.info(`\n${output}`);
const { template } = generateStackTemplate(stackName, iac, context);
if (typeof template === 'string') {
logger.info(`\n${template}`);
} else {
const output =
options.format === TemplateFormat.JSON
? JSON.stringify(template, null, 2)
: yaml.stringify(template);
logger.info(`\n${output}`);
}
};
6 changes: 3 additions & 3 deletions src/common/provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export enum PROVIDER {
HUAWEI = 'HUAWEI',
ALIBABA = 'ALIBABA',
export enum Provider {
HUAWEI = 'huawei',
ALIYUN = 'aliyun',
// TENCENT = 'TENCENT',
// AWS = 'AZURE',
// AZURE = 'AZURE',
Expand Down
3 changes: 2 additions & 1 deletion src/parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { parseDatabase } from './databaseParser';
import { parseTag } from './tagParser';
import { parse } from 'yaml';
import { validateYaml } from '../validator';
import { Provider } from '../common';

const validateExistence = (path: string) => {
if (!existsSync(path)) {
Expand All @@ -17,7 +18,7 @@ const transformYaml = (iacJson: ServerlessIacRaw): ServerlessIac => {
return {
service: iacJson.service,
version: iacJson.version,
provider: iacJson.provider,
provider: iacJson.provider as Provider,
vars: iacJson.vars,
stages: iacJson.stages,
functions: parseFunction(iacJson.functions),
Expand Down
Loading

0 comments on commit d4cf33e

Please sign in to comment.