@@ -27,16 +27,20 @@ const props = defineProps({
27
27
required: true ,
28
28
validator : (val : SupportedEntityType ) => SupportedEntityTypesArray .includes (val ),
29
29
},
30
+ credentialType: {
31
+ type: String ,
32
+ default: ' ' ,
33
+ },
30
34
})
31
35
32
36
const buildBasicValString = (value : string | number | boolean , key : string ): string => {
33
37
const indent = SINGLE_INDENT
34
38
let content = ' '
35
39
36
40
if (typeof value === ' string' ) {
37
- content += ` \n ${indent }${key } = "${value }"`
41
+ content += ` ${indent }${key } = "${value }"\n `
38
42
} else { // boolean or number
39
- content += ` \n ${indent }${key } = ${String (value !== undefined && value !== null ? value : ' ' )}`
43
+ content += ` ${indent }${key } = ${String (value !== undefined && value !== null ? value : ' ' )}\n `
40
44
}
41
45
42
46
return content
@@ -52,7 +56,7 @@ const buildObjectStr = (value: Record<string, any>, key?: string, additionalInde
52
56
let content = ' '
53
57
54
58
if (key ) {
55
- content += ` \n ${indent }${key } = {\n `
59
+ content += ` ${indent }${key } = {\n `
56
60
}
57
61
58
62
if (value === null ) {
@@ -94,7 +98,7 @@ const buildObjectStr = (value: Record<string, any>, key?: string, additionalInde
94
98
content += ` ${indent }${SINGLE_INDENT }${k } = ${valueContent }\n `
95
99
}
96
100
97
- return key ? content += ` ${indent }} ` : content
101
+ return key ? content += ` ${indent }}\n ` : content
98
102
}
99
103
100
104
const buildArrayStr = (arr : any [], key ? : string , additionalIndent = ' ' ): string => {
@@ -108,7 +112,7 @@ const buildArrayStr = (arr: any[], key?: string, additionalIndent = ''): string
108
112
if (arr .length === 0 ) {
109
113
content += ` ${indent }${key } = [ `
110
114
} else {
111
- content += ` \n ${indent }${key } = [\n `
115
+ content += ` ${indent }${key } = [\n `
112
116
}
113
117
}
114
118
@@ -135,9 +139,9 @@ const buildArrayStr = (arr: any[], key?: string, additionalIndent = ''): string
135
139
136
140
if (key ) {
137
141
if (arr .length === 0 ) {
138
- content += ' ]'
142
+ content += ' ]\n '
139
143
} else {
140
- content += ` ${indent }] `
144
+ content += ` ${indent }]\n `
141
145
}
142
146
}
143
147
@@ -201,33 +205,33 @@ const terraformContent = computed((): string => {
201
205
// snis can be a child of certificate
202
206
parentEntityType = ' certificate'
203
207
delete modifiedRecord .certificate
204
- } else if (modifiedRecord .key_set ?.id ) {
208
+ } else if (modifiedRecord .set ?.id ) {
205
209
// keys can be a child of key_set
206
- parentEntityType = ' key_set '
207
- delete modifiedRecord .key_set
210
+ parentEntityType = ' set '
211
+ delete modifiedRecord .set
208
212
}
209
213
210
214
// special handling for plugins
211
215
if (props .entityType === ' plugin' ) {
212
216
// plugin type is specified separately
213
217
// clone and convert '-' to '_' since terraform doesn't allow '-'
214
- const pluginType = (modifiedRecord .name + ' ' ).replace (/ -/ g , ' _' )
218
+ const pluginType = props . credentialType . replace ( / - / g , ' _ ' ) || (modifiedRecord .name + ' ' ).replace (/ -/ g , ' _' )
215
219
delete modifiedRecord .name
216
220
217
- content += ` resource "konnect_gateway_plugin_${pluginType }" "my_${pluginType }" { `
221
+ content += ` resource "konnect_gateway_plugin_${pluginType }" "my_${pluginType }" {\n `
218
222
} else { // generic entity
219
- content += ` resource "konnect_gateway_${props .entityType }" "my_${props .entityType }" { `
223
+ content += ` resource "konnect_gateway_${props .entityType }" "my_${props .entityType }" {\n `
220
224
}
221
225
222
226
// main config
223
227
content += generateConfig (modifiedRecord )
224
228
225
229
// control plane id
226
- content += ` \n ${SINGLE_INDENT }control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id\n `
230
+ content += ` ${SINGLE_INDENT }control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id\n `
227
231
228
232
// parent entity information if scoped
229
233
if (parentEntityType ) {
230
- content += ` \n ${SINGLE_INDENT }${parentEntityType } = {\n `
234
+ content += ` ${SINGLE_INDENT }${parentEntityType } = {\n `
231
235
content += ` ${SINGLE_INDENT }${SINGLE_INDENT }id = konnect_gateway_${parentEntityType }.my_${parentEntityType }.id\n `
232
236
content += ` ${SINGLE_INDENT }}\n `
233
237
}
0 commit comments