diff --git a/charts/kubedbcom-milvus-editor-options/templates/binding.yaml b/charts/kubedbcom-milvus-editor-options/templates/binding.yaml new file mode 100644 index 0000000000..fd8f5c8321 --- /dev/null +++ b/charts/kubedbcom-milvus-editor-options/templates/binding.yaml @@ -0,0 +1,16 @@ +{{- if .Values.spec.admin.expose.enable.default }} +apiVersion: catalog.appscode.com/v1alpha1 +kind: MilvusBinding +metadata: + name: {{ include "kubedbcom-milvus-editor-options.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "kubedbcom-milvus-editor-options.labels" . | nindent 4 }} +spec: + sourceRef: + name: {{ include "kubedbcom-milvus-editor-options.fullname" . }} + namespace: {{ .Release.Namespace }} + uiExposure: + disableUI: {{ .Values.spec.admin.expose.uiExposure.disableUI }} + disableCostEfficiency: {{ .Values.spec.admin.expose.uiExposure.disableCostEfficiency }} +{{- end }} \ No newline at end of file diff --git a/charts/kubedbcom-milvus-editor-options/ui/create-ui.yaml b/charts/kubedbcom-milvus-editor-options/ui/create-ui.yaml index c3d5b6688f..1907e3713b 100644 --- a/charts/kubedbcom-milvus-editor-options/ui/create-ui.yaml +++ b/charts/kubedbcom-milvus-editor-options/ui/create-ui.yaml @@ -604,6 +604,12 @@ step: name: isToggleOn|tls type: function type: block-layout + - if: + name: isToggleOn|expose + type: function + label: Expose via Gateway? + schema: schema/properties/spec/properties/admin/properties/expose/properties/enable/properties/default + type: switch if: name: showAdditionalSettings type: function diff --git a/charts/kubedbcom-milvus-editor/ui/edit-ui.yaml b/charts/kubedbcom-milvus-editor/ui/edit-ui.yaml index 58329a0105..16011a830d 100644 --- a/charts/kubedbcom-milvus-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-milvus-editor/ui/edit-ui.yaml @@ -1024,4 +1024,18 @@ step: id: monitoring loader: initMonitoring type: single-step-form +- elements: + - fullwidth: true + init: + type: func + value: isBindingAlreadyOn + label: Expose Database + schema: temp/properties/binding + type: switch + watcher: + func: addOrRemoveBinding + paths: + - temp/properties/binding + id: binding + type: single-step-form type: multi-step-form diff --git a/charts/kubedbcom-milvus-editor/ui/functions.js b/charts/kubedbcom-milvus-editor/ui/functions.js index 09ed811475..2139a1b64d 100644 --- a/charts/kubedbcom-milvus-editor/ui/functions.js +++ b/charts/kubedbcom-milvus-editor/ui/functions.js @@ -116,10 +116,7 @@ export const useFunc = (model) => { async function getIssuerRefsName() { const owner = storeGet('/route/params/user') const cluster = storeGet('/route/params/cluster') - const kind = getValue( - model, - '/resources/kubedbComMilvus/spec/tls/issuerRef/kind', - ) + const kind = getValue(model, '/resources/kubedbComMilvus/spec/tls/issuerRef/kind') const namespace = getValue(model, '/metadata/release/namespace') if (kind === 'Issuer') { @@ -672,10 +669,8 @@ export const useFunc = (model) => { function showOpsRequestOptions() { if (isKubedb()) return true return ( - !!getValue( - model, - '/resources/autoscalingKubedbComMilvusAutoscaler/spec/databaseRef/name', - ) && !!getValue(discriminator, '/autoscalingType') + !!getValue(model, '/resources/autoscalingKubedbComMilvusAutoscaler/spec/databaseRef/name') && + !!getValue(discriminator, '/autoscalingType') ) } @@ -771,6 +766,45 @@ export const useFunc = (model) => { } } + function isBindingAlreadyOn() { + const value = getValue(model, '/resources') + const keys = Object.keys(value) + const isExposeBinding = !!keys.find((str) => str === 'catalogAppscodeComMilvusBinding') + return isExposeBinding + } + + function addOrRemoveBinding() { + const value = getValue(discriminator, `/binding`) + const dbName = getValue(model, '/metadata/release/name') + const dbNamespace = getValue(model, '/metadata/release/namespace') + const labels = getValue(model, '/resources/kubedbComMilvus/metadata/labels') + const bindingValues = { + apiVersion: 'catalog.appscode.com/v1alpha1', + kind: 'MilvusBinding', + metadata: { + labels, + name: dbName, + namespace: dbNamespace, + }, + spec: { + sourceRef: { + name: dbName, + namespace: dbNamespace, + }, + }, + } + + if (value) { + commit('wizard/model$update', { + path: '/resources/catalogAppscodeComMilvusBinding', + value: bindingValues, + force: true, + }) + } else { + commit('wizard/model$delete', '/resources/catalogAppscodeComMilvusBinding') + } + } + return { returnFalse, returnTrue, @@ -837,5 +871,8 @@ export const useFunc = (model) => { setApplyToIfReady, handleUnit, setValueFromDbDetails, + + addOrRemoveBinding, + isBindingAlreadyOn, } } diff --git a/charts/kubedbcom-qdrant-editor-options/templates/binding.yaml b/charts/kubedbcom-qdrant-editor-options/templates/binding.yaml new file mode 100644 index 0000000000..1883e76f14 --- /dev/null +++ b/charts/kubedbcom-qdrant-editor-options/templates/binding.yaml @@ -0,0 +1,16 @@ +{{- if .Values.spec.admin.expose.enable.default }} +apiVersion: catalog.appscode.com/v1alpha1 +kind: QdrantBinding +metadata: + name: {{ include "kubedbcom-qdrant-editor.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "kubedbcom-qdrant-editor.labels" . | nindent 4 }} +spec: + sourceRef: + name: {{ include "kubedbcom-qdrant-editor.fullname" . }} + namespace: {{ .Release.Namespace }} + uiExposure: + disableUI: {{ .Values.spec.admin.expose.uiExposure.disableUI }} + disableCostEfficiency: {{ .Values.spec.admin.expose.uiExposure.disableCostEfficiency }} +{{- end }} \ No newline at end of file diff --git a/charts/kubedbcom-qdrant-editor-options/ui/create-ui.yaml b/charts/kubedbcom-qdrant-editor-options/ui/create-ui.yaml index 573a3def62..654870e11d 100644 --- a/charts/kubedbcom-qdrant-editor-options/ui/create-ui.yaml +++ b/charts/kubedbcom-qdrant-editor-options/ui/create-ui.yaml @@ -327,6 +327,12 @@ step: name: isToggleOn|tls type: function type: block-layout + - if: + name: isToggleOn|expose + type: function + label: Expose via Gateway? + schema: schema/properties/spec/properties/admin/properties/expose/properties/enable/properties/default + type: switch if: name: showAdditionalSettings type: function diff --git a/charts/kubedbcom-weaviate-editor-options/templates/binding.yaml b/charts/kubedbcom-weaviate-editor-options/templates/binding.yaml new file mode 100644 index 0000000000..8eb93701ae --- /dev/null +++ b/charts/kubedbcom-weaviate-editor-options/templates/binding.yaml @@ -0,0 +1,16 @@ +{{- if .Values.spec.admin.expose.enable.default }} +apiVersion: catalog.appscode.com/v1alpha1 +kind: WeaviateBinding +metadata: + name: {{ include "kubedbcom-weaviate-editor-options.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "kubedbcom-weaviate-editor-options.labels" . | nindent 4 }} +spec: + sourceRef: + name: {{ include "kubedbcom-weaviate-editor-options.fullname" . }} + namespace: {{ .Release.Namespace }} + uiExposure: + disableUI: {{ .Values.spec.admin.expose.uiExposure.disableUI }} + disableCostEfficiency: {{ .Values.spec.admin.expose.uiExposure.disableCostEfficiency }} +{{- end }} \ No newline at end of file diff --git a/charts/kubedbcom-weaviate-editor-options/ui/create-ui.yaml b/charts/kubedbcom-weaviate-editor-options/ui/create-ui.yaml index 2b2e6e35de..6751320069 100644 --- a/charts/kubedbcom-weaviate-editor-options/ui/create-ui.yaml +++ b/charts/kubedbcom-weaviate-editor-options/ui/create-ui.yaml @@ -303,9 +303,12 @@ step: validation: type: required type: block-layout - if: - name: returnFalse - type: function + - if: + name: isToggleOn|expose + type: function + label: Expose via Gateway? + schema: schema/properties/spec/properties/admin/properties/expose/properties/enable/properties/default + type: switch label: Additional Options showLabels: true type: block-layout diff --git a/charts/kubedbcom-weaviate-editor/ui/edit-ui.yaml b/charts/kubedbcom-weaviate-editor/ui/edit-ui.yaml index 5404d69b7b..747ff2943e 100644 --- a/charts/kubedbcom-weaviate-editor/ui/edit-ui.yaml +++ b/charts/kubedbcom-weaviate-editor/ui/edit-ui.yaml @@ -302,4 +302,18 @@ step: type: block-layout id: storage-autoscaler type: single-step-form +- elements: + - fullwidth: true + init: + type: func + value: isBindingAlreadyOn + label: Expose Database + schema: temp/properties/binding + type: switch + watcher: + func: addOrRemoveBinding + paths: + - temp/properties/binding + id: binding + type: single-step-form type: multi-step-form diff --git a/charts/kubedbcom-weaviate-editor/ui/functions.js b/charts/kubedbcom-weaviate-editor/ui/functions.js index 0e871c63b8..ff1e3ca91e 100644 --- a/charts/kubedbcom-weaviate-editor/ui/functions.js +++ b/charts/kubedbcom-weaviate-editor/ui/functions.js @@ -554,6 +554,45 @@ export const useFunc = (model) => { return showStoragememory } + function isBindingAlreadyOn() { + const value = getValue(model, '/resources') + const keys = Object.keys(value) + const isExposeBinding = !!keys.find((str) => str === 'catalogAppscodeComWeaviateBinding') + return isExposeBinding + } + + function addOrRemoveBinding() { + const value = getValue(discriminator, `/binding`) + const dbName = getValue(model, '/metadata/release/name') + const dbNamespace = getValue(model, '/metadata/release/namespace') + const labels = getValue(model, '/resources/kubedbComWeaviate/metadata/labels') + const bindingValues = { + apiVersion: 'catalog.appscode.com/v1alpha1', + kind: 'WeaviateBinding', + metadata: { + labels, + name: dbName, + namespace: dbNamespace, + }, + spec: { + sourceRef: { + name: dbName, + namespace: dbNamespace, + }, + }, + } + + if (value) { + commit('wizard/model$update', { + path: '/resources/catalogAppscodeComWeaviateBinding', + value: bindingValues, + force: true, + }) + } else { + commit('wizard/model$delete', '/resources/catalogAppscodeComWeaviateBinding') + } + } + return { isKubedb, isConsole, @@ -584,5 +623,7 @@ export const useFunc = (model) => { returnFalse, setValueFromDbDetails, showStorageMemoryOption, + isBindingAlreadyOn, + addOrRemoveBinding, } }