Skip to content

Commit

Permalink
Implement ops mappers
Browse files Browse the repository at this point in the history
Signed-off-by: Arnob kumar saha <[email protected]>
  • Loading branch information
ArnobKumarSaha committed Oct 28, 2024
1 parent 8d88001 commit 1dd57f6
Show file tree
Hide file tree
Showing 9 changed files with 539 additions and 0 deletions.
68 changes: 68 additions & 0 deletions ops.kubedb.com/v1alpha1/druid_mapping.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
Copyright AppsCode Inc. and Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import "k8s.io/apimachinery/pkg/runtime/schema"

func init() {
RegisterOpsPathMapperToPlugins(&DruidOpsRequest{})
}

type DruidOpsRequest struct{}

var _ OpsPathMapper = (*DruidOpsRequest)(nil)

func (m *DruidOpsRequest) HorizontalPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{
"spec.horizontalScaling.topology.coordinators": "spec.topology.coordinators.replicas",
"spec.horizontalScaling.topology.overloads": "spec.topology.overloads.replicas",
"spec.horizontalScaling.topology.middleManagers": "spec.topology.middleManagers.replicas",
"spec.horizontalScaling.topology.historicals": "spec.topology.historicals.replicas",
"spec.horizontalScaling.topology.brokers": "spec.topology.brokers.replicas",
"spec.horizontalScaling.topology.routers": "spec.topology.routers.replicas",
}
}

func (m *DruidOpsRequest) VerticalPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{
"spec.verticalScaling.topology.coordinators": "spec.topology.coordinators.podTemplate.spec.resources",
"spec.verticalScaling.topology.overloads": "spec.topology.overloads.podTemplate.spec.resources",
"spec.verticalScaling.topology.middleManagers": "spec.topology.middleManagers.podTemplate.spec.resources",
"spec.verticalScaling.topology.historicals": "spec.topology.historicals.podTemplate.spec.resources",
"spec.verticalScaling.topology.brokers": "spec.topology.brokers.podTemplate.spec.resources",
"spec.verticalScaling.topology.routers": "spec.topology.routers.podTemplate.spec.resources",
}
}

func (m *DruidOpsRequest) VolumeExpansionPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{
"spec.volumeExpansion.topology.middleManagers": "spec.topology.middleManagers.podTemplate.spec.storage.resources.requests.storage",
"spec.volumeExpansion.topology.historicals": "spec.topology.historicals.podTemplate.spec.storage.resources.requests.storage",
}
}

func (m *DruidOpsRequest) GetAppRefPath() []string {
return []string{"spec", "databaseRef"}
}

func (m *DruidOpsRequest) GroupVersionKind() schema.GroupVersionKind {
return schema.GroupVersionKind{
Group: "ops.kubedb.com",
Version: "v1alpha1",
Kind: "DruidOpsRequest",
}
}
55 changes: 55 additions & 0 deletions ops.kubedb.com/v1alpha1/ferretdb_mapping.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
Copyright AppsCode Inc. and Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import "k8s.io/apimachinery/pkg/runtime/schema"

func init() {
RegisterOpsPathMapperToPlugins(&FerretDBOpsRequest{})
}

type FerretDBOpsRequest struct{}

var _ OpsPathMapper = (*FerretDBOpsRequest)(nil)

func (m *FerretDBOpsRequest) HorizontalPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{
"spec.horizontalScaling.node": "spec.replicas",
}
}

func (m *FerretDBOpsRequest) VerticalPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{
"spec.verticalScaling.node": "spec.podTemplate.spec.resources",
}
}

func (m *FerretDBOpsRequest) VolumeExpansionPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{}
}

func (m *FerretDBOpsRequest) GetAppRefPath() []string {
return []string{"spec", "databaseRef"}
}

func (m *FerretDBOpsRequest) GroupVersionKind() schema.GroupVersionKind {
return schema.GroupVersionKind{
Group: "ops.kubedb.com",
Version: "v1alpha1",
Kind: "FerretDBOpsRequest",
}
}
59 changes: 59 additions & 0 deletions ops.kubedb.com/v1alpha1/mssqlserver_mapping.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Copyright AppsCode Inc. and Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import "k8s.io/apimachinery/pkg/runtime/schema"

func init() {
RegisterOpsPathMapperToPlugins(&MSSQLServerOpsRequest{})
}

type MSSQLServerOpsRequest struct{}

var _ OpsPathMapper = (*MSSQLServerOpsRequest)(nil)

func (m *MSSQLServerOpsRequest) HorizontalPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{
"spec.horizontalScaling.replicas": "spec.replicas",
}
}

func (m *MSSQLServerOpsRequest) VerticalPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{
"spec.verticalScaling.mssqlserver": "spec.podTemplate.spec.resources",
"spec.verticalScaling.exporter": "spec.monitor.prometheus.exporter.resources",
"spec.verticalScaling.coordinator": "spec.coordinator.resources",
}
}

func (m *MSSQLServerOpsRequest) VolumeExpansionPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{
"spec.volumeExpansion.mssqlserver": "spec.storage.resources.requests.storage",
}
}

func (m *MSSQLServerOpsRequest) GetAppRefPath() []string {
return []string{"spec", "databaseRef"}
}

func (m *MSSQLServerOpsRequest) GroupVersionKind() schema.GroupVersionKind {
return schema.GroupVersionKind{
Group: "ops.kubedb.com",
Version: "v1alpha1",
Kind: "MSSQLServerOpsRequest",
}
}
59 changes: 59 additions & 0 deletions ops.kubedb.com/v1alpha1/perconaxtradb_mapping.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Copyright AppsCode Inc. and Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import "k8s.io/apimachinery/pkg/runtime/schema"

func init() {
RegisterOpsPathMapperToPlugins(&PerconaXtraDBOpsRequest{})
}

type PerconaXtraDBOpsRequest struct{}

var _ OpsPathMapper = (*PerconaXtraDBOpsRequest)(nil)

func (m *PerconaXtraDBOpsRequest) HorizontalPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{
"spec.horizontalScaling.member": "spec.replicas",
}
}

func (m *PerconaXtraDBOpsRequest) VerticalPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{
"spec.verticalScaling.perconaxtradb": "spec.podTemplate.spec.resources",
"spec.verticalScaling.exporter": "spec.monitor.prometheus.exporter.resources",
"spec.verticalScaling.coordinator": "spec.coordinator.resources",
}
}

func (m *PerconaXtraDBOpsRequest) VolumeExpansionPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{
"spec.volumeExpansion.perconaxtradb": "spec.storage.resources.requests.storage",
}
}

func (m *PerconaXtraDBOpsRequest) GetAppRefPath() []string {
return []string{"spec", "databaseRef"}
}

func (m *PerconaXtraDBOpsRequest) GroupVersionKind() schema.GroupVersionKind {
return schema.GroupVersionKind{
Group: "ops.kubedb.com",
Version: "v1alpha1",
Kind: "PerconaXtraDBOpsRequest",
}
}
55 changes: 55 additions & 0 deletions ops.kubedb.com/v1alpha1/pgpool_mapping.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
Copyright AppsCode Inc. and Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import "k8s.io/apimachinery/pkg/runtime/schema"

func init() {
RegisterOpsPathMapperToPlugins(&PgpoolOpsRequest{})
}

type PgpoolOpsRequest struct{}

var _ OpsPathMapper = (*PgpoolOpsRequest)(nil)

func (m *PgpoolOpsRequest) HorizontalPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{
"spec.horizontalScaling.node": "spec.replicas",
}
}

func (m *PgpoolOpsRequest) VerticalPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{
"spec.verticalScaling.node": "spec.podTemplate.spec.resources",
}
}

func (m *PgpoolOpsRequest) VolumeExpansionPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{}
}

func (m *PgpoolOpsRequest) GetAppRefPath() []string {
return []string{"spec", "databaseRef"}
}

func (m *PgpoolOpsRequest) GroupVersionKind() schema.GroupVersionKind {
return schema.GroupVersionKind{
Group: "ops.kubedb.com",
Version: "v1alpha1",
Kind: "PgpoolOpsRequest",
}
}
57 changes: 57 additions & 0 deletions ops.kubedb.com/v1alpha1/rabbitmq_mapping.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
Copyright AppsCode Inc. and Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import "k8s.io/apimachinery/pkg/runtime/schema"

func init() {
RegisterOpsPathMapperToPlugins(&RabbitMQOpsRequest{})
}

type RabbitMQOpsRequest struct{}

var _ OpsPathMapper = (*RabbitMQOpsRequest)(nil)

func (m *RabbitMQOpsRequest) HorizontalPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{
"spec.horizontalScaling.node": "spec.replicas",
}
}

func (m *RabbitMQOpsRequest) VerticalPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{
"spec.verticalScaling.node": "spec.podTemplate.spec.resources",
}
}

func (m *RabbitMQOpsRequest) VolumeExpansionPathMapping() map[OpsReqPath]ReferencedObjPath {
return map[OpsReqPath]ReferencedObjPath{
"spec.volumeExpansion.node": "spec.storage.resources.requests.storage",
}
}

func (m *RabbitMQOpsRequest) GetAppRefPath() []string {
return []string{"spec", "databaseRef"}
}

func (m *RabbitMQOpsRequest) GroupVersionKind() schema.GroupVersionKind {
return schema.GroupVersionKind{
Group: "ops.kubedb.com",
Version: "v1alpha1",
Kind: "RabbitMQOpsRequest",
}
}
Loading

0 comments on commit 1dd57f6

Please sign in to comment.