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 @@ -93,6 +93,12 @@ A form component for Redis Configurations.
- default: `undefined`
- Whether the server_name field can accept vault references.

- `isCEFieldsReferenceable`
- type: `boolean`
- required: `false`
- default: `undefined`
- Whether the CE partial fields can accept vault references.

The base konnect or kongManger config.

#### `partialId`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const kongManagerConfig: KongManagerRedisConfigurationFormConfig = {
isPortReferenceable: true,
isHostReferenceable: true,
isServerNameReferenceable: true,
isCEFieldsReferenceable: true,
cancelRoute: { name: 'redis-configuration-list' },
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const baseConfigKM: KongManagerRedisConfigurationFormConfig = {
isPortReferenceable: true,
isHostReferenceable: true,
isServerNameReferenceable: true,
isCEFieldsReferenceable: true,
cancelRoute,
}

Expand All @@ -29,6 +30,7 @@ const baseConfigKonnect: KonnectRedisConfigurationFormConfig = {
isPortReferenceable: true,
isHostReferenceable: true,
isServerNameReferenceable: true,
isCEFieldsReferenceable: false,
cancelRoute,
}

Expand Down Expand Up @@ -175,9 +177,12 @@ describe('<RedisConfigurationForm />', {
cy.getTestId('redis-connection-is-proxied-checkbox').should('not.exist')

cy.getTestId('redis-host-input').should('be.visible')
cy.getTestId('secret-picker-provider-for-host').should(config.isCEFieldsReferenceable ? 'be.visible' : 'not.exist')
cy.getTestId('redis-port-input').should('be.visible')
cy.getTestId('secret-picker-provider-for-port').should(config.isCEFieldsReferenceable ? 'be.visible' : 'not.exist')
cy.getTestId('redis-timeout-input').should('be.visible')
cy.getTestId('redis-auth-provider-select').should('be.visible')
cy.getTestId('secret-picker-provider-for-server_name').should(config.isCEFieldsReferenceable ? 'be.visible' : 'not.exist')

// Host/Port EE fields
cy.getTestId('redis-type-select').click()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
:readonly="form.readonly"
/>
<VaultSecretPickerProvider
v-if="redisType === RedisType.HOST_PORT_EE && config.isHostReferenceable"
v-if="isReferenceable.host"
class="secret-picker-provider"
data-testid="secret-picker-provider-for-host"
:disabled="form.readonly"
Expand All @@ -242,7 +242,7 @@
:readonly="form.readonly"
/>
<VaultSecretPickerProvider
v-if="redisType === RedisType.HOST_PORT_EE && config.isPortReferenceable"
v-if="isReferenceable.port"
class="secret-picker-provider"
data-testid="secret-picker-provider-for-port"
:disabled="form.readonly"
Expand Down Expand Up @@ -364,7 +364,7 @@
:readonly="form.readonly"
/>
<VaultSecretPickerProvider
v-if="redisType === RedisType.HOST_PORT_EE && config.isServerNameReferenceable"
v-if="isReferenceable.serverName"
class="secret-picker-provider"
data-testid="secret-picker-provider-for-server_name"
:disabled="form.readonly"
Expand Down Expand Up @@ -563,6 +563,18 @@ const router = useRouter()

const codeBlockType = ref<string>('json')

const isReferenceable = computed<{ host: boolean, port: boolean, serverName: boolean }>(() => {
const canReferenceFields =
redisType.value === RedisType.HOST_PORT_EE ||
(redisType.value === RedisType.HOST_PORT_CE && !!props.config.isCEFieldsReferenceable)

return {
host: canReferenceFields && !!props.config.isHostReferenceable,
port: canReferenceFields && !!props.config.isPortReferenceable,
serverName: canReferenceFields && !!props.config.isServerNameReferenceable,
}
})

const typeOptions = computed<SelectItem[]>(() => {
return [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ export const useRedisConfigurationForm = (options: Options) => {
config: {
cloud_authentication: getCloudAuthConfig(),
host: form.fields.config.host,
port: s.int(form.fields.config.port),
port: Number.isNaN(Number(form.fields.config.port))
? form.fields.config.port
: s.int(form.fields.config.port),
timeout: s.int(form.fields.config.timeout),
username: s.str(form.fields.config.username, null),
database: s.int(form.fields.config.database),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export interface BaseRedisConfigurationFormConfig {
* Whether the server_name field can accept vault references
*/
isServerNameReferenceable?: boolean
/**
* Whether the above three fields can accept vault references in Redis CE partials
*/
isCEFieldsReferenceable?: boolean
}

export interface KonnectRedisConfigurationFormConfig extends KonnectBaseFormConfig, BaseRedisConfigurationFormConfig { }
Expand Down
Loading