Skip to content

Commit 9879996

Browse files
committed
changed to boolean field, which indicatest provider behavior after databases and roles restoration
1 parent 336a6aa commit 9879996

12 files changed

Lines changed: 247 additions & 193 deletions

File tree

apis/cluster/postgresql/v1alpha1/role_types.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ type RoleParameters struct {
9191
// +optional
9292
ConfigurationParameters *[]RoleConfigurationParameter `json:"configurationParameters,omitempty"`
9393

94-
// PasswordResetToken can be set to any string to trigger a one-time password reset.
95-
// Useful after restoring a database from a snapshot, where roles already exist in the DB but
96-
// the connection secret may be empty. Change the token value to trigger another reset.
94+
// PasswordReset controls behaviour when the role exists in the database but the connection
95+
// secret has no password.
96+
// When true, a new password is generated and written to the connection secret.
9797
// +optional
98-
PasswordResetToken *string `json:"passwordResetToken,omitempty"`
98+
PasswordReset *bool `json:"passwordReset,omitempty"`
9999
}
100100

101101
// RoleConfigurationParameter is a role configuration parameter.
@@ -111,10 +111,6 @@ type RoleObservation struct {
111111
PrivilegesAsClauses []string `json:"privilegesAsClauses,omitempty"`
112112
// ConfigurationParameters represents the applied configuration parameters for the PostgreSQL role.
113113
ConfigurationParameters *[]RoleConfigurationParameter `json:"configurationParameters,omitempty"`
114-
// LastPasswordResetToken tracks the passwordResetToken value at which the last password reset was applied.
115-
// Used to prevent repeated resets when spec.forProvider.passwordResetToken is set.
116-
// +optional
117-
LastPasswordResetToken *string `json:"lastPasswordResetToken,omitempty"`
118114
}
119115

120116
// +kubebuilder:object:root=true

apis/cluster/postgresql/v1alpha1/zz_generated.deepcopy.go

Lines changed: 3 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/namespaced/postgresql/v1alpha1/role_types.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ type RoleParameters struct {
9292
// +optional
9393
ConfigurationParameters *[]RoleConfigurationParameter `json:"configurationParameters,omitempty"`
9494

95-
// PasswordResetToken can be set to any string to trigger a one-time password reset.
96-
// Useful after restoring a database from a snapshot, where roles already exist in the DB but
97-
// the connection secret may be empty. Change the token value to trigger another reset.
95+
// PasswordReset controls behaviour when the role exists in the database but the connection
96+
// secret has no password.
97+
// When true, a new password is generated and written to the connection secret.
9898
// +optional
99-
PasswordResetToken *string `json:"passwordResetToken,omitempty"`
99+
PasswordReset *bool `json:"passwordReset,omitempty"`
100100
}
101101

102102
// RoleConfigurationParameter is a role configuration parameter.
@@ -112,10 +112,6 @@ type RoleObservation struct {
112112
PrivilegesAsClauses []string `json:"privilegesAsClauses,omitempty"`
113113
// ConfigurationParameters represents the applied configuration parameters for the PostgreSQL role.
114114
ConfigurationParameters *[]RoleConfigurationParameter `json:"configurationParameters,omitempty"`
115-
// LastPasswordResetToken tracks the passwordResetToken value at which the last password reset was applied.
116-
// Used to prevent repeated resets when spec.forProvider.passwordResetToken is set.
117-
// +optional
118-
LastPasswordResetToken *string `json:"lastPasswordResetToken,omitempty"`
119115
}
120116

121117
// +kubebuilder:object:root=true

apis/namespaced/postgresql/v1alpha1/zz_generated.deepcopy.go

Lines changed: 3 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package/crds/postgresql.sql.crossplane.io_roles.yaml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,11 @@ spec:
9494
description: ConnectionLimit to be applied to the role.
9595
format: int32
9696
type: integer
97-
passwordResetToken:
97+
passwordReset:
9898
description: |-
99-
PasswordResetToken can be set to any string to trigger a one-time password reset.
100-
Useful after restoring a database from a snapshot, where roles already exist in the DB but
101-
the connection secret may be empty. Change the token value to trigger another reset.
102-
type: string
99+
PasswordReset controls behaviour when the role exists in the database but the connection
100+
secret has no password. When true, a new password is generated and written to the connection secret.
101+
type: boolean
103102
passwordSecretRef:
104103
description: |-
105104
PasswordSecretRef references the secret that contains the password used
@@ -258,11 +257,6 @@ spec:
258257
type: string
259258
type: object
260259
type: array
261-
lastPasswordResetToken:
262-
description: |-
263-
LastPasswordResetToken tracks the passwordResetToken value at which the last password reset was applied.
264-
Used to prevent repeated resets when spec.forProvider.passwordResetToken is set.
265-
type: string
266260
privilegesAsClauses:
267261
description: |-
268262
PrivilegesAsClauses represents the applied privileges state, taking into account

package/crds/postgresql.sql.m.crossplane.io_roles.yaml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,11 @@ spec:
8080
description: ConnectionLimit to be applied to the role.
8181
format: int32
8282
type: integer
83-
passwordResetToken:
83+
passwordReset:
8484
description: |-
85-
PasswordResetToken can be set to any string to trigger a one-time password reset.
86-
Useful after restoring a database from a snapshot, where roles already exist in the DB but
87-
the connection secret may be empty. Change the token value to trigger another reset.
88-
type: string
85+
PasswordReset controls behaviour when the role exists in the database but the connection
86+
secret has no password. When true, a new password is generated and written to the connection secret.
87+
type: boolean
8988
passwordSecretRef:
9089
description: |-
9190
PasswordSecretRef references the secret that contains the password used
@@ -211,11 +210,6 @@ spec:
211210
type: string
212211
type: object
213212
type: array
214-
lastPasswordResetToken:
215-
description: |-
216-
LastPasswordResetToken tracks the passwordResetToken value at which the last password reset was applied.
217-
Used to prevent repeated resets when spec.forProvider.passwordResetToken is set.
218-
type: string
219213
privilegesAsClauses:
220214
description: |-
221215
PrivilegesAsClauses represents the applied privileges state, taking into account

pkg/controller/cluster/postgresql/role/reconciler.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,6 @@ func (c *external) Update(ctx context.Context, mg *v1alpha1.Role) (managed.Exter
352352
}); err != nil {
353353
return managed.ExternalUpdate{}, errors.Wrap(err, errUpdateRole)
354354
}
355-
if mg.Spec.ForProvider.PasswordResetToken != nil {
356-
token := *mg.Spec.ForProvider.PasswordResetToken
357-
mg.Status.AtProvider.LastPasswordResetToken = &token
358-
}
359355
}
360356

361357
privs := privilegesToClauses(mg.Spec.ForProvider.Privileges)

0 commit comments

Comments
 (0)