Skip to content

Commit 3f0ea8e

Browse files
authored
fix key pair validation in db vertical scaling ops (#1087)
Signed-off-by: shofiq <shofiq@appscode.com>
1 parent 635183e commit 3f0ea8e

59 files changed

Lines changed: 1093 additions & 849 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

charts/opskubedbcom-cassandraopsrequest-editor/ui/create-ui.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,18 +196,22 @@ step:
196196
example, 'zone=us-central1-a' ensures workloads are deployed in that zone.
197197
type: label-element
198198
- elements:
199-
- label: Key
200-
schema: temp/topologyKey
201-
type: input
199+
- type: input
200+
label: Key
201+
schema: schema/properties/spec/properties/verticalScaling/properties/node/properties/topology/properties/key
202202
validation:
203-
name: isVerticalScaleTopologyRequired
204203
type: custom
205-
- label: Value
206-
schema: temp/topologyValue
207-
type: input
204+
name: isVerticalScaleTopologyRequired|node|key
205+
watchPaths:
206+
- schema/properties/spec/properties/verticalScaling/properties/node/properties/topology/properties/value
207+
- type: input
208+
label: Value
209+
schema: schema/properties/spec/properties/verticalScaling/properties/node/properties/topology/properties/value
208210
validation:
209-
name: isVerticalScaleTopologyRequired
210211
type: custom
212+
name: isVerticalScaleTopologyRequired|node|value
213+
watchPaths:
214+
- schema/properties/spec/properties/verticalScaling/properties/node/properties/topology/properties/key
211215
type: horizontal-layout
212216
label: Node Selection
213217
showLabels: true

charts/opskubedbcom-cassandraopsrequest-editor/ui/functions.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,24 +1648,22 @@ export const useFunc = (model) => {
16481648
return 'IfReady'
16491649
}
16501650

1651-
function isVerticalScaleTopologyRequired() {
1652-
// watchDependency('discriminator#/topologyKey')
1653-
// watchDependency('discriminator#/topologyValue')
1651+
function isVerticalScaleTopologyRequired(type, mode) {
1652+
// watchDependency(`discriminator#/topologyKey`)
1653+
// watchDependency(`discriminator#/topologyValue`)
1654+
const path = `/spec/verticalScaling/${type}/topology`
16541655

1655-
const key = getValue(discriminator, '/topologyKey')
1656-
const value = getValue(discriminator, '/topologyValue')
1657-
const path = `/spec/verticalScaling/node/topology`
1656+
const key = String(getValue(model, `${path}/key`) ?? '').trim()
1657+
const value = String(getValue(model, `${path}/value`) ?? '').trim()
16581658

1659-
if (key || value) {
1660-
commit('wizard/model$update', {
1661-
path: path,
1662-
value: { key, value },
1663-
force: true,
1664-
})
1665-
return ''
1666-
} else {
1659+
if (!key && !value) {
16671660
commit('wizard/model$delete', path)
1668-
return false
1661+
}
1662+
const missingPair = mode === 'key' ? !key && value : key && !value
1663+
if (missingPair) {
1664+
return mode === 'key'
1665+
? 'Key is required when Value is provided'
1666+
: 'Value is required when Key is provided'
16691667
}
16701668
}
16711669

charts/opskubedbcom-clickhouseopsrequest-editor/ui/create-ui.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,18 +196,22 @@ step:
196196
example, 'zone=us-central1-a' ensures workloads are deployed in that zone.
197197
type: label-element
198198
- elements:
199-
- label: Key
200-
schema: temp/topologyKey
201-
type: input
199+
- type: input
200+
label: Key
201+
schema: schema/properties/spec/properties/verticalScaling/properties/node/properties/topology/properties/key
202202
validation:
203-
name: isVerticalScaleTopologyRequired
204203
type: custom
205-
- label: Value
206-
schema: temp/topologyValue
207-
type: input
204+
name: isVerticalScaleTopologyRequired|node|key
205+
watchPaths:
206+
- schema/properties/spec/properties/verticalScaling/properties/node/properties/topology/properties/value
207+
- type: input
208+
label: Value
209+
schema: schema/properties/spec/properties/verticalScaling/properties/node/properties/topology/properties/value
208210
validation:
209-
name: isVerticalScaleTopologyRequired
210211
type: custom
212+
name: isVerticalScaleTopologyRequired|node|value
213+
watchPaths:
214+
- schema/properties/spec/properties/verticalScaling/properties/node/properties/topology/properties/key
211215
type: horizontal-layout
212216
label: Node Selection
213217
showLabels: true

charts/opskubedbcom-clickhouseopsrequest-editor/ui/functions.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,24 +1660,22 @@ export const useFunc = (model) => {
16601660
return 'IfReady'
16611661
}
16621662

1663-
function isVerticalScaleTopologyRequired() {
1664-
// watchDependency('discriminator#/topologyKey')
1665-
// watchDependency('discriminator#/topologyValue')
1663+
function isVerticalScaleTopologyRequired(type, mode) {
1664+
// watchDependency(`discriminator#/topologyKey`)
1665+
// watchDependency(`discriminator#/topologyValue`)
1666+
const path = `/spec/verticalScaling/${type}/topology`
16661667

1667-
const key = getValue(discriminator, '/topologyKey')
1668-
const value = getValue(discriminator, '/topologyValue')
1669-
const path = `/spec/verticalScaling/node/topology`
1668+
const key = String(getValue(model, `${path}/key`) ?? '').trim()
1669+
const value = String(getValue(model, `${path}/value`) ?? '').trim()
16701670

1671-
if (key || value) {
1672-
commit('wizard/model$update', {
1673-
path: path,
1674-
value: { key, value },
1675-
force: true,
1676-
})
1677-
return ''
1678-
} else {
1671+
if (!key && !value) {
16791672
commit('wizard/model$delete', path)
1680-
return false
1673+
}
1674+
const missingPair = mode === 'key' ? !key && value : key && !value
1675+
if (missingPair) {
1676+
return mode === 'key'
1677+
? 'Key is required when Value is provided'
1678+
: 'Value is required when Key is provided'
16811679
}
16821680
}
16831681

charts/opskubedbcom-documentdbopsrequest-editor/ui/create-ui.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,18 +196,22 @@ step:
196196
example, 'zone=us-central1-a' ensures workloads are deployed in that zone.
197197
type: label-element
198198
- elements:
199-
- label: Key
200-
schema: temp/topologyKey
201-
type: input
199+
- type: input
200+
label: Key
201+
schema: schema/properties/spec/properties/verticalScaling/properties/documentdb/properties/topology/properties/key
202202
validation:
203-
name: isVerticalScaleTopologyRequired
204203
type: custom
205-
- label: Value
206-
schema: temp/topologyValue
207-
type: input
204+
name: isVerticalScaleTopologyRequired|documentdb|key
205+
watchPaths:
206+
- schema/properties/spec/properties/verticalScaling/properties/documentdb/properties/topology/properties/value
207+
- type: input
208+
label: Value
209+
schema: schema/properties/spec/properties/verticalScaling/properties/documentdb/properties/topology/properties/value
208210
validation:
209-
name: isVerticalScaleTopologyRequired
210211
type: custom
212+
name: isVerticalScaleTopologyRequired|documentdb|value
213+
watchPaths:
214+
- schema/properties/spec/properties/verticalScaling/properties/documentdb/properties/topology/properties/key
211215
type: horizontal-layout
212216
label: Node Selection
213217
showLabels: true

charts/opskubedbcom-documentdbopsrequest-editor/ui/functions.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,24 +1659,22 @@ export const useFunc = (model) => {
16591659
return 'IfReady'
16601660
}
16611661

1662-
function isVerticalScaleTopologyRequired() {
1663-
// watchDependency('discriminator#/topologyKey')
1664-
// watchDependency('discriminator#/topologyValue')
1662+
function isVerticalScaleTopologyRequired(type, mode) {
1663+
// watchDependency(`discriminator#/topologyKey`)
1664+
// watchDependency(`discriminator#/topologyValue`)
1665+
const path = `/spec/verticalScaling/${type}/topology`
16651666

1666-
const key = getValue(discriminator, '/topologyKey')
1667-
const value = getValue(discriminator, '/topologyValue')
1668-
const path = `/spec/verticalScaling/documentdb/topology`
1667+
const key = String(getValue(model, `${path}/key`) ?? '').trim()
1668+
const value = String(getValue(model, `${path}/value`) ?? '').trim()
16691669

1670-
if (key || value) {
1671-
commit('wizard/model$update', {
1672-
path: path,
1673-
value: { key, value },
1674-
force: true,
1675-
})
1676-
return ''
1677-
} else {
1670+
if (!key && !value) {
16781671
commit('wizard/model$delete', path)
1679-
return false
1672+
}
1673+
const missingPair = mode === 'key' ? !key && value : key && !value
1674+
if (missingPair) {
1675+
return mode === 'key'
1676+
? 'Key is required when Value is provided'
1677+
: 'Value is required when Key is provided'
16801678
}
16811679
}
16821680

charts/opskubedbcom-druidopsrequest-editor/ui/create-ui.yaml

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,22 @@ step:
282282
example, 'zone=us-central1-a' ensures workloads are deployed in that zone.
283283
type: label-element
284284
- elements:
285-
- label: Key
285+
- type: input
286+
label: Key
286287
schema: schema/properties/spec/properties/verticalScaling/properties/middleManagers/properties/topology/properties/key
287-
type: input
288-
- label: Value
288+
validation:
289+
type: custom
290+
name: isVerticalScaleTopologyRequired|middleManagers|key
291+
watchPaths:
292+
- schema/properties/spec/properties/verticalScaling/properties/middleManagers/properties/topology/properties/value
293+
- type: input
294+
label: Value
289295
schema: schema/properties/spec/properties/verticalScaling/properties/middleManagers/properties/topology/properties/value
290-
type: input
296+
validation:
297+
type: custom
298+
name: isVerticalScaleTopologyRequired|middleManagers|value
299+
watchPaths:
300+
- schema/properties/spec/properties/verticalScaling/properties/middleManagers/properties/topology/properties/key
291301
type: horizontal-layout
292302
label: Node Selection
293303
showLabels: true
@@ -343,12 +353,22 @@ step:
343353
example, 'zone=us-central1-a' ensures workloads are deployed in that zone.
344354
type: label-element
345355
- elements:
346-
- label: Key
356+
- type: input
357+
label: Key
347358
schema: schema/properties/spec/properties/verticalScaling/properties/historicals/properties/topology/properties/key
348-
type: input
349-
- label: Value
359+
validation:
360+
type: custom
361+
name: isVerticalScaleTopologyRequired|historicals|key
362+
watchPaths:
363+
- schema/properties/spec/properties/verticalScaling/properties/historicals/properties/topology/properties/value
364+
- type: input
365+
label: Value
350366
schema: schema/properties/spec/properties/verticalScaling/properties/historicals/properties/topology/properties/value
351-
type: input
367+
validation:
368+
type: custom
369+
name: isVerticalScaleTopologyRequired|historicals|value
370+
watchPaths:
371+
- schema/properties/spec/properties/verticalScaling/properties/historicals/properties/topology/properties/key
352372
type: horizontal-layout
353373
label: Node Selection
354374
showLabels: true
@@ -404,12 +424,22 @@ step:
404424
example, 'zone=us-central1-a' ensures workloads are deployed in that zone.
405425
type: label-element
406426
- elements:
407-
- label: Key
427+
- type: input
428+
label: Key
408429
schema: schema/properties/spec/properties/verticalScaling/properties/brokers/properties/topology/properties/key
409-
type: input
410-
- label: Value
430+
validation:
431+
type: custom
432+
name: isVerticalScaleTopologyRequired|brokers|key
433+
watchPaths:
434+
- schema/properties/spec/properties/verticalScaling/properties/brokers/properties/topology/properties/value
435+
- type: input
436+
label: Value
411437
schema: schema/properties/spec/properties/verticalScaling/properties/brokers/properties/topology/properties/value
412-
type: input
438+
validation:
439+
type: custom
440+
name: isVerticalScaleTopologyRequired|brokers|value
441+
watchPaths:
442+
- schema/properties/spec/properties/verticalScaling/properties/brokers/properties/topology/properties/key
413443
type: horizontal-layout
414444
label: Node Selection
415445
showLabels: true
@@ -465,12 +495,22 @@ step:
465495
example, 'zone=us-central1-a' ensures workloads are deployed in that zone.
466496
type: label-element
467497
- elements:
468-
- label: Key
498+
- type: input
499+
label: Key
469500
schema: schema/properties/spec/properties/verticalScaling/properties/coordinators/properties/topology/properties/key
470-
type: input
471-
- label: Value
501+
validation:
502+
type: custom
503+
name: isVerticalScaleTopologyRequired|coordinators|key
504+
watchPaths:
505+
- schema/properties/spec/properties/verticalScaling/properties/coordinators/properties/topology/properties/value
506+
- type: input
507+
label: Value
472508
schema: schema/properties/spec/properties/verticalScaling/properties/coordinators/properties/topology/properties/value
473-
type: input
509+
validation:
510+
type: custom
511+
name: isVerticalScaleTopologyRequired|coordinators|value
512+
watchPaths:
513+
- schema/properties/spec/properties/verticalScaling/properties/coordinators/properties/topology/properties/key
474514
type: horizontal-layout
475515
label: Node Selection
476516
showLabels: true

charts/opskubedbcom-druidopsrequest-editor/ui/functions.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -991,24 +991,22 @@ export const useFunc = (model) => {
991991
// VERTICAL SCALING FUNCTIONS
992992
// ============================================================
993993

994-
function isVerticalScaleTopologyRequired(type) {
995-
// watchDependency(`discriminator#/topologyKey-${type}`)
996-
// watchDependency(`discriminator#/topologyValue-${type}`)
997-
998-
const key = getValue(discriminator, `/topologyKey-${type}`)
999-
const value = getValue(discriminator, `/topologyValue-${type}`)
994+
function isVerticalScaleTopologyRequired(type, mode) {
995+
// watchDependency(`discriminator#/topologyKey`)
996+
// watchDependency(`discriminator#/topologyValue`)
1000997
const path = `/spec/verticalScaling/${type}/topology`
1001998

1002-
if (key || value) {
1003-
commit('wizard/model$update', {
1004-
path: path,
1005-
value: { key, value },
1006-
force: true,
1007-
})
1008-
return ''
1009-
} else {
999+
const key = String(getValue(model, `${path}/key`) ?? '').trim()
1000+
const value = String(getValue(model, `${path}/value`) ?? '').trim()
1001+
1002+
if (!key && !value) {
10101003
commit('wizard/model$delete', path)
1011-
return false
1004+
}
1005+
const missingPair = mode === 'key' ? !key && value : key && !value
1006+
if (missingPair) {
1007+
return mode === 'key'
1008+
? 'Key is required when Value is provided'
1009+
: 'Value is required when Key is provided'
10121010
}
10131011
}
10141012

0 commit comments

Comments
 (0)