Documentation
¶
Index ¶
- Constants
- func GetObjectGVK(obj ctrlclient.Object) (*schema.GroupVersionKind, error)
- type Client
- func (c *Client) CreateOrUpdate(ctx context.Context, obj ctrlclient.Object) (mutation bool, err error)
- func (c *Client) Get(ctx context.Context, obj ctrlclient.Object) error
- func (c *Client) GetCtrlClient() ctrlclient.Client
- func (c *Client) GetCtrlScheme() *runtime.Scheme
- func (c *Client) GetOwnerName() string
- func (c *Client) GetOwnerNamespace() string
- func (c *Client) GetOwnerReference() ctrlclient.Object
- func (c *Client) SetOwnerReference(obj ctrlclient.Object, gvk *schema.GroupVersionKind) error
- type DataBaseType
- type DatabaseConfiguration
- func (d *DatabaseConfiguration) GetCredential(name string) (*DatabaseCredential, error)
- func (d *DatabaseConfiguration) GetDatabaseParams() (*DatabaseParams, error)
- func (d *DatabaseConfiguration) GetJDBCUrl() (string, error)
- func (d *DatabaseConfiguration) GetNamespace() string
- func (d *DatabaseConfiguration) GetRefDatabase(ctx context.Context) (commonsv1alph1.Database, error)
- func (d *DatabaseConfiguration) GetRefDatabaseConnection(name string) (commonsv1alph1.DatabaseConnection, error)
- func (d *DatabaseConfiguration) GetRefDatabaseName() string
- type DatabaseCredential
- type DatabaseParams
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 (*Client) Get ¶
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 (*Client) GetOwnerName ¶
func (*Client) GetOwnerNamespace ¶
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 (d *DatabaseConfiguration) GetRefDatabase(ctx context.Context) (commonsv1alph1.Database, error)
func (*DatabaseConfiguration) GetRefDatabaseConnection ¶
func (d *DatabaseConfiguration) GetRefDatabaseConnection(name string) (commonsv1alph1.DatabaseConnection, error)
func (*DatabaseConfiguration) GetRefDatabaseName ¶
func (d *DatabaseConfiguration) GetRefDatabaseName() string
type DatabaseCredential ¶
type DatabaseParams ¶
type DatabaseParams struct {
DbType DataBaseType
Driver string
Username string
Password string
Host string
Port int32
DbName string
}
func NewDatabaseParams ¶
Click to show internal directories.
Click to hide internal directories.