client

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Examples

Constants

View Source
const (
	DbUsernameName = "USERNAME"
	DbPasswordName = "PASSWORD"
)

Variables

This section is empty.

Functions

func GetObjectGVK

func GetObjectGVK(obj ctrlclient.Object) (*schema.GroupVersionKind, error)

Types

type Client

type Client struct {
	Client ctrlclient.Client

	OwnerReference ctrlclient.Object
}

func (*Client) CreateOrUpdate

func (c *Client) CreateOrUpdate(ctx context.Context, obj ctrlclient.Object) (mutation bool, err error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, obj ctrlclient.Object) error

Get the object from the cluster If the object has no namespace, it will use the owner namespace

Example
client := &Client{}

// Get a service in the same namespace as the owner object
svcInOwnerNamespace := &corev1.Service{
	ObjectMeta: metav1.ObjectMeta{Name: "my-svc"},
}

if err := client.Get(context.Background(), svcInOwnerNamespace); err != nil {
	return
}

// Get a service in another namespace
svcInAnotherNamespace := &corev1.Service{
	ObjectMeta: metav1.ObjectMeta{Name: "my-svc", Namespace: "another-ns"},
}
if err := client.Get(context.Background(), svcInAnotherNamespace); err != nil {
	return
}

func (*Client) GetCtrlClient

func (c *Client) GetCtrlClient() ctrlclient.Client

func (*Client) GetCtrlScheme

func (c *Client) GetCtrlScheme() *runtime.Scheme

func (*Client) GetOwnerName

func (c *Client) GetOwnerName() string

func (*Client) GetOwnerNamespace

func (c *Client) GetOwnerNamespace() string

func (*Client) GetOwnerReference

func (c *Client) GetOwnerReference() ctrlclient.Object

func (*Client) SetOwnerReference

func (c *Client) SetOwnerReference(obj ctrlclient.Object, gvk *schema.GroupVersionKind) error

type DataBaseType

type DataBaseType string
const (
	Postgres DataBaseType = "postgresql"
	Mysql    DataBaseType = "mysql"
	Derby    DataBaseType = "derby"
	Unknown  DataBaseType = "unknown"
)

type DatabaseConfiguration

type DatabaseConfiguration struct {
	DbReference *string
	DbInline    *DatabaseParams
	Namespace   string
	Context     context.Context
	Client      *Client
}

DatabaseConfiguration is a struct that holds the configuration for a database. example1:

dbConfig := &DatabaseConfiguration{DbReference: &ref, Context: ctx, Client: client}
dbConfig.GetDatabaseParams()
dbConfig.GetURI()

example2:

func (*DatabaseConfiguration) GetCredential

func (d *DatabaseConfiguration) GetCredential(name string) (*DatabaseCredential, error)

func (*DatabaseConfiguration) GetDatabaseParams

func (d *DatabaseConfiguration) GetDatabaseParams() (*DatabaseParams, error)

func (*DatabaseConfiguration) GetJDBCUrl

func (d *DatabaseConfiguration) GetJDBCUrl() (string, error)

GetJDBCUrl returns the JDBC URL for the database. Supported: - Postgres - Mysql - Derby

  • `derby:dbName;create=true`, the dbName is a file path.

func (*DatabaseConfiguration) GetNamespace

func (d *DatabaseConfiguration) GetNamespace() string

func (*DatabaseConfiguration) GetRefDatabase

func (*DatabaseConfiguration) GetRefDatabaseConnection

func (d *DatabaseConfiguration) GetRefDatabaseConnection(name string) (commonsv1alph1.DatabaseConnection, error)

func (*DatabaseConfiguration) GetRefDatabaseName

func (d *DatabaseConfiguration) GetRefDatabaseName() string

type DatabaseCredential

type DatabaseCredential struct {
	Username string `json:"USERNAME"`
	Password string `json:"PASSWORD"`
}

type DatabaseParams

type DatabaseParams struct {
	DbType   DataBaseType
	Driver   string
	Username string
	Password string
	Host     string
	Port     int32
	DbName   string
}

func NewDatabaseParams

func NewDatabaseParams(
	Driver string,
	Username string,
	Password string,
	Host string,
	Port int32,
	DbName string) *DatabaseParams

Jump to

Keyboard shortcuts

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