// NewConfigFromClusterKey returns a new Config based on a MySQLCluster key
NewConfigFromClusterKey returns a new Config based on a MySQLCluster key
// NewConfigFromClusterKey returns a new Config based on a MySQLCluster key
func NewConfigFromClusterKey(c client.Client, clusterKey client.ObjectKey) (*Config, error) {
	cluster := &mysqlv1alpha1.MysqlCluster{}
	if err := c.Get(context.TODO(), clusterKey, cluster); err != nil {
		return nil, err
	}
	secret := &corev1.Secret{}
	secretKey := client.ObjectKey{Name: cluster.Spec.SecretName, Namespace: cluster.Namespace}
	if err := c.Get(context.TODO(), secretKey, secret); err != nil {
		return nil, err
	}
	return &Config{
		User:     "root",
		Password: string(secret.Data["ROOT_PASSWORD"]),
		Host:     fmt.Sprintf("%s-mysql-master.%s", cluster.Name, cluster.Namespace),
		Port:     3306,
	}, nil
}
func NewConfigFromClusterKey ( c client . Client , clusterKey client . ObjectKey ) ( * Config , error ) { cluster := & mysqlv1alpha1 . MysqlCluster { } if err := c . Get ( context . TODO ( ) , clusterKey , cluster ) ; err != nil { return nil , err } secret := & corev1 . Secret { } secretKey := client . ObjectKey { Name : cluster . Spec . SecretName , Namespace : cluster . Namespace } if err := c . Get ( context . TODO ( ) , secretKey , secret ) ; err != nil { return nil , err } return & Config { User : " " , Password : string ( secret . Data [ " " ] ) , Host : fmt . Sprintf ( " " , cluster . Name , cluster . Namespace ) , Port : 3306 , } , nil }
NewConfigFromClusterKey returns a new Config based on a MySQLCluster key
NewConfigFromClusterKey returns a new Config based on a MySQLCluster key