Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<script setup lang="ts">
import { type PropType, computed } from 'vue'
import { type SupportedEntityType, SupportedEntityTypesArray } from '../../types'
import { EventGatewayTypesArray, type SupportedEntityType, SupportedEntityTypesArray } from '../../types'

const SINGLE_INDENT = ' '

Expand All @@ -31,6 +31,15 @@ const props = defineProps({
type: String,
default: '',
},
subEntityType: {
// only for event gateway entities
type: String,
default: '',
},
})

const isEventGatewayEntity = computed(() => {
return EventGatewayTypesArray.includes(props.entityType)
})

const buildBasicValString = (value: string | number | boolean, key: string): string => {
Expand Down Expand Up @@ -211,8 +220,14 @@ const terraformContent = computed((): string => {
delete modifiedRecord.set
}

// special handling for plugins
if (props.entityType === 'plugin') {
if (isEventGatewayEntity.value) {
// special handling for event gateways
const entityName = props.subEntityType
? `${props.entityType}_${props.subEntityType}`
: props.entityType
content += `resource "konnect_event_gateway_${entityName}" "my_eventgateway${entityName.replaceAll('_', '')}" {\n`
content += `${SINGLE_INDENT}provider = konnect-beta \n` // remove this line if provider changes
} else if (props.entityType === 'plugin') {
// plugin type is specified separately
//clone and convert '-' to '_' since terraform doesn't allow '-'
const pluginType = props.credentialType.replace(/-/g, '_') || (modifiedRecord.name + '').replace(/-/g, '_')
Expand All @@ -227,10 +242,9 @@ const terraformContent = computed((): string => {
content += generateConfig(modifiedRecord)

// control plane id
content += `${SINGLE_INDENT}control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id\n`

// parent entity information if scoped
if (parentEntityType) {
if (!isEventGatewayEntity.value) {
content += `${SINGLE_INDENT}control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id\n`
} else if (parentEntityType) { // parent entity information if scoped
content += `${SINGLE_INDENT}${parentEntityType} = {\n`
content += `${SINGLE_INDENT}${SINGLE_INDENT}id = konnect_gateway_${parentEntityType}.my_${parentEntityType}.id\n`
content += `${SINGLE_INDENT}}\n`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
v-if="format === 'terraform' && entityRecord"
:entity-record="entityRecord"
:entity-type="props.entityType"
:sub-entity-type="props.subEntityType"
/>
</template>

Expand Down Expand Up @@ -100,6 +101,11 @@ const props = defineProps({
required: true,
validator: (val: SupportedEntityType) => SupportedEntityTypesArray.includes(val),
},
subEntityType: {
// only for event gateway entities
type: String,
default: '',
},
propertyCollections: {
type: Object as PropType<PropList>,
required: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
:prop-list-types="propListTypes"
:property-collections="propertyLists"
:record="record"
:sub-entity-type="subEntityType"
>
<!-- Pass all the slots from GrandParent to Child components -->
<template
Expand Down Expand Up @@ -158,6 +159,13 @@ const props = defineProps({
required: true,
validator: (val: SupportedEntityType) => SupportedEntityTypesArray.includes(val),
},
/**
* Sub Entity type, required to generate terraform code for event gateway entities
*/
subEntityType: {
type: String,
default: '',
},
/** Record key that contains the plugin configuration */
pluginConfigKey: {
type: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ export enum SupportedEntityType {
BackendCluster = 'backend_cluster',
VirtualCluster = 'virtual_cluster',
Listener = 'listener',
Policy = 'policy',
ProducePolicy = 'produce_policy',
ConsumePolicy = 'consume_policy',
ClusterPolicy = 'cluster_policy',
ListenerPolicy = 'listener_policy',
SchemaRegistry = 'schema_registry',
StaticKey = 'static_key',
// Use this for any entity type that is not supported by terraform
// If entityType is 'other' terraform scripts will not be available
// Note: This is currently only supported by EntityBaseForm not EntityBaseConfigCard!!
Expand All @@ -32,6 +37,8 @@ export enum SupportedEntityType {

export const SupportedEntityTypesArray = Object.values(SupportedEntityType)

export const EventGatewayTypesArray = ['backend_cluster', 'virtual_cluster', 'listener', 'produce_policy', 'consume_policy', 'cluster_policy', 'listener_policy', 'schema_registry', 'static_key']

export interface BaseEntityConfig {
/** the ID of the entity */
entityId: string
Expand Down
Loading