From 61e95e45445c43e5f984025d91fff9071b7ecf33 Mon Sep 17 00:00:00 2001 From: Arnob Kumar Saha Date: Thu, 19 Dec 2024 11:37:22 +0600 Subject: [PATCH] Add available database list in connection (#1371) Signed-off-by: Arnob kumar saha --- .config/api-rules/violation_exceptions.list | 1 + apis/ui/v1alpha1/database_connection_types.go | 3 +++ apis/ui/v1alpha1/openapi_generated.go | 15 +++++++++++++++ apis/ui/v1alpha1/zz_generated.deepcopy.go | 5 +++++ crds/ui.kubedb.com_databaseconnections.yaml | 4 ++++ 5 files changed, 28 insertions(+) diff --git a/.config/api-rules/violation_exceptions.list b/.config/api-rules/violation_exceptions.list index f6cd789ef3..c819ad2a9c 100644 --- a/.config/api-rules/violation_exceptions.list +++ b/.config/api-rules/violation_exceptions.list @@ -50,6 +50,7 @@ API rule violation: list_type_missing,kmodules.xyz/offshoot-api/api/v1,ServiceSp API rule violation: list_type_missing,kmodules.xyz/offshoot-api/api/v1,ServiceSpec,LoadBalancerSourceRanges API rule violation: list_type_missing,kmodules.xyz/offshoot-api/api/v1,ServiceSpec,Ports API rule violation: list_type_missing,kubedb.dev/apimachinery/apis/ui/v1alpha1,DatabaseConnectionSpec,CACert +API rule violation: list_type_missing,kubedb.dev/apimachinery/apis/ui/v1alpha1,DatabaseConnectionSpec,Databases API rule violation: list_type_missing,kubedb.dev/apimachinery/apis/ui/v1alpha1,DatabaseConnectionSpec,Gateway API rule violation: list_type_missing,kubedb.dev/apimachinery/apis/ui/v1alpha1,ElasticsearchNodesStatSpec,Roles API rule violation: list_type_missing,kubedb.dev/apimachinery/apis/ui/v1alpha1,ElasticsearchNodesStatsSpec,Nodes diff --git a/apis/ui/v1alpha1/database_connection_types.go b/apis/ui/v1alpha1/database_connection_types.go index 551ca24458..f62a5d4c7b 100644 --- a/apis/ui/v1alpha1/database_connection_types.go +++ b/apis/ui/v1alpha1/database_connection_types.go @@ -46,6 +46,9 @@ type DatabaseConnectionSpec struct { Gateway []GatewayConnection `json:"gateway,omitempty"` InCluster InClusterConnection `json:"inCluster,omitempty"` + // Databases already present on the referred database server + Databases []string `json:"databases,omitempty"` + // Parameters: `username = \n // password = \n // host = \n diff --git a/apis/ui/v1alpha1/openapi_generated.go b/apis/ui/v1alpha1/openapi_generated.go index f34e6c6fe3..a17b8a439b 100644 --- a/apis/ui/v1alpha1/openapi_generated.go +++ b/apis/ui/v1alpha1/openapi_generated.go @@ -25639,6 +25639,21 @@ func schema_apimachinery_apis_ui_v1alpha1_DatabaseConnectionSpec(ref common.Refe Ref: ref("kubedb.dev/apimachinery/apis/ui/v1alpha1.InClusterConnection"), }, }, + "databases": { + SchemaProps: spec.SchemaProps{ + Description: "Databases already present on the referred database server", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, "connectOptions": { SchemaProps: spec.SchemaProps{ Description: "Parameters: `username = \n password = \n host = \n database = \n sslmode = REQUIRED`\n\nURI: `mongodb+srv://:@:/?authSource=&tls=true&replicaSet=arnob`\n\nFlags: `mongo \"mongodb+srv://:@:/?authSource=&replicaSet=arnob\" --tls`\n\nAnd some language specific template strings. Like: Java, C#, Go, Python, Javascript, Ruby etc.", diff --git a/apis/ui/v1alpha1/zz_generated.deepcopy.go b/apis/ui/v1alpha1/zz_generated.deepcopy.go index c60d37d3b3..e9b1c6fcf9 100644 --- a/apis/ui/v1alpha1/zz_generated.deepcopy.go +++ b/apis/ui/v1alpha1/zz_generated.deepcopy.go @@ -100,6 +100,11 @@ func (in *DatabaseConnectionSpec) DeepCopyInto(out *DatabaseConnectionSpec) { } } in.InCluster.DeepCopyInto(&out.InCluster) + if in.Databases != nil { + in, out := &in.Databases, &out.Databases + *out = make([]string, len(*in)) + copy(*out, *in) + } if in.ConnectOptions != nil { in, out := &in.ConnectOptions, &out.ConnectOptions *out = make(map[string]string, len(*in)) diff --git a/crds/ui.kubedb.com_databaseconnections.yaml b/crds/ui.kubedb.com_databaseconnections.yaml index 29091f5465..7af6c25e99 100644 --- a/crds/ui.kubedb.com_databaseconnections.yaml +++ b/crds/ui.kubedb.com_databaseconnections.yaml @@ -33,6 +33,10 @@ spec: additionalProperties: type: string type: object + databases: + items: + type: string + type: array gateway: items: properties: