Skip to content

Commit

Permalink
fix(entities-plugins): omit redis cluster/sentinel addresses if empty (
Browse files Browse the repository at this point in the history
  • Loading branch information
sumimakito committed Apr 29, 2024
1 parent 10efd2d commit 64283b7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/entities/entities-plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@kong-ui-public/i18n": "workspace:^",
"@kong/design-tokens": "1.12.11",
"@kong/kongponents": "9.0.0-alpha.146",
"@types/lodash-es": "^4.17.12",
"axios": "^1.6.8",
"vue": "^3.4.21",
"vue-router": "^4.3.0"
Expand Down Expand Up @@ -80,6 +81,7 @@
"@kong-ui-public/entities-shared": "workspace:^",
"@kong-ui-public/forms": "^3.1.0",
"@kong/icons": "^1.9.1",
"lodash-es": "^4.17.21",
"marked": "^12.0.1"
}
}
13 changes: 11 additions & 2 deletions packages/entities/entities-plugins/src/components/PluginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,12 @@ import {
import '@kong-ui-public/entities-shared/dist/style.css'
import type { Tab } from '@kong/kongponents'
import type { AxiosError, AxiosResponse } from 'axios'
import { cloneDeep, get, has, unset } from 'lodash-es'
import { marked, type MarkedOptions } from 'marked'
import { CREDENTIAL_METADATA, CREDENTIAL_SCHEMAS, PLUGIN_METADATA } from '../definitions/metadata'
import { computed, onBeforeMount, reactive, ref, watch, type PropType } from 'vue'
import { useRouter } from 'vue-router'
import composables from '../composables'
import { CREDENTIAL_METADATA, CREDENTIAL_SCHEMAS, PLUGIN_METADATA } from '../definitions/metadata'
import { ArrayStringFieldSchema } from '../definitions/schemas/ArrayStringFieldSchema'
import endpoints from '../plugins-endpoints'
import {
Expand Down Expand Up @@ -1004,7 +1005,15 @@ const isCustomPlugin = computed((): boolean => {
})
const getRequestBody = computed((): Record<string, any> => {
const requestBody: Record<string, any> = submitPayload.value
const requestBody: Record<string, any> = cloneDeep(submitPayload.value)
// FIXME !!! KAG-4328: Handle Redis config fields - Omit them if they are empty
for (const keyPath of ['config.redis.cluster_addresses', 'config.redis.sentinel_addresses']) {
if (has(requestBody, keyPath) && Array.isArray(get(requestBody, keyPath)) && get(requestBody, keyPath).length === 0) {
unset(requestBody, keyPath)
}
}
// credentials incorrectly build the entity id object
if (treatAsCredential.value) {
for (const key in PluginScope) {
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit 64283b7

Please sign in to comment.