Skip to content

Commit 94f6057

Browse files
Anthony Landrethtony-landreth
authored andcommitted
Uses apierrors instead of strings.Contains
1 parent b258f9c commit 94f6057

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

internal/cmd/backup.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ package cmd
1616

1717
import (
1818
"context"
19-
"strings"
2019
"time"
2120

2221
"github.com/spf13/cobra"
22+
apierrors "k8s.io/apimachinery/pkg/api/errors"
2323
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2424
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2525
"k8s.io/apimachinery/pkg/types"
@@ -129,7 +129,7 @@ postgresclusters/hippo backup initiated`)
129129
)
130130

131131
if err != nil {
132-
if strings.Contains(err.Error(), "conflict") {
132+
if apierrors.IsConflict(err) {
133133
cmd.Printf("SUGGESTION: The --force-conflicts flag may help in performing this operation.")
134134
}
135135
cmd.Printf("\nError requesting update: %s\n", err)

internal/cmd/restore.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"time"
2222

2323
"github.com/spf13/cobra"
24+
apierrors "k8s.io/apimachinery/pkg/api/errors"
2425
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2526
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2627
"k8s.io/apimachinery/pkg/types"
@@ -193,7 +194,7 @@ func (config pgBackRestRestore) Run(ctx context.Context) error {
193194
config.PostgresCluster, types.ApplyPatchType, patch,
194195
config.Patch.PatchOptions(patchOptions))
195196
if err != nil {
196-
if strings.Contains(err.Error(), "conflict") {
197+
if apierrors.IsConflict(err) {
197198
fmt.Fprintf(config.Out, "SUGGESTION: The --force-conflicts flag may help in performing this operation.\n")
198199
}
199200
return err

0 commit comments

Comments
 (0)