Skip to content

Commit

Permalink
Add form to Expose via Gateway for elastic search
Browse files Browse the repository at this point in the history
Signed-off-by: Nihal Azmain <[email protected]>
  • Loading branch information
Nihal-Azmain authored and ArnobKumarSaha committed Jan 1, 2025
1 parent 44070bc commit b695c7b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
16 changes: 16 additions & 0 deletions charts/kubedbcom-elasticsearch-editor/ui/edit-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2202,4 +2202,20 @@ steps:
type: single-step-form
id: storage-autoscaler
title: steps.0.label
- form:
discriminator:
binding:
default: false
type: boolean
elements:
- computed: isBindingAlreadyOn
label:
text: Expose Binding
onChange: addOrRemoveBinding
type: switch
schema:
$ref: discriminator#/properties/binding
type: single-step-form
id: binding
title: steps.13.label
type: multi-step-form
39 changes: 39 additions & 0 deletions charts/kubedbcom-elasticsearch-editor/ui/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3201,6 +3201,43 @@ function objectCopy(obj) {
return JSON.parse(temp)
}

function isBindingAlreadyOn({ model, getValue }) {
const value = getValue(model, '/resources')
const keys = Object.keys(value)
isExposeBinding = !!keys.find((str) => str === 'catalogAppscodeComElasticsearchBinding')
return isExposeBinding
}

async function addOrRemoveBinding({ commit, model, getValue, discriminator }) {
const value = getValue(discriminator, `/binding`)
const dbName = getValue(model, '/metadata/release/name')
const dbNamespace = getValue(model, '/metadata/release/namespace')
const bindingValues = {
apiVersion: 'catalog.appscode.com/v1alpha1',
kind: 'ElasticsearchBinding',
metadata: {
name: dbName,
namespace: dbNamespace,
},
spec: {
sourceRef: {
name: dbName,
namespace: dbNamespace,
},
},
}

if (value) {
await commit('wizard/model$update', {
path: '/resources/catalogAppscodeComElasticsearchBinding',
value: bindingValues,
force: true,
})
} else {
await commit('wizard/model$delete', '/resources/catalogAppscodeComElasticsearchBinding')
}
}

return {
handleUnit,
isConsole,
Expand Down Expand Up @@ -3392,4 +3429,6 @@ return {
setArchiverSwitch,
onArchiverChange,
onBackupTypeChange,
isBindingAlreadyOn,
addOrRemoveBinding,
}

0 comments on commit b695c7b

Please sign in to comment.