Skip to content

Commit 8849702

Browse files
author
Jeff McCormick
committed
fix bug in --secret-from and --password logic
1 parent a088bdf commit 8849702

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

conf/apiserver/pgo.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ Pgo:
5454
LSPVCTemplate: /config/pgo.lspvc-template.json
5555
LoadTemplate: /config/pgo.load-template.json
5656
COImagePrefix: crunchydata
57-
COImageTag: centos7-3.2
57+
COImageTag: centos7-3.2.0

operator/cluster/cluster.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,17 @@ func AddClusterBase(clientset *kubernetes.Clientset, client *rest.RESTClient, cl
157157
}
158158

159159
log.Debug("creating Pgcluster object strategy is [" + cl.Spec.Strategy + "]")
160+
//allows user to override with their own passwords
161+
if cl.Spec.Password != "" {
162+
log.Debug("user has set a password, will use that instead of generated ones or the secret-from settings")
163+
cl.Spec.RootPassword = cl.Spec.Password
164+
cl.Spec.Password = cl.Spec.Password
165+
cl.Spec.PrimaryPassword = cl.Spec.Password
166+
}
160167

161168
var err1, err2, err3 error
162169
if cl.Spec.SecretFrom != "" {
170+
log.Debug("secret-from is specified! using " + cl.Spec.SecretFrom)
163171
_, cl.Spec.RootPassword, err1 = util.GetPasswordFromSecret(clientset, namespace, cl.Spec.SecretFrom+crv1.RootSecretSuffix)
164172
_, cl.Spec.Password, err2 = util.GetPasswordFromSecret(clientset, namespace, cl.Spec.SecretFrom+crv1.UserSecretSuffix)
165173
_, cl.Spec.PrimaryPassword, err3 = util.GetPasswordFromSecret(clientset, namespace, cl.Spec.SecretFrom+crv1.PrimarySecretSuffix)
@@ -169,13 +177,6 @@ func AddClusterBase(clientset *kubernetes.Clientset, client *rest.RESTClient, cl
169177
}
170178
}
171179

172-
//allows user to override with their own passwords
173-
if cl.Spec.Password != "" {
174-
cl.Spec.RootPassword = cl.Spec.Password
175-
cl.Spec.Password = cl.Spec.Password
176-
cl.Spec.PrimaryPassword = cl.Spec.Password
177-
}
178-
179180
var testPassword string
180181
_, _, testPassword, err = util.CreateDatabaseSecrets(clientset, client, cl, namespace)
181182
if err != nil {

pgo/cmd/restore.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ var restoreCmd = &cobra.Command{
4848
fmt.Println("Error: You must specify the --to-cluster flag.")
4949
os.Exit(2)
5050
}
51+
/**
5152
if RestoreOpts == "" {
5253
fmt.Println("Error: You must specify the --restore-opts flag.")
5354
os.Exit(2)
5455
}
56+
*/
5557
restore(args)
5658
}
5759

@@ -62,7 +64,7 @@ func init() {
6264
RootCmd.AddCommand(restoreCmd)
6365

6466
restoreCmd.Flags().StringVarP(&ToCluster, "to-cluster", "", "", "The name of the new cluster to restore to.")
65-
restoreCmd.Flags().StringVarP(&RestoreOpts, "restore-opts", "", "full", "The options for the restore.")
67+
restoreCmd.Flags().StringVarP(&RestoreOpts, "restore-opts", "", "", "The options for the restore.")
6668
restoreCmd.Flags().StringVarP(&PITRTarget, "pitr-target", "", "", "The PITR target, being a PostgreSQL timestamp such as '2018-08-13 11:25:42.582117-04'.")
6769

6870
}

0 commit comments

Comments
 (0)