Skip to content

Commit

Permalink
πŸ€– Refactor: mySQL, Server, Subnet, VPC Paresr μΆ”κ°€
Browse files Browse the repository at this point in the history
  • Loading branch information
Gdm0714 committed Jan 6, 2025
1 parent 7988e40 commit 76d160f
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 16 deletions.
4 changes: 2 additions & 2 deletions packages/terraform/parser/MySQLParesr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class MySQLParesr extends BaseResourceParser {
hostIp: properties.hostIp,
databaseName: properties.databaseName,
subnet: properties.subnet,
vpc: properties.vpc
})
vpc: properties.vpc,
});
}
}
22 changes: 17 additions & 5 deletions packages/terraform/parser/ServerParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,25 @@ export class ServerParser extends BaseResourceParser {

protected validateProperties(properties: any): void {
if (!properties.server_image_number) {
throw new ValidationError('Server', 'serverImageNumber', 'server image number κ°€ ν•„μˆ˜μž…λ‹ˆλ‹€.');
throw new ValidationError(
'Server',
'serverImageNumber',
'server image number κ°€ ν•„μˆ˜μž…λ‹ˆλ‹€.',
);
}
if (!properties.server_spec_code) {
throw new ValidationError('Server', 'serverSpecCode', 'server spec code κ°€ ν•„μˆ˜μž…λ‹ˆλ‹€.');
throw new ValidationError(
'Server',
'serverSpecCode',
'server spec code κ°€ ν•„μˆ˜μž…λ‹ˆλ‹€.',
);
}
if (!properties.subnet) {
throw new ValidationError('Server', 'subnet', 'subnet 이 ν•„μˆ˜μž…λ‹ˆλ‹€.');
throw new ValidationError(
'Server',
'subnet',
'subnet 이 ν•„μˆ˜μž…λ‹ˆλ‹€.',
);
}
}

Expand All @@ -25,7 +37,7 @@ export class ServerParser extends BaseResourceParser {
subnetName: properties.subnet,
loginKeyName: properties.loginKeyName,
nicName: properties.nicName,
acgName: properties.acgName
acgName: properties.acgName,
});
}
}
}
36 changes: 29 additions & 7 deletions packages/terraform/parser/SubnetParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,38 @@ export class SubnetParser extends BaseResourceParser {

protected validateProperties(properties: any): void {
if (!properties.subnet) {
throw new ValidationError('Subnet', 'subnet', 'CIDR block 이 ν•„μˆ˜ μ†μ„±μž…λ‹ˆλ‹€.');
throw new ValidationError(
'Subnet',
'subnet',
'CIDR block 이 ν•„μˆ˜ μ†μ„±μž…λ‹ˆλ‹€.',
);
}
if (!properties.zone) {
throw new ValidationError('Subnet', 'zone', 'zone 이 ν•„μˆ˜ μ†μ„±μž…λ‹ˆλ‹€.');
throw new ValidationError(
'Subnet',
'zone',
'zone 이 ν•„μˆ˜ μ†μ„±μž…λ‹ˆλ‹€.',
);
}
if (!properties.subnetType || !['PUBLIC', 'PRIVATE'].includes(properties.subnetType)) {
throw new ValidationError('Subnet', 'subnetType', 'PUBLIC λ˜λŠ” PRIVATE 이어야 ν•©λ‹ˆλ‹€');
if (
!properties.subnetType ||
!['PUBLIC', 'PRIVATE'].includes(properties.subnetType)
) {
throw new ValidationError(
'Subnet',
'subnetType',
'PUBLIC λ˜λŠ” PRIVATE 이어야 ν•©λ‹ˆλ‹€',
);
}
if (properties.usageType && !['GEN', 'LOADB', 'BM', 'NATGW'].includes(properties.usageType)) {
throw new ValidationError('Subnet', 'usageType', 'GEN, LOADB, BM, NATGW 쀑 ν•˜λ‚˜μ—¬μ•Ό ν•©λ‹ˆλ‹€');
if (
properties.usageType &&
!['GEN', 'LOADB', 'BM', 'NATGW'].includes(properties.usageType)
) {
throw new ValidationError(
'Subnet',
'usageType',
'GEN, LOADB, BM, NATGW 쀑 ν•˜λ‚˜μ—¬μ•Ό ν•©λ‹ˆλ‹€',
);
}
}

Expand All @@ -28,7 +50,7 @@ export class SubnetParser extends BaseResourceParser {
subnetType: properties.subnetType,
usageType: properties.usageType || 'GEN',
vpcName: properties.vpcName,
networkAclNo: properties.networkAclNo
networkAclNo: properties.networkAclNo,
});
}
}
8 changes: 6 additions & 2 deletions packages/terraform/parser/VPCParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ export class VPCParser extends BaseResourceParser {

protected validateProperties(properties: any) {
if (!properties.cidrBlock) {
throw new ValidationError('VPC', 'ipv4CidrBlock', 'ν•„μˆ˜ 속성이 μ—†μŠ΅λ‹ˆλ‹€.');
throw new ValidationError(
'VPC',
'ipv4CidrBlock',
'ν•„μˆ˜ 속성이 μ—†μŠ΅λ‹ˆλ‹€.',
);
}
}

protected createModel(properties: any): NCloudVPC {
return new NCloudVPC({
name: this.getNameOrDefault(properties, 'vpc'),
ipv4CidrBlock: properties.cidrBlock,
})
});
}
}

0 comments on commit 76d160f

Please sign in to comment.