Skip to content

Commit

Permalink
Add form to Expose via Gateway for all db that has expose via gateway
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 b695c7b commit 7e84932
Show file tree
Hide file tree
Showing 10 changed files with 275 additions and 0 deletions.
16 changes: 16 additions & 0 deletions charts/kubedbcom-kafka-editor/ui/edit-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1141,4 +1141,20 @@ steps:
type: single-step-form
id: storage-autoscaler
title: steps.7.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.8.label
type: multi-step-form
39 changes: 39 additions & 0 deletions charts/kubedbcom-kafka-editor/ui/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,43 @@ function handleUnit({ commit, model, getValue }, path, type = 'bound') {
}
}

function isBindingAlreadyOn({ model, getValue }) {
const value = getValue(model, '/resources')
const keys = Object.keys(value)
isExposeBinding = !!keys.find((str) => str === 'catalogAppscodeComKafkaBinding')
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: 'KafkaBinding',
metadata: {
name: dbName,
namespace: dbNamespace,
},
spec: {
sourceRef: {
name: dbName,
namespace: dbNamespace,
},
},
}

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

return {
handleUnit,
isConsole,
Expand Down Expand Up @@ -1376,4 +1413,6 @@ return {
getOpsRequestUrl,
getCreateNameSpaceUrl,
setStorageClass,
isBindingAlreadyOn,
addOrRemoveBinding,
}
16 changes: 16 additions & 0 deletions charts/kubedbcom-mariadb-editor/ui/edit-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1238,4 +1238,20 @@ steps:
type: single-step-form
id: storage-autoscaler
title: steps.10.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.11.label
type: multi-step-form
39 changes: 39 additions & 0 deletions charts/kubedbcom-mariadb-editor/ui/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2301,6 +2301,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 === 'catalogAppscodeComMariaDBBinding')
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: 'MariaDBBinding',
metadata: {
name: dbName,
namespace: dbNamespace,
},
spec: {
sourceRef: {
name: dbName,
namespace: dbNamespace,
},
},
}

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

return {
getDbDetails,
isConsole,
Expand Down Expand Up @@ -2442,4 +2479,6 @@ return {
setArchiverSwitch,
onArchiverChange,
onBackupTypeChange,
isBindingAlreadyOn,
addOrRemoveBinding,
}
16 changes: 16 additions & 0 deletions charts/kubedbcom-mongodb-editor/ui/edit-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2356,4 +2356,20 @@ steps:
type: single-step-form
id: storage-autoscaler
title: steps.11.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.12.label
type: multi-step-form
39 changes: 39 additions & 0 deletions charts/kubedbcom-mongodb-editor/ui/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2805,6 +2805,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 === 'catalogAppscodeComMongoDBBinding')
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: 'MongoDBBinding',
metadata: {
name: dbName,
namespace: dbNamespace,
},
spec: {
sourceRef: {
name: dbName,
namespace: dbNamespace,
},
},
}

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

return {
handleUnit,
setMetadata,
Expand Down Expand Up @@ -2969,4 +3006,6 @@ return {
setArchiverSwitch,
onArchiverChange,
onBackupTypeChange,
isBindingAlreadyOn,
addOrRemoveBinding,
}
16 changes: 16 additions & 0 deletions charts/kubedbcom-redis-editor/ui/edit-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1640,4 +1640,20 @@ steps:
type: single-step-form
id: storage-autoscaler
title: steps.10.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.11.label
type: multi-step-form
39 changes: 39 additions & 0 deletions charts/kubedbcom-redis-editor/ui/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2562,6 +2562,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 === 'catalogAppscodeComRedisBinding')
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: 'RedisBinding',
metadata: {
name: dbName,
namespace: dbNamespace,
},
spec: {
sourceRef: {
name: dbName,
namespace: dbNamespace,
},
},
}

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

return {
handleUnit,
isConsole,
Expand Down Expand Up @@ -2722,4 +2759,6 @@ return {
onArchiverChange,
onBackupTypeChange,
getNamespaceArray,
isBindingAlreadyOn,
addOrRemoveBinding,
}
16 changes: 16 additions & 0 deletions charts/kubedbcom-singlestore-editor/ui/edit-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -758,4 +758,20 @@ steps:
type: single-step-form
id: storage-autoscaler
title: steps.10.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.11.label
type: multi-step-form
39 changes: 39 additions & 0 deletions charts/kubedbcom-singlestore-editor/ui/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2890,6 +2890,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 === 'catalogAppscodeComSinglestoreBinding')
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: 'SinglestoreBinding',
metadata: {
name: dbName,
namespace: dbNamespace,
},
spec: {
sourceRef: {
name: dbName,
namespace: dbNamespace,
},
},
}

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

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

0 comments on commit 7e84932

Please sign in to comment.