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
12 changes: 11 additions & 1 deletion charts/kubedbcom-redis-editor-options/ui/create-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,19 @@ step:
- element:
label: Shard Endpoints (comma-separated, e.g. "endpoint1,endpoint2,endpoint3")
type: input
init:
type: func
value: setAnnounceShards
label: Shards
schema: schema/properties/spec/properties/cluster/properties/announce/properties/shards
schema: temp/announceShards
type: array-item-form
validation:
type: custom
name: validateAnnounceShards
watcher:
func: onAnnounceShardsChange
paths:
- temp/announceShards
if:
name: showAnnounce
type: function
Expand Down
43 changes: 43 additions & 0 deletions charts/kubedbcom-redis-editor-options/ui/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,46 @@ export const useFunc = (model) => {
})
}

function setAnnounceShards() {
const shards = getValue(model, '/spec/cluster/announce/shards') || []
return shards.map((shard) => (shard?.endpoints || []).join(','))
}

function onAnnounceShardsChange() {
const shards = getValue(discriminator, '/announceShards') || []
const transformed = shards.map((shard) => ({
endpoints: (shard || '')
.split(',')
.map((endpoint) => endpoint.trim())
.filter((endpoint) => endpoint),
}))

commit('wizard/model$update', {
path: '/spec/cluster/announce/shards',
value: transformed,
force: true,
})
}

function validateAnnounceShards() {
const shards = getValue(discriminator, '/announceShards') || []
const master = getValue(model, '/spec/cluster/master') || 0
const replicas = getValue(model, '/spec/cluster/replicas') || 0
if (shards.length !== master) {
return `Shards Length should be equal to master(${master})`
}
for (let i = 0; i < shards.length; i++) {
const shard = shards[i]
const endpoints = shard
.split(',')
.map((endpoint) => endpoint.trim())
.filter((endpoint) => endpoint)
if (endpoints.length !== replicas) {
return `Each Shard should have ${replicas} comma-separated endpoints, but found ${endpoints.length}.`
}
}
}

function setBackup() {
const backup = getValue(model, '/spec/backup/tool')
const val = getValue(model, '/spec/admin/backup/enable/default')
Expand Down Expand Up @@ -1427,13 +1467,16 @@ export const useFunc = (model) => {
isToggleOn,
isVariantAvailable,
notEqualToDatabaseMode,
onAnnounceShardsChange,
validateAnnounceShards,
onAuthChange,
onBackupSwitch,
onCreateSentinelChange,
onReferSecretChange,
returnFalse,
returnTrue,
setAnnounce,
setAnnounceShards,
setBackup,
setLimits,
setMachineToCustom,
Expand Down
Loading