Skip to content

Commit 89c48e4

Browse files
committed
refactor: replace pointer package usage with ptr package
Signed-off-by: Alejandro Recalde <alejandrorecalde5@gmail.com>
1 parent e71cc6e commit 89c48e4

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

pkg/controller/cluster/mysql/user/reconciler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ func (c *external) Create(ctx context.Context, mg resource.Managed) (managed.Ext
318318

319319
func (c *external) executeCreateUserQuery(ctx context.Context, username string, host string, plugin string, resourceOptionsClauses []string, pw *string) error {
320320
var identifiedClause string
321-
321+
322322
// When plugin is empty (nil or ""), use default auth: IDENTIFIED BY 'password'
323323
// When plugin is specified, use: IDENTIFIED WITH plugin BY 'password'
324324
// This ensures compatibility with both MySQL and MariaDB
@@ -407,7 +407,7 @@ func (c *external) applyAlterUserIfSomeFieldChanged(ctx context.Context, cr *v1a
407407

408408
func (c *external) executeAlterUserQuery(ctx context.Context, username string, host string, plugin string, pw string) error {
409409
var identifiedClause string
410-
410+
411411
// When plugin is empty (nil or ""), use default auth: IDENTIFIED BY 'password'
412412
// When plugin is specified, use: IDENTIFIED WITH plugin BY 'password'
413413
// This ensures compatibility with both MySQL and MariaDB

pkg/controller/cluster/mysql/user/reconciler_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"github.com/pkg/errors"
2929
corev1 "k8s.io/api/core/v1"
3030
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
31-
"k8s.io/utils/pointer"
31+
"k8s.io/utils/ptr"
3232
"sigs.k8s.io/controller-runtime/pkg/client"
3333

3434
xpv1 "github.com/crossplane/crossplane-runtime/v2/apis/common/v1"
@@ -529,8 +529,8 @@ func TestCreate(t *testing.T) {
529529
},
530530
Spec: v1alpha1.UserSpec{
531531
ForProvider: v1alpha1.UserParameters{
532-
AuthPlugin: pointer.StringPtr("authentication_ldap_simple"),
533-
UsePassword: pointer.BoolPtr(false),
532+
AuthPlugin: ptr.To("authentication_ldap_simple"),
533+
UsePassword: ptr.To(false),
534534
},
535535
},
536536
},
@@ -628,7 +628,7 @@ func TestUpdate(t *testing.T) {
628628
},
629629
Status: v1alpha1.UserStatus{
630630
AtProvider: v1alpha1.UserObservation{
631-
AuthPlugin: pointer.StringPtr(""),
631+
AuthPlugin: ptr.To(""),
632632
},
633633
},
634634
},
@@ -663,7 +663,7 @@ func TestUpdate(t *testing.T) {
663663
},
664664
Status: v1alpha1.UserStatus{
665665
AtProvider: v1alpha1.UserObservation{
666-
AuthPlugin: pointer.StringPtr(""),
666+
AuthPlugin: ptr.To(""),
667667
},
668668
},
669669
},
@@ -697,7 +697,7 @@ func TestUpdate(t *testing.T) {
697697
},
698698
Status: v1alpha1.UserStatus{
699699
AtProvider: v1alpha1.UserObservation{
700-
AuthPlugin: pointer.StringPtr(""),
700+
AuthPlugin: ptr.To(""),
701701
},
702702
},
703703
},
@@ -745,7 +745,7 @@ func TestUpdate(t *testing.T) {
745745
},
746746
Status: v1alpha1.UserStatus{
747747
AtProvider: v1alpha1.UserObservation{
748-
AuthPlugin: pointer.StringPtr(""),
748+
AuthPlugin: ptr.To(""),
749749
},
750750
},
751751
},
@@ -809,10 +809,10 @@ func TestUpdate(t *testing.T) {
809809
Key: xpv1.ResourceCredentialsSecretPasswordKey,
810810
},
811811
ResourceOptions: &v1alpha1.ResourceOptions{
812-
MaxQueriesPerHour: pointer.IntPtr(10),
813-
MaxUpdatesPerHour: pointer.IntPtr(10),
814-
MaxConnectionsPerHour: pointer.IntPtr(10),
815-
MaxUserConnections: pointer.IntPtr(10),
812+
MaxQueriesPerHour: ptr.To(10),
813+
MaxUpdatesPerHour: ptr.To(10),
814+
MaxConnectionsPerHour: ptr.To(10),
815+
MaxUserConnections: ptr.To(10),
816816
},
817817
},
818818
},
@@ -824,7 +824,7 @@ func TestUpdate(t *testing.T) {
824824
"MAX_CONNECTIONS_PER_HOUR 20",
825825
"MAX_USER_CONNECTIONS 20",
826826
},
827-
AuthPlugin: pointer.StringPtr(""), // default AuthPlugin value
827+
AuthPlugin: ptr.To(""), // default AuthPlugin value
828828
},
829829
},
830830
},
@@ -887,7 +887,7 @@ func TestUpdate(t *testing.T) {
887887
"MAX_CONNECTIONS_PER_HOUR 0",
888888
"MAX_USER_CONNECTIONS 0",
889889
},
890-
AuthPlugin: pointer.StringPtr(""), // default AuthPlugin value
890+
AuthPlugin: ptr.To(""), // default AuthPlugin value
891891
},
892892
},
893893
},
@@ -922,13 +922,13 @@ func TestUpdate(t *testing.T) {
922922
},
923923
Spec: v1alpha1.UserSpec{
924924
ForProvider: v1alpha1.UserParameters{
925-
AuthPlugin: pointer.StringPtr("authentication_ldap_simple"),
926-
UsePassword: pointer.BoolPtr(false),
925+
AuthPlugin: ptr.To("authentication_ldap_simple"),
926+
UsePassword: ptr.To(false),
927927
},
928928
},
929929
Status: v1alpha1.UserStatus{
930930
AtProvider: v1alpha1.UserObservation{
931-
AuthPlugin: pointer.StringPtr("authentication_ldap_simple"),
931+
AuthPlugin: ptr.To("authentication_ldap_simple"),
932932
},
933933
},
934934
},
@@ -962,12 +962,12 @@ func TestUpdate(t *testing.T) {
962962
},
963963
Key: xpv1.ResourceCredentialsSecretPasswordKey,
964964
},
965-
AuthPlugin: pointer.StringPtr(""),
965+
AuthPlugin: ptr.To(""),
966966
},
967967
},
968968
Status: v1alpha1.UserStatus{
969969
AtProvider: v1alpha1.UserObservation{
970-
AuthPlugin: pointer.StringPtr("authentication_ldap_simple"),
970+
AuthPlugin: ptr.To("authentication_ldap_simple"),
971971
},
972972
},
973973
},

0 commit comments

Comments
 (0)