Skip to content

Commit

Permalink
PR feedback and adding comments (#3741)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminjb authored Oct 12, 2023
1 parent a026ab5 commit 33e497b
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ spec:
properties:
adminUsername:
description: AdminUsername is the username to set during pgAdmin startup.
pgAdmin requires this to have a valid email form.
pgAdmin requires this to have a valid email form in order to log
in. Once set, this cannot be changed.
type: string
affinity:
description: 'Scheduling constraints of the PGAdmin pod. More info:
Expand Down
2 changes: 1 addition & 1 deletion docs/content/references/crd.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions internal/controller/standalone_pgadmin/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,12 @@ func generateClusterConfig(
sort.Strings(keys)

clusterServers := map[int]any{}
// Because we allow multiple ServerGroups to be defined, we use `currentOffset` to keep
// track of the last number added to the `Servers` group
var currentOffset = 0
for _, serverGroupName := range keys {
sort.Slice(clusters[serverGroupName].Items,
func(i, j int) bool {
return clusters[serverGroupName].Items[i].Name < clusters[serverGroupName].Items[j].Name
})
for i, cluster := range clusters[serverGroupName].Items {
for _, cluster := range clusters[serverGroupName].Items {
object := map[string]any{
"Name": cluster.Name,
"Group": serverGroupName,
Expand All @@ -167,9 +164,8 @@ func generateClusterConfig(
"SSLMode": "prefer",
"Shared": true,
}
clusterServers[i+1+currentOffset] = object
clusterServers[len(clusterServers)+1] = object
}
currentOffset = len(clusters[serverGroupName].Items) + currentOffset
}
servers := map[string]any{
"Servers": clusterServers,
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/standalone_pgadmin/postgrescluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (r *PGAdminReconciler) findPGAdminsForPostgresCluster(
}) == nil {
for i := range pgadmins.Items {
for _, serverGroup := range pgadmins.Items[i].Spec.ServerGroups {
if selector, err := naming.AsSelector(*serverGroup.PostgresClusterSelector); err == nil {
if selector, err := naming.AsSelector(serverGroup.PostgresClusterSelector); err == nil {
if selector.Matches(labels.Set(cluster.GetLabels())) {
matching = append(matching, &pgadmins.Items[i])
}
Expand All @@ -67,7 +67,7 @@ func (r *PGAdminReconciler) getClustersForPGAdmin(
var selector labels.Selector

for _, serverGroup := range pgAdmin.Spec.ServerGroups {
if selector, err = naming.AsSelector(*serverGroup.PostgresClusterSelector); err == nil {
if selector, err = naming.AsSelector(serverGroup.PostgresClusterSelector); err == nil {
var filteredList v1beta1.PostgresClusterList
err = r.List(ctx, &filteredList,
client.InNamespace(pgAdmin.Namespace),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ type PGAdminSpec struct {
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

// AdminUsername is the username to set during pgAdmin startup.
// pgAdmin requires this to have a valid email form.
// pgAdmin requires this to have a valid email form in order to log in.
// Once set, this cannot be changed.
// +optional
AdminUsername string `json:"adminUsername"`

Expand All @@ -126,7 +127,7 @@ type ServerGroup struct {

// PostgresClusterSelector selects clusters to dynamically add to pgAdmin by matching labels.
// An empty selector like `{}` will select ALL clusters in the namespace.
PostgresClusterSelector *metav1.LabelSelector `json:"postgresClusterSelector"`
PostgresClusterSelector metav1.LabelSelector `json:"postgresClusterSelector"`
}

// PGAdminStatus defines the observed state of PGAdmin
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 33e497b

Please sign in to comment.