Skip to content

Commit 25049a9

Browse files
committed
add expose binding support to milvus, qdrant, weaviate
Signed-off-by: Samiul <samiul@appscode.com>
1 parent 8103e6a commit 25049a9

7 files changed

Lines changed: 132 additions & 11 deletions

File tree

charts/kubedbcom-milvus-editor-options/ui/create-ui.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,12 @@ step:
604604
name: isToggleOn|tls
605605
type: function
606606
type: block-layout
607+
- if:
608+
name: isToggleOn|expose
609+
type: function
610+
label: Expose via Gateway?
611+
schema: schema/properties/spec/properties/admin/properties/expose/properties/enable/properties/default
612+
type: switch
607613
if:
608614
name: showAdditionalSettings
609615
type: function

charts/kubedbcom-milvus-editor/ui/edit-ui.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,4 +1024,18 @@ step:
10241024
id: monitoring
10251025
loader: initMonitoring
10261026
type: single-step-form
1027+
- elements:
1028+
- fullwidth: true
1029+
init:
1030+
type: func
1031+
value: isBindingAlreadyOn
1032+
label: Expose Database
1033+
schema: temp/properties/binding
1034+
type: switch
1035+
watcher:
1036+
func: addOrRemoveBinding
1037+
paths:
1038+
- temp/properties/binding
1039+
id: binding
1040+
type: single-step-form
10271041
type: multi-step-form

charts/kubedbcom-milvus-editor/ui/functions.js

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,7 @@ export const useFunc = (model) => {
116116
async function getIssuerRefsName() {
117117
const owner = storeGet('/route/params/user')
118118
const cluster = storeGet('/route/params/cluster')
119-
const kind = getValue(
120-
model,
121-
'/resources/kubedbComMilvus/spec/tls/issuerRef/kind',
122-
)
119+
const kind = getValue(model, '/resources/kubedbComMilvus/spec/tls/issuerRef/kind')
123120
const namespace = getValue(model, '/metadata/release/namespace')
124121

125122
if (kind === 'Issuer') {
@@ -672,10 +669,8 @@ export const useFunc = (model) => {
672669
function showOpsRequestOptions() {
673670
if (isKubedb()) return true
674671
return (
675-
!!getValue(
676-
model,
677-
'/resources/autoscalingKubedbComMilvusAutoscaler/spec/databaseRef/name',
678-
) && !!getValue(discriminator, '/autoscalingType')
672+
!!getValue(model, '/resources/autoscalingKubedbComMilvusAutoscaler/spec/databaseRef/name') &&
673+
!!getValue(discriminator, '/autoscalingType')
679674
)
680675
}
681676

@@ -771,6 +766,45 @@ export const useFunc = (model) => {
771766
}
772767
}
773768

769+
function isBindingAlreadyOn() {
770+
const value = getValue(model, '/resources')
771+
const keys = Object.keys(value)
772+
const isExposeBinding = !!keys.find((str) => str === 'catalogAppscodeComMariaDBBinding')
773+
return isExposeBinding
774+
}
775+
776+
function addOrRemoveBinding() {
777+
const value = getValue(discriminator, `/binding`)
778+
const dbName = getValue(model, '/metadata/release/name')
779+
const dbNamespace = getValue(model, '/metadata/release/namespace')
780+
const labels = getValue(model, '/resources/kubedbComMariaDB/metadata/labels')
781+
const bindingValues = {
782+
apiVersion: 'catalog.appscode.com/v1alpha1',
783+
kind: 'MariaDBBinding',
784+
metadata: {
785+
labels,
786+
name: dbName,
787+
namespace: dbNamespace,
788+
},
789+
spec: {
790+
sourceRef: {
791+
name: dbName,
792+
namespace: dbNamespace,
793+
},
794+
},
795+
}
796+
797+
if (value) {
798+
commit('wizard/model$update', {
799+
path: '/resources/catalogAppscodeComMariaDBBinding',
800+
value: bindingValues,
801+
force: true,
802+
})
803+
} else {
804+
commit('wizard/model$delete', '/resources/catalogAppscodeComMariaDBBinding')
805+
}
806+
}
807+
774808
return {
775809
returnFalse,
776810
returnTrue,
@@ -837,5 +871,8 @@ export const useFunc = (model) => {
837871
setApplyToIfReady,
838872
handleUnit,
839873
setValueFromDbDetails,
874+
875+
addOrRemoveBinding,
876+
isBindingAlreadyOn,
840877
}
841878
}

charts/kubedbcom-qdrant-editor-options/ui/create-ui.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,12 @@ step:
327327
name: isToggleOn|tls
328328
type: function
329329
type: block-layout
330+
- if:
331+
name: isToggleOn|expose
332+
type: function
333+
label: Expose via Gateway?
334+
schema: schema/properties/spec/properties/admin/properties/expose/properties/enable/properties/default
335+
type: switch
330336
if:
331337
name: showAdditionalSettings
332338
type: function

charts/kubedbcom-weaviate-editor-options/ui/create-ui.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,12 @@ step:
303303
validation:
304304
type: required
305305
type: block-layout
306-
if:
307-
name: returnFalse
308-
type: function
306+
- if:
307+
name: isToggleOn|expose
308+
type: function
309+
label: Expose via Gateway?
310+
schema: schema/properties/spec/properties/admin/properties/expose/properties/enable/properties/default
311+
type: switch
309312
label: Additional Options
310313
showLabels: true
311314
type: block-layout

charts/kubedbcom-weaviate-editor/ui/edit-ui.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,18 @@ step:
302302
type: block-layout
303303
id: storage-autoscaler
304304
type: single-step-form
305+
- elements:
306+
- fullwidth: true
307+
init:
308+
type: func
309+
value: isBindingAlreadyOn
310+
label: Expose Database
311+
schema: temp/properties/binding
312+
type: switch
313+
watcher:
314+
func: addOrRemoveBinding
315+
paths:
316+
- temp/properties/binding
317+
id: binding
318+
type: single-step-form
305319
type: multi-step-form

charts/kubedbcom-weaviate-editor/ui/functions.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,45 @@ export const useFunc = (model) => {
554554
return showStoragememory
555555
}
556556

557+
function isBindingAlreadyOn() {
558+
const value = getValue(model, '/resources')
559+
const keys = Object.keys(value)
560+
const isExposeBinding = !!keys.find((str) => str === 'catalogAppscodeComMariaDBBinding')
561+
return isExposeBinding
562+
}
563+
564+
function addOrRemoveBinding() {
565+
const value = getValue(discriminator, `/binding`)
566+
const dbName = getValue(model, '/metadata/release/name')
567+
const dbNamespace = getValue(model, '/metadata/release/namespace')
568+
const labels = getValue(model, '/resources/kubedbComMariaDB/metadata/labels')
569+
const bindingValues = {
570+
apiVersion: 'catalog.appscode.com/v1alpha1',
571+
kind: 'MariaDBBinding',
572+
metadata: {
573+
labels,
574+
name: dbName,
575+
namespace: dbNamespace,
576+
},
577+
spec: {
578+
sourceRef: {
579+
name: dbName,
580+
namespace: dbNamespace,
581+
},
582+
},
583+
}
584+
585+
if (value) {
586+
commit('wizard/model$update', {
587+
path: '/resources/catalogAppscodeComMariaDBBinding',
588+
value: bindingValues,
589+
force: true,
590+
})
591+
} else {
592+
commit('wizard/model$delete', '/resources/catalogAppscodeComMariaDBBinding')
593+
}
594+
}
595+
557596
return {
558597
isKubedb,
559598
isConsole,
@@ -584,5 +623,7 @@ export const useFunc = (model) => {
584623
returnFalse,
585624
setValueFromDbDetails,
586625
showStorageMemoryOption,
626+
isBindingAlreadyOn,
627+
addOrRemoveBinding,
587628
}
588629
}

0 commit comments

Comments
 (0)