Skip to content

Commit c1e0103

Browse files
committed
refactor describe clusterrole and clusterrolebinding
This makes it more clear that 'postgresoperator' is a special case for certain installers.
1 parent e42945e commit c1e0103

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

internal/cmd/export.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -606,27 +606,34 @@ Collecting PGO CLI logs...
606606
writeInfo(cmd, fmt.Sprintf("Error running kubectl describe postgrescluster: %s", err))
607607
}
608608

609+
// Resource name is generally 'postgres-operator' but in some environments
610+
// like Openshift it could be 'postgresoperator'
609611
writeInfo(cmd, "Running kubectl describe clusterrole...")
610612
err = runKubectlCommand(tw, cmd, clusterName+"/describe/clusterrole", "describe", "clusterrole", "postgres-operator")
611613
if err != nil {
614+
writeInfo(cmd, fmt.Sprintf("Error running kubectl describe clusterrole: %s", err))
612615
writeInfo(cmd, "Could not find clusterrole 'postgres-operator'. Looking for 'postgresoperator'...")
613-
writeInfo(cmd, "Running kubectl describe clusterrole...")
614-
err = runKubectlCommand(tw, cmd, clusterName+"/describe/clusterrole", "describe", "clusterrole", "postgresoperator")
615-
}
616616

617-
if err != nil {
618-
writeInfo(cmd, fmt.Sprintf("Error running kubectl describe clusterrole: %s", err))
617+
// Check for the alternative spelling with 'postgresoperator'
618+
err = runKubectlCommand(tw, cmd, clusterName+"/describe/clusterrole", "describe", "clusterrole", "postgresoperator")
619+
if err != nil {
620+
writeInfo(cmd, fmt.Sprintf("Error running kubectl describe clusterrole: %s", err))
621+
}
619622
}
620623

624+
// Resource name is generally 'postgres-operator' but in some environments
625+
// like Openshift it could be 'postgresoperator'
621626
writeInfo(cmd, "Running kubectl describe clusterrolebinding...")
622627
err = runKubectlCommand(tw, cmd, clusterName+"/describe/clusterrolebinding", "describe", "clusterrolebinding", "postgres-operator")
623628
if err != nil {
629+
writeInfo(cmd, fmt.Sprintf("Error running kubectl describe clusterrolebinding: %s", err))
630+
631+
// Check for the alternative spelling with 'postgresoperator'
624632
writeInfo(cmd, "Could not find clusterrolebinding 'postgres-operator'. Looking for 'postgresoperator'...")
625-
writeInfo(cmd, "Running kubectl describe clusterrole...")
626633
err = runKubectlCommand(tw, cmd, clusterName+"/describe/clusterrolebinding", "describe", "clusterrolebinding", "postgresoperator")
627-
}
628-
if err != nil {
629-
writeInfo(cmd, fmt.Sprintf("Error running kubectl describe clusterrolebinding: %s", err))
634+
if err != nil {
635+
writeInfo(cmd, fmt.Sprintf("Error running kubectl describe clusterrolebinding: %s", err))
636+
}
630637
}
631638

632639
writeInfo(cmd, "Running kubectl describe lease...")

0 commit comments

Comments
 (0)