-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package providers | ||
|
||
import ( | ||
"context" | ||
"github.com/spf13/viper" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
type AWSProvider struct { | ||
} | ||
|
||
func NewAWSProvider(k8sClient client.Client, config *viper.Viper) *AWSProvider { | ||
return &AWSProvider{} | ||
} | ||
|
||
func (p *AWSProvider) CreateDatabase(ctx context.Context, spec DatabaseSpec) error { | ||
return nil | ||
} | ||
|
||
func (p *AWSProvider) DeleteDatabase(ctx context.Context, name string) error { | ||
return nil | ||
} | ||
|
||
func (p *AWSProvider) GetDatabase(ctx context.Context, name string) (*DatabaseSpec, error) { | ||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package providers | ||
|
||
import ( | ||
"context" | ||
"github.com/spf13/viper" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
type CloudNativePGProvider struct { | ||
} | ||
|
||
func NewCloudNativePGProvider(k8sClient client.Client, config *viper.Viper) *CloudNativePGProvider { | ||
return &CloudNativePGProvider{} | ||
} | ||
|
||
func (p *CloudNativePGProvider) CreateDatabase(ctx context.Context, spec DatabaseSpec) error { | ||
return nil | ||
} | ||
|
||
func (p *CloudNativePGProvider) DeleteDatabase(ctx context.Context, name string) error { | ||
return nil | ||
} | ||
|
||
func (p *CloudNativePGProvider) GetDatabase(ctx context.Context, name string) (*DatabaseSpec, error) { | ||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package providers | ||
|
||
import ( | ||
"context" | ||
"github.com/spf13/viper" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
type GCPProvider struct { | ||
} | ||
|
||
func NewGCPProvider(k8sClient client.Client, config *viper.Viper) *GCPProvider { | ||
return &GCPProvider{} | ||
} | ||
|
||
func (p *GCPProvider) CreateDatabase(ctx context.Context, spec DatabaseSpec) error { | ||
return nil | ||
} | ||
|
||
func (p *GCPProvider) DeleteDatabase(ctx context.Context, name string) error { | ||
return nil | ||
} | ||
|
||
func (p *GCPProvider) GetDatabase(ctx context.Context, name string) (*DatabaseSpec, error) { | ||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package providers | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
v1 "github.com/infobloxopen/db-controller/api/v1" | ||
"github.com/infobloxopen/db-controller/pkg/hostparams" | ||
"github.com/spf13/viper" | ||
|
||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
// DatabaseSpec defines the required parameters to provision a database using any provider. | ||
type DatabaseSpec struct { | ||
ProviderResourceName string | ||
DbType v1.DatabaseType | ||
SharedDBHost bool | ||
MasterConnInfo v1.DatabaseClaimConnectionInfo | ||
TempSecret string | ||
HostParams hostparams.HostParams | ||
EnableReplicationRole bool | ||
EnableSuperUser bool | ||
EnablePerfInsight bool | ||
EnableCloudwatchLogsExport []*string | ||
BackupRetentionDays int64 | ||
CACertificateIdentifier string | ||
|
||
Tags v1.Tag | ||
Labels map[string]string | ||
PreferredMaintenanceWindow *string | ||
BackupPolicy string | ||
} | ||
|
||
// Provider is an interface that abstracts provider-specific logic. | ||
type Provider interface { | ||
// CreateDatabase provisions a new database instance. | ||
CreateDatabase(ctx context.Context, spec DatabaseSpec) error | ||
// DeleteDatabase deprovisions an existing database instance. | ||
DeleteDatabase(ctx context.Context, name string) error | ||
// GetDatabase retrieves the current status of a database instance. | ||
GetDatabase(ctx context.Context, name string) (*DatabaseSpec, error) | ||
} | ||
|
||
// NewProvider returns a concrete provider implementation based on the given provider name. | ||
func NewProvider(config *viper.Viper, k8sClient client.Client) (Provider, error) { | ||
cloud := config.GetString("cloud") | ||
switch cloud { | ||
case "aws": | ||
return NewAWSProvider(k8sClient, config), nil | ||
case "gcp": | ||
return NewGCPProvider(k8sClient, config), nil | ||
case "cloudnative-pg": | ||
return nil, nil | ||
default: | ||
return nil, fmt.Errorf("unsupported provider for cloud: %s", cloud) | ||
} | ||
} |