Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEVOPS-3117 fix postgresdump #115

Merged
merged 2 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/cmd/decrypt.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func GetDecryptedData(kmsService kmsiface.KMSAPI, encryptedData []byte) ([]byte,
// Decrypt file content
plaintext, ok = secretbox.Open(plaintext, p.Message, p.Nonce, plainDataKey)
if !ok {
return plaintext, errors.Wrap(err, "error decrypting value with data key")
return plaintext, errors.New("Error decrypting value with data key")
}
return plaintext, nil
}
2 changes: 1 addition & 1 deletion pkg/cmd/edit/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func (o *Object) Decrypt(kmsService kmsiface.KMSAPI, recrypt bool) error {
var plaintext []byte
plaintext, ok = secretbox.Open(plaintext, p.Message, p.Nonce, plainDataKey)
if !ok {
return errors.Wrapf(err, "error decrypting value with data key for %s", key)
return errors.Errorf("error decrypting value with data key for %s", key)
}
dec.Data[key] = string(plaintext)
keyUsageCount[keyId] = keyUsageCount[keyId] + 1
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/password.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ var passwordCmd = &cobra.Command{
}
}
if len(readOnlysecrets) == 0 {
return errors.Wrapf(err, "no readonly secrets found for instance %s", args[0])
return errors.Errorf("no readonly secrets found for instance %s", args[0])
}
// prompt user to select a readonly secret
prompt := promptui.Select{
Expand Down
9 changes: 5 additions & 4 deletions pkg/cmd/postgresdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ var postgresdumpCMD = &cobra.Command{
}

postgresUserList := &v1beta2.PostgresUserList{}
_ = kubeObj.Client.List(ctx, postgresUserList, client.InNamespace(target.Namespace))
if len(postgresUserList.Items) == 0 {
return errors.Wrap(err, "failed to get postgres users list")
err = kubeObj.Client.List(ctx, postgresUserList, client.InNamespace(target.Namespace))
if err != nil {
return errors.Wrap(err, "failed to get postgres user")
}

postgresUser := &v1beta2.PostgresUser{}
for _, postgresUsr := range postgresUserList.Items {
if postgresUsr.Spec.Mode == "owner" && postgresUsr.Name == args[0] {
Expand All @@ -89,7 +90,7 @@ var postgresdumpCMD = &cobra.Command{
}
}
if postgresUser.Name == "" {
return errors.Wrap(err, "failed to get postgres user")
return fmt.Errorf("No Postgres users of type owner found in namespace: %s", target.Namespace)
}

var instanceName string
Expand Down