Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
EVEREST-757 Implement namespaces endpoint and change dbengines to nam…
Browse files Browse the repository at this point in the history
…espaced (#392)
  • Loading branch information
recharte authored Jan 29, 2024
1 parent f38d8bb commit ed59734
Show file tree
Hide file tree
Showing 17 changed files with 950 additions and 589 deletions.
14 changes: 9 additions & 5 deletions api/database_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
databaseClusterKind = "databaseclusters"
)

// CreateDatabaseCluster creates a new db cluster inside the given k8s cluster.
func (e *EverestServer) CreateDatabaseCluster(ctx echo.Context) error {
dbc := &DatabaseCluster{}
Expand All @@ -42,22 +46,22 @@ func (e *EverestServer) CreateDatabaseCluster(ctx echo.Context) error {
return ctx.JSON(http.StatusBadRequest, Error{Message: pointer.ToString(err.Error())})
}

return e.proxyKubernetes(ctx, "")
return e.proxyKubernetes(ctx, "", databaseClusterKind, "")
}

// ListDatabaseClusters lists the created database clusters on the specified kubernetes cluster.
func (e *EverestServer) ListDatabaseClusters(ctx echo.Context) error {
return e.proxyKubernetes(ctx, "")
return e.proxyKubernetes(ctx, "", databaseClusterKind, "")
}

// DeleteDatabaseCluster deletes a database cluster on the specified kubernetes cluster.
func (e *EverestServer) DeleteDatabaseCluster(ctx echo.Context, name string) error {
return e.proxyKubernetes(ctx, name)
return e.proxyKubernetes(ctx, "", databaseClusterKind, name)
}

// GetDatabaseCluster retrieves the specified database cluster on the specified kubernetes cluster.
func (e *EverestServer) GetDatabaseCluster(ctx echo.Context, name string) error {
return e.proxyKubernetes(ctx, name)
return e.proxyKubernetes(ctx, "", databaseClusterKind, name)
}

// UpdateDatabaseCluster replaces the specified database cluster on the specified kubernetes cluster.
Expand All @@ -82,7 +86,7 @@ func (e *EverestServer) UpdateDatabaseCluster(ctx echo.Context, name string) err
return ctx.JSON(http.StatusBadRequest, Error{Message: pointer.ToString(err.Error())})
}

return e.proxyKubernetes(ctx, name)
return e.proxyKubernetes(ctx, "", databaseClusterKind, name)
}

// GetDatabaseClusterCredentials returns credentials for the specified database cluster.
Expand Down
12 changes: 8 additions & 4 deletions api/database_cluster_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import (
"github.com/labstack/echo/v4"
)

const (
databaseClusterBackupKind = "databaseclusterbackups"
)

// ListDatabaseClusterBackups returns list of the created database cluster backups on the specified kubernetes cluster.
func (e *EverestServer) ListDatabaseClusterBackups(ctx echo.Context, name string) error {
req := ctx.Request()
Expand All @@ -42,7 +46,7 @@ func (e *EverestServer) ListDatabaseClusterBackups(ctx echo.Context, name string
path = strings.TrimSuffix(path, name)
path = strings.ReplaceAll(path, "database-clusters", "database-cluster-backups")
req.URL.Path = path
return e.proxyKubernetes(ctx, "")
return e.proxyKubernetes(ctx, "", databaseClusterBackupKind, "")
}

// CreateDatabaseClusterBackup creates a database cluster backup on the specified kubernetes cluster.
Expand All @@ -59,15 +63,15 @@ func (e *EverestServer) CreateDatabaseClusterBackup(ctx echo.Context) error {
e.l.Error(err)
return ctx.JSON(http.StatusBadRequest, Error{Message: pointer.ToString(err.Error())})
}
return e.proxyKubernetes(ctx, "")
return e.proxyKubernetes(ctx, "", databaseClusterBackupKind, "")
}

// DeleteDatabaseClusterBackup deletes the specified cluster backup on the specified kubernetes cluster.
func (e *EverestServer) DeleteDatabaseClusterBackup(ctx echo.Context, name string) error {
return e.proxyKubernetes(ctx, name)
return e.proxyKubernetes(ctx, "", databaseClusterBackupKind, name)
}

// GetDatabaseClusterBackup returns the specified cluster backup on the specified kubernetes cluster.
func (e *EverestServer) GetDatabaseClusterBackup(ctx echo.Context, name string) error {
return e.proxyKubernetes(ctx, name)
return e.proxyKubernetes(ctx, "", databaseClusterBackupKind, name)
}
14 changes: 9 additions & 5 deletions api/database_cluster_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ import (
everestv1alpha1 "github.com/percona/everest-operator/api/v1alpha1"
)

const (
databaseClusterRestoreKind = "databaseclusterrestores"
)

// ListDatabaseClusterRestores List of the created database cluster restores on the specified kubernetes cluster.
func (e *EverestServer) ListDatabaseClusterRestores(ctx echo.Context, name string) error {
req := ctx.Request()
Expand All @@ -43,7 +47,7 @@ func (e *EverestServer) ListDatabaseClusterRestores(ctx echo.Context, name strin
path = strings.TrimSuffix(path, name)
path = strings.ReplaceAll(path, "database-clusters", "database-cluster-restores")
req.URL.Path = path
return e.proxyKubernetes(ctx, "")
return e.proxyKubernetes(ctx, "", databaseClusterRestoreKind, "")
}

// CreateDatabaseClusterRestore Create a database cluster restore on the specified kubernetes cluster.
Expand Down Expand Up @@ -75,17 +79,17 @@ func (e *EverestServer) CreateDatabaseClusterRestore(ctx echo.Context) error {
})
}

return e.proxyKubernetes(ctx, "")
return e.proxyKubernetes(ctx, "", databaseClusterRestoreKind, "")
}

// DeleteDatabaseClusterRestore Delete the specified cluster restore on the specified kubernetes cluster.
func (e *EverestServer) DeleteDatabaseClusterRestore(ctx echo.Context, name string) error {
return e.proxyKubernetes(ctx, name)
return e.proxyKubernetes(ctx, "", databaseClusterRestoreKind, name)
}

// GetDatabaseClusterRestore Returns the specified cluster restore on the specified kubernetes cluster.
func (e *EverestServer) GetDatabaseClusterRestore(ctx echo.Context, name string) error {
return e.proxyKubernetes(ctx, name)
return e.proxyKubernetes(ctx, "", databaseClusterRestoreKind, name)
}

// UpdateDatabaseClusterRestore Replace the specified cluster restore on the specified kubernetes cluster.
Expand All @@ -103,5 +107,5 @@ func (e *EverestServer) UpdateDatabaseClusterRestore(ctx echo.Context, name stri
Message: pointer.ToString(err.Error()),
})
}
return e.proxyKubernetes(ctx, name)
return e.proxyKubernetes(ctx, "", databaseClusterRestoreKind, name)
}
22 changes: 13 additions & 9 deletions api/database_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,21 @@ package api

import "github.com/labstack/echo/v4"

// ListDatabaseEngines List of the available database engines on the specified kubernetes cluster.
func (e *EverestServer) ListDatabaseEngines(ctx echo.Context) error {
return e.proxyKubernetes(ctx, "")
const (
databaseEngineKind = "databaseengines"
)

// ListDatabaseEngines List of the available database engines on the specified namespace.
func (e *EverestServer) ListDatabaseEngines(ctx echo.Context, namespace string) error {
return e.proxyKubernetes(ctx, namespace, databaseEngineKind, "")
}

// GetDatabaseEngine Get the specified database cluster on the specified kubernetes cluster.
func (e *EverestServer) GetDatabaseEngine(ctx echo.Context, name string) error {
return e.proxyKubernetes(ctx, name)
// GetDatabaseEngine Get the specified database engine on the specified namespace.
func (e *EverestServer) GetDatabaseEngine(ctx echo.Context, namespace string, name string) error {
return e.proxyKubernetes(ctx, namespace, databaseEngineKind, name)
}

// UpdateDatabaseEngine Get the specified database cluster on the specified kubernetes cluster.
func (e *EverestServer) UpdateDatabaseEngine(ctx echo.Context, name string) error {
return e.proxyKubernetes(ctx, name)
// UpdateDatabaseEngine Update the specified database engine on the specified namespace.
func (e *EverestServer) UpdateDatabaseEngine(ctx echo.Context, namespace string, name string) error {
return e.proxyKubernetes(ctx, namespace, databaseEngineKind, name)
}
Loading

0 comments on commit ed59734

Please sign in to comment.