providers

package
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AWSDeploymentStrategy       = "aws"
	OpenShiftDeploymentStrategy = "openshift"
	GCPDeploymentStrategy       = "gcp"

	BlobStorageResourceType ResourceType = "blobstorage"
	PostgresResourceType    ResourceType = "postgres"
	RedisResourceType       ResourceType = "redis"
	NetworkResourceType     ResourceType = "_network"
)
View Source
const (
	DefaultProviderConfigMapName = "cloud-resource-config"
)

DefaultProviderConfigMapName represents the default config map name

Variables

View Source
var DefaultConfigNamespace, _ = k8sutil.GetWatchNamespace()

DefaultConfigNamespace get default namespace

Functions

This section is empty.

Types

type BlobStorageInstance

type BlobStorageInstance struct {
	DeploymentDetails DeploymentDetails
}

type BlobStorageProvider

type BlobStorageProvider interface {
	GetName() string
	SupportsStrategy(s string) bool
	GetReconcileTime(bs *v1alpha1.BlobStorage) time.Duration
	CreateStorage(ctx context.Context, bs *v1alpha1.BlobStorage) (*BlobStorageInstance, croType.StatusMessage, error)
	DeleteStorage(ctx context.Context, bs *v1alpha1.BlobStorage) (croType.StatusMessage, error)
}

type BlobStorageProviderMock

type BlobStorageProviderMock struct {
	// CreateStorageFunc mocks the CreateStorage method.
	CreateStorageFunc func(ctx context.Context, bs *v1alpha1.BlobStorage) (*BlobStorageInstance, croType.StatusMessage, error)

	// DeleteStorageFunc mocks the DeleteStorage method.
	DeleteStorageFunc func(ctx context.Context, bs *v1alpha1.BlobStorage) (croType.StatusMessage, error)

	// GetNameFunc mocks the GetName method.
	GetNameFunc func() string

	// GetReconcileTimeFunc mocks the GetReconcileTime method.
	GetReconcileTimeFunc func(bs *v1alpha1.BlobStorage) time.Duration

	// SupportsStrategyFunc mocks the SupportsStrategy method.
	SupportsStrategyFunc func(s string) bool
	// contains filtered or unexported fields
}

BlobStorageProviderMock is a mock implementation of BlobStorageProvider.

func TestSomethingThatUsesBlobStorageProvider(t *testing.T) {

	// make and configure a mocked BlobStorageProvider
	mockedBlobStorageProvider := &BlobStorageProviderMock{
		CreateStorageFunc: func(ctx context.Context, bs *v1alpha1.BlobStorage) (*BlobStorageInstance, croType.StatusMessage, error) {
			panic("mock out the CreateStorage method")
		},
		DeleteStorageFunc: func(ctx context.Context, bs *v1alpha1.BlobStorage) (croType.StatusMessage, error) {
			panic("mock out the DeleteStorage method")
		},
		GetNameFunc: func() string {
			panic("mock out the GetName method")
		},
		GetReconcileTimeFunc: func(bs *v1alpha1.BlobStorage) time.Duration {
			panic("mock out the GetReconcileTime method")
		},
		SupportsStrategyFunc: func(s string) bool {
			panic("mock out the SupportsStrategy method")
		},
	}

	// use mockedBlobStorageProvider in code that requires BlobStorageProvider
	// and then make assertions.

}

func (*BlobStorageProviderMock) CreateStorage

CreateStorage calls CreateStorageFunc.

func (*BlobStorageProviderMock) CreateStorageCalls

func (mock *BlobStorageProviderMock) CreateStorageCalls() []struct {
	Ctx context.Context
	Bs  *v1alpha1.BlobStorage
}

CreateStorageCalls gets all the calls that were made to CreateStorage. Check the length with:

len(mockedBlobStorageProvider.CreateStorageCalls())

func (*BlobStorageProviderMock) DeleteStorage

DeleteStorage calls DeleteStorageFunc.

func (*BlobStorageProviderMock) DeleteStorageCalls

func (mock *BlobStorageProviderMock) DeleteStorageCalls() []struct {
	Ctx context.Context
	Bs  *v1alpha1.BlobStorage
}

DeleteStorageCalls gets all the calls that were made to DeleteStorage. Check the length with:

len(mockedBlobStorageProvider.DeleteStorageCalls())

func (*BlobStorageProviderMock) GetName

func (mock *BlobStorageProviderMock) GetName() string

GetName calls GetNameFunc.

func (*BlobStorageProviderMock) GetNameCalls

func (mock *BlobStorageProviderMock) GetNameCalls() []struct {
}

GetNameCalls gets all the calls that were made to GetName. Check the length with:

len(mockedBlobStorageProvider.GetNameCalls())

func (*BlobStorageProviderMock) GetReconcileTime

func (mock *BlobStorageProviderMock) GetReconcileTime(bs *v1alpha1.BlobStorage) time.Duration

GetReconcileTime calls GetReconcileTimeFunc.

func (*BlobStorageProviderMock) GetReconcileTimeCalls

func (mock *BlobStorageProviderMock) GetReconcileTimeCalls() []struct {
	Bs *v1alpha1.BlobStorage
}

GetReconcileTimeCalls gets all the calls that were made to GetReconcileTime. Check the length with:

len(mockedBlobStorageProvider.GetReconcileTimeCalls())

func (*BlobStorageProviderMock) SupportsStrategy

func (mock *BlobStorageProviderMock) SupportsStrategy(s string) bool

SupportsStrategy calls SupportsStrategyFunc.

func (*BlobStorageProviderMock) SupportsStrategyCalls

func (mock *BlobStorageProviderMock) SupportsStrategyCalls() []struct {
	S string
}

SupportsStrategyCalls gets all the calls that were made to SupportsStrategy. Check the length with:

len(mockedBlobStorageProvider.SupportsStrategyCalls())

type CloudProviderMetricType

type CloudProviderMetricType struct {
	//PrometheusMetricName the name of the metric exposed via cro
	PrometheusMetricName string
	//ProviderMetricName the metric we scrape from the cloud provider
	ProviderMetricName string
	//Statistic the type of metric value we return e.g. Average, Sum, Max, Min etc.
	Statistic string
}

CloudProviderMetricType is used to declare a generic type of metric it maps provider specific metrics to metrics we expose in prometheus

type ConfigManager

type ConfigManager interface {
	GetStrategyMappingForDeploymentType(ctx context.Context, t string) (*DeploymentStrategyMapping, error)
}

type ConfigManagerMock

type ConfigManagerMock struct {
	// GetStrategyMappingForDeploymentTypeFunc mocks the GetStrategyMappingForDeploymentType method.
	GetStrategyMappingForDeploymentTypeFunc func(ctx context.Context, t string) (*DeploymentStrategyMapping, error)
	// contains filtered or unexported fields
}

ConfigManagerMock is a mock implementation of ConfigManager.

func TestSomethingThatUsesConfigManager(t *testing.T) {

	// make and configure a mocked ConfigManager
	mockedConfigManager := &ConfigManagerMock{
		GetStrategyMappingForDeploymentTypeFunc: func(ctx context.Context, t string) (*DeploymentStrategyMapping, error) {
			panic("mock out the GetStrategyMappingForDeploymentType method")
		},
	}

	// use mockedConfigManager in code that requires ConfigManager
	// and then make assertions.

}

func (*ConfigManagerMock) GetStrategyMappingForDeploymentType

func (mock *ConfigManagerMock) GetStrategyMappingForDeploymentType(ctx context.Context, t string) (*DeploymentStrategyMapping, error)

GetStrategyMappingForDeploymentType calls GetStrategyMappingForDeploymentTypeFunc.

func (*ConfigManagerMock) GetStrategyMappingForDeploymentTypeCalls

func (mock *ConfigManagerMock) GetStrategyMappingForDeploymentTypeCalls() []struct {
	Ctx context.Context
	T   string
}

GetStrategyMappingForDeploymentTypeCalls gets all the calls that were made to GetStrategyMappingForDeploymentType. Check the length with:

len(mockedConfigManager.GetStrategyMappingForDeploymentTypeCalls())

type ConfigMapConfigManager

type ConfigMapConfigManager struct {
	// contains filtered or unexported fields
}

func NewConfigManager

func NewConfigManager(cm string, namespace string, client client.Client) *ConfigMapConfigManager

func (*ConfigMapConfigManager) GetStrategyMappingForDeploymentType

func (m *ConfigMapConfigManager) GetStrategyMappingForDeploymentType(ctx context.Context, t string) (*DeploymentStrategyMapping, error)

GetStrategyMappingForDeploymentType Get high-level information about the strategy used in a deployment type

type DeploymentDetails

type DeploymentDetails interface {
	Data() map[string][]byte
}

type DeploymentDetailsMock

type DeploymentDetailsMock struct {
	// DataFunc mocks the Data method.
	DataFunc func() map[string][]byte
	// contains filtered or unexported fields
}

DeploymentDetailsMock is a mock implementation of DeploymentDetails.

func TestSomethingThatUsesDeploymentDetails(t *testing.T) {

	// make and configure a mocked DeploymentDetails
	mockedDeploymentDetails := &DeploymentDetailsMock{
		DataFunc: func() map[string][]byte {
			panic("mock out the Data method")
		},
	}

	// use mockedDeploymentDetails in code that requires DeploymentDetails
	// and then make assertions.

}

func (*DeploymentDetailsMock) Data

func (mock *DeploymentDetailsMock) Data() map[string][]byte

Data calls DataFunc.

func (*DeploymentDetailsMock) DataCalls

func (mock *DeploymentDetailsMock) DataCalls() []struct {
}

DataCalls gets all the calls that were made to Data. Check the length with:

len(mockedDeploymentDetails.DataCalls())

type DeploymentStrategyMapping

type DeploymentStrategyMapping struct {
	BlobStorage string `json:"blobstorage"`
	Redis       string `json:"redis"`
	Postgres    string `json:"postgres"`
}

DeploymentStrategyMapping Deployment Strategy Map

type GenericCloudMetric

type GenericCloudMetric struct {
	Name   string
	Labels map[string]string
	Value  float64
}

GenericCloudMetric is a wrapper to represent provider specific metrics generically

func (*GenericCloudMetric) IsIncludedInSlice added in v1.0.0

func (gcm *GenericCloudMetric) IsIncludedInSlice(metrics []*GenericCloudMetric) bool

type PostgresDeploymentDetails

type PostgresDeploymentDetails struct {
	Username string
	Password string
	Host     string
	Database string
	Port     int
}

func (*PostgresDeploymentDetails) Data

func (d *PostgresDeploymentDetails) Data() map[string][]byte

type PostgresInstance

type PostgresInstance struct {
	DeploymentDetails DeploymentDetails
}

type PostgresMetricsProvider

type PostgresMetricsProvider interface {
	SupportsStrategy(s string) bool
	ScrapePostgresMetrics(ctx context.Context, postgres *v1alpha1.Postgres, metricTypes []CloudProviderMetricType) (*ScrapeMetricsData, error)
}

type PostgresProvider

type PostgresProvider interface {
	GetName() string
	SupportsStrategy(s string) bool
	GetReconcileTime(ps *v1alpha1.Postgres) time.Duration
	ReconcilePostgres(ctx context.Context, ps *v1alpha1.Postgres) (*PostgresInstance, croType.StatusMessage, error)
	DeletePostgres(ctx context.Context, ps *v1alpha1.Postgres) (croType.StatusMessage, error)
}

type PostgresSnapshotInstance

type PostgresSnapshotInstance struct {
	Name string
}

type PostgresSnapshotProvider

type PostgresSnapshotProvider interface {
	GetName() string
	SupportsStrategy(s string) bool
	GetReconcileTime(snapshot *v1alpha1.PostgresSnapshot) time.Duration
	CreatePostgresSnapshot(ctx context.Context, snapshot *v1alpha1.PostgresSnapshot, postgres *v1alpha1.Postgres) (*PostgresSnapshotInstance, croType.StatusMessage, error)
	DeletePostgresSnapshot(ctx context.Context, snapshot *v1alpha1.PostgresSnapshot, posgres *v1alpha1.Postgres) (croType.StatusMessage, error)
}

type RedisCluster

type RedisCluster struct {
	DeploymentDetails DeploymentDetails
}

type RedisDeploymentDetails

type RedisDeploymentDetails struct {
	URI  string
	Port int64
}

RedisDeploymentDetails provider specific details about the AWS Redis Cluster created

func (*RedisDeploymentDetails) Data

func (r *RedisDeploymentDetails) Data() map[string][]byte

Data Redis provider Data function

type RedisMetricsProvider

type RedisMetricsProvider interface {
	SupportsStrategy(s string) bool
	ScrapeRedisMetrics(ctx context.Context, redis *v1alpha1.Redis, metricsTypes []CloudProviderMetricType) (*ScrapeMetricsData, error)
}

type RedisProvider

type RedisProvider interface {
	GetName() string
	SupportsStrategy(s string) bool
	GetReconcileTime(r *v1alpha1.Redis) time.Duration
	CreateRedis(ctx context.Context, r *v1alpha1.Redis) (*RedisCluster, croType.StatusMessage, error)
	DeleteRedis(ctx context.Context, r *v1alpha1.Redis) (croType.StatusMessage, error)
}

type RedisSnapshotInstance

type RedisSnapshotInstance struct {
	Name string
}

type RedisSnapshotProvider

type RedisSnapshotProvider interface {
	GetName() string
	SupportsStrategy(s string) bool
	GetReconcileTime(snapshot *v1alpha1.RedisSnapshot) time.Duration
	CreateRedisSnapshot(ctx context.Context, snapshot *v1alpha1.RedisSnapshot, redis *v1alpha1.Redis) (*RedisSnapshotInstance, croType.StatusMessage, error)
	DeleteRedisSnapshot(ctx context.Context, snapshot *v1alpha1.RedisSnapshot, redis *v1alpha1.Redis) (croType.StatusMessage, error)
}

type ResourceType

type ResourceType string

type ScrapeMetricsData

type ScrapeMetricsData struct {
	// Metrics is an array of built cloud metrics from scraping a provider
	Metrics []*GenericCloudMetric
}

ScrapeMetricsData is a wrapper for output of scrape metrics

Directories

Path Synopsis
Cluster VPC and networking setup
Cluster VPC and networking setup
gcp

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL