Skip to content

Commit

Permalink
Add form for Expose via Gateway (#701)
Browse files Browse the repository at this point in the history
Signed-off-by: Nihal Azmain <[email protected]>
Signed-off-by: Arnob kumar saha <[email protected]>
Co-authored-by: Arnob kumar saha <[email protected]>
  • Loading branch information
Nihal-Azmain and ArnobKumarSaha authored Jan 3, 2025
1 parent 3579d3c commit 2055ff0
Show file tree
Hide file tree
Showing 17 changed files with 34,427 additions and 1 deletion.
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 Database
onChange: addOrRemoveBinding
schema:
$ref: discriminator#/properties/binding
type: switch
type: single-step-form
id: binding
title: steps.13.label
type: multi-step-form
41 changes: 41 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,45 @@ 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 labels = getValue(model, '/resources/kubedbComElasticsearch/metadata/labels')
const bindingValues = {
apiVersion: 'catalog.appscode.com/v1alpha1',
kind: 'ElasticsearchBinding',
metadata: {
labels,
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 +3431,6 @@ return {
setArchiverSwitch,
onArchiverChange,
onBackupTypeChange,
isBindingAlreadyOn,
addOrRemoveBinding,
}
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 Database
onChange: addOrRemoveBinding
schema:
$ref: discriminator#/properties/binding
type: switch
type: single-step-form
id: binding
title: steps.8.label
type: multi-step-form
41 changes: 41 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,45 @@ 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 labels = getValue(model, '/resources/kubedbComKafka/metadata/labels')
const bindingValues = {
apiVersion: 'catalog.appscode.com/v1alpha1',
kind: 'KafkaBinding',
metadata: {
labels,
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 +1415,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 Database
onChange: addOrRemoveBinding
schema:
$ref: discriminator#/properties/binding
type: switch
type: single-step-form
id: binding
title: steps.11.label
type: multi-step-form
41 changes: 41 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,45 @@ 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 labels = getValue(model, '/resources/kubedbComMariaDB/metadata/labels')
const bindingValues = {
apiVersion: 'catalog.appscode.com/v1alpha1',
kind: 'MariaDBBinding',
metadata: {
labels,
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 +2481,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 Database
onChange: addOrRemoveBinding
schema:
$ref: discriminator#/properties/binding
type: switch
type: single-step-form
id: binding
title: steps.12.label
type: multi-step-form
41 changes: 41 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,45 @@ 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 labels = getValue(model, '/resources/kubedbComMongoDB/metadata/labels')
const bindingValues = {
apiVersion: 'catalog.appscode.com/v1alpha1',
kind: 'MongoDBBinding',
metadata: {
labels,
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 +3008,6 @@ return {
setArchiverSwitch,
onArchiverChange,
onBackupTypeChange,
isBindingAlreadyOn,
addOrRemoveBinding,
}
16 changes: 16 additions & 0 deletions charts/kubedbcom-mysql-editor/ui/edit-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1277,4 +1277,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 Database
onChange: addOrRemoveBinding
schema:
$ref: discriminator#/properties/binding
type: switch
type: single-step-form
id: binding
title: steps.11.label
type: multi-step-form
41 changes: 41 additions & 0 deletions charts/kubedbcom-mysql-editor/ui/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2348,6 +2348,45 @@ 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 === 'catalogAppscodeComMySQLBinding')
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 labels = getValue(model, '/resources/kubedbComMySQL/metadata/labels')
const bindingValues = {
apiVersion: 'catalog.appscode.com/v1alpha1',
kind: 'MySQLBinding',
metadata: {
labels,
name: dbName,
namespace: dbNamespace,
},
spec: {
sourceRef: {
name: dbName,
namespace: dbNamespace,
},
},
}

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

return {
handleUnit,
isConsole,
Expand Down Expand Up @@ -2494,4 +2533,6 @@ return {
onArchiverChange,
onBackupTypeChange,
getNamespaceArray,
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 Database
onChange: addOrRemoveBinding
schema:
$ref: discriminator#/properties/binding
type: switch
type: single-step-form
id: binding
title: steps.11.label
type: multi-step-form
Loading

0 comments on commit 2055ff0

Please sign in to comment.