Skip to content

Commit

Permalink
Use --defaults-extra-file option to exec mysql command.
Browse files Browse the repository at this point in the history
Signed-off-by: Kazuhito MATSUDA <kazuhito.matuda@gmail.com>
  • Loading branch information
kfyharukz committed Nov 11, 2020
1 parent 3f5242d commit 9aedbd3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
8 changes: 3 additions & 5 deletions cmd/kubectl-moco/cmd/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"context"
"fmt"
"os"
"time"

Expand Down Expand Up @@ -54,12 +55,9 @@ func runMySQLCommand(ctx context.Context, clusterName string, cmd *cobra.Command
if err != nil {
return err
}
password, err := getPassword(ctx, moco.UniqueName(cluster), mysqlConfig.user)
if err != nil {
return err
}

commands := append([]string{podName, "--", "mysql", "-u", mysqlConfig.user, "-p" + password}, args...)
myCnfPath := fmt.Sprintf("%s/%s-my.cnf", moco.MyCnfSecretPath, mysqlConfig.user)
commands := append([]string{podName, "--", "mysql", "--defaults-extra-file=" + myCnfPath}, args...)
argsLenAtDash := 2
options := &cmdexec.ExecOptions{
StreamOptions: cmdexec.StreamOptions{
Expand Down
1 change: 0 additions & 1 deletion controllers/mysqlcluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ var _ = Describe("MySQLCluster controller", func() {
Expect(initSecret.Data).Should(HaveKey(moco.ReplicationPasswordKey))
Expect(initSecret.Data).Should(HaveKey(moco.CloneDonorPasswordKey))
Expect(initSecret.Data).Should(HaveKey(moco.MiscPasswordKey))
Expect(initSecret.Data).Should(HaveKey(moco.MiscPasswordKey))

ctrlSecret := &corev1.Secret{}
err = k8sClient.Get(ctx, client.ObjectKey{Namespace: ctrlSecretNS, Name: ctrlSecretName}, ctrlSecret)
Expand Down

0 comments on commit 9aedbd3

Please sign in to comment.