Documentation ¶
Index ¶
- Constants
- Variables
- func EnvWithDefault(name, defValue string) string
- func EnvWithDefaultBool(name string, defValue bool) bool
- func WithDefault(value, defValue string) string
- type TestClient
- func (c *TestClient) DeleteAllForeground(set map[string]string, obj runtimeClient.Object) error
- func (c *TestClient) Logs(pod, container, namespace string) (string, error)
- func (c *TestClient) WriteAllResourcesToFile(dir string)
- func (c *TestClient) WriteKindToFile(dir, namespace, suffix string, list runtimeClient.ObjectList, set labels.Set)
Constants ¶
View Source
const (
DefaultNamespace = "gingersnap-operator-system"
)
Variables ¶
View Source
var ( OperatorNamespace = EnvWithDefault("TEST_OPERATOR_NAMESPACE", DefaultNamespace) Namespace = EnvWithDefault("TEST_NAMESPACE", DefaultNamespace) CleanupTestNamespace = EnvWithDefaultBool("TEST_NAMESPACE_DELETE", true) OutputDir = EnvWithDefault("TEST_OUTPUT_DIR", os.TempDir()+"/gingersnap-operator") MultiNamespace = Namespace != OperatorNamespace )
View Source
var MysqlConfigMap = &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: "mysql", Namespace: Namespace, }, Data: map[string]string{"setup.sql": ` create schema debezium; create table debezium.customer(id int not null, fullname varchar(255), email varchar(255), constraint primary key (id)); create table debezium.car_model(id int not null, model varchar(255), brand varchar(255), constraint primary key (id)); GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'gingersnap_user'; `}, }
View Source
var MysqlConnectionSecret = &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ Name: "db-credentials", Namespace: Namespace, }, StringData: map[string]string{ "host": fmt.Sprintf("%s.%s.svc.cluster.local", MysqlService.Name, MysqlService.Namespace), "port": "3306", "username": "gingersnap_user", "password": "password", "database": "debezium", }, }
View Source
var MysqlDeployment = &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: "mysql", Namespace: Namespace, Labels: mysqlLabels, }, Spec: appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{ MatchLabels: mysqlLabels, }, Template: corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: mysqlLabels, }, Spec: corev1.PodSpec{ Containers: []corev1.Container{{ Name: "mysql", Image: "mysql:latest", Args: []string{"--default-authentication-plugin=mysql_native_password"}, Env: []corev1.EnvVar{ {Name: "MYSQL_ROOT_PASSWORD", Value: "root"}, {Name: "MYSQL_USER", Value: "gingersnap_user"}, {Name: "MYSQL_PASSWORD", Value: "password"}, }, Ports: []corev1.ContainerPort{{ ContainerPort: 3306, }}, VolumeMounts: []corev1.VolumeMount{{ Name: "init-db", MountPath: "/docker-entrypoint-initdb.d", ReadOnly: true, }}, }}, Volumes: []corev1.Volume{{ Name: "init-db", VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ LocalObjectReference: corev1.LocalObjectReference{ Name: MysqlConfigMap.Name, }, }, }, }}, }, }, }, }
View Source
var MysqlService = &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: "mysql", Namespace: Namespace, }, Spec: corev1.ServiceSpec{ Type: corev1.ServiceTypeClusterIP, Ports: []corev1.ServicePort{{ Port: 3306, Protocol: corev1.ProtocolTCP, }}, Selector: MysqlDeployment.Labels, }, }
Functions ¶
func EnvWithDefault ¶
EnvWithDefault return os.Getenv(name) if exists else return defValue
func EnvWithDefaultBool ¶
EnvWithDefaultBool return os.Getenv(name) if exists else return defValue
func WithDefault ¶
WithDefault return value if not empty else return defValue
Types ¶
type TestClient ¶
func (*TestClient) DeleteAllForeground ¶
func (c *TestClient) DeleteAllForeground(set map[string]string, obj runtimeClient.Object) error
func (*TestClient) Logs ¶
func (c *TestClient) Logs(pod, container, namespace string) (string, error)
func (*TestClient) WriteAllResourcesToFile ¶
func (c *TestClient) WriteAllResourcesToFile(dir string)
func (*TestClient) WriteKindToFile ¶
func (c *TestClient) WriteKindToFile(dir, namespace, suffix string, list runtimeClient.ObjectList, set labels.Set)
Click to show internal directories.
Click to hide internal directories.