Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: liubo02 <[email protected]>
  • Loading branch information
liubog2008 committed Sep 11, 2023
1 parent f6c53bd commit a89348b
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 44 deletions.
6 changes: 3 additions & 3 deletions apis/globalaccelerator/v1alpha1/referencers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package v1alpha1
import (
"github.com/crossplane/crossplane-runtime/pkg/reference"
"github.com/crossplane/crossplane-runtime/pkg/resource"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

// AcceleratorARN returns the status.atProvider.ARN of an Accelerator
Expand All @@ -14,7 +14,7 @@ func AcceleratorARN() reference.ExtractValueFn {
return ""
}

return pointer.StringDeref(r.Status.AtProvider.AcceleratorARN, "")
return ptr.Deref(r.Status.AtProvider.AcceleratorARN, "")
}
}

Expand All @@ -26,6 +26,6 @@ func ListenerARN() reference.ExtractValueFn {
return ""
}

return pointer.StringDeref(r.Status.AtProvider.ListenerARN, "")
return ptr.Deref(r.Status.AtProvider.ListenerARN, "")
}
}
18 changes: 9 additions & 9 deletions pkg/clients/database/rds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
Expand Down Expand Up @@ -349,12 +349,12 @@ func TestIsUpToDate(t *testing.T) {
"EngineVersionUpgrade": {
args: args{
db: rdstypes.DBInstance{
EngineVersion: pointer.String("12.3"),
EngineVersion: ptr.To("12.3"),
},
r: v1beta1.RDSInstance{
Spec: v1beta1.RDSInstanceSpec{
ForProvider: v1beta1.RDSInstanceParameters{
EngineVersion: pointer.String("12.7"),
EngineVersion: ptr.To("12.7"),
},
},
},
Expand All @@ -364,12 +364,12 @@ func TestIsUpToDate(t *testing.T) {
"EngineVersionUpgradeMajorVersion": {
args: args{
db: rdstypes.DBInstance{
EngineVersion: pointer.String("12.3"),
EngineVersion: ptr.To("12.3"),
},
r: v1beta1.RDSInstance{
Spec: v1beta1.RDSInstanceSpec{
ForProvider: v1beta1.RDSInstanceParameters{
EngineVersion: pointer.String("13.7"),
EngineVersion: ptr.To("13.7"),
},
},
},
Expand All @@ -379,12 +379,12 @@ func TestIsUpToDate(t *testing.T) {
"EngineVersionMajorVersionOnly": {
args: args{
db: rdstypes.DBInstance{
EngineVersion: pointer.String("12.3"),
EngineVersion: ptr.To("12.3"),
},
r: v1beta1.RDSInstance{
Spec: v1beta1.RDSInstanceSpec{
ForProvider: v1beta1.RDSInstanceParameters{
EngineVersion: pointer.String("12"),
EngineVersion: ptr.To("12"),
},
},
},
Expand All @@ -394,12 +394,12 @@ func TestIsUpToDate(t *testing.T) {
"EngineVersionDowngrade": {
args: args{
db: rdstypes.DBInstance{
EngineVersion: pointer.String("12.3"),
EngineVersion: ptr.To("12.3"),
},
r: v1beta1.RDSInstance{
Spec: v1beta1.RDSInstanceSpec{
ForProvider: v1beta1.RDSInstanceParameters{
EngineVersion: pointer.String("12.1"),
EngineVersion: ptr.To("12.1"),
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/clients/ec2/tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/aws/smithy-go/document"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

func TestDiffEC2Tags(t *testing.T) {
Expand Down Expand Up @@ -239,7 +239,7 @@ func TestDiffEC2Tags(t *testing.T) {
for name, tc := range cases {
t.Run(name, func(t *testing.T) {
tagCmp := cmpopts.SortSlices(func(i, j ec2types.Tag) bool {
return pointer.StringDeref(i.Key, "") < pointer.StringDeref(j.Key, "")
return ptr.Deref(i.Key, "") < ptr.Deref(j.Key, "")
})
add, remove := DiffEC2Tags(tc.args.local, tc.args.remote)
if diff := cmp.Diff(tc.want.add, add, tagCmp, cmpopts.IgnoreTypes(document.NoSerde{})); diff != "" {
Expand Down
18 changes: 9 additions & 9 deletions pkg/controller/docdb/dbcluster/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/pkg/errors"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/aws/aws-sdk-go/aws/request"
Expand Down Expand Up @@ -2229,7 +2229,7 @@ func TestCreate(t *testing.T) {
{Key: awsclient.String(testTagKey), Value: awsclient.String(testTagValue)},
{Key: awsclient.String(testOtherTagKey), Value: awsclient.String(testOtherTagValue)},
},
SnapshotIdentifier: pointer.String("abcd"),
SnapshotIdentifier: ptr.To("abcd"),
},
},
},
Expand Down Expand Up @@ -2372,9 +2372,9 @@ func TestCreate(t *testing.T) {
withMasterPasswordSecretRef(testMasterPasswordSecretNamespace, testMasterPasswordSecretName, testMasterPasswordSecretKey),
withRestoreToPointInTime(&svcapitypes.RestorePointInTimeConfiguration{
RestoreTime: &metav1.Time{Time: timeNow},
UseLatestRestorableTime: pointer.Bool(true),
UseLatestRestorableTime: ptr.To(true),
SourceDBClusterIdentifier: "abcd",
RestoreType: pointer.String("full-copy"),
RestoreType: ptr.To("full-copy"),
}),
),
},
Expand Down Expand Up @@ -2419,9 +2419,9 @@ func TestCreate(t *testing.T) {
withStatusDBClusterParameterGroupName(testDBClusterParameterGroupName),
withRestoreToPointInTime(&svcapitypes.RestorePointInTimeConfiguration{
RestoreTime: &metav1.Time{Time: timeNow},
UseLatestRestorableTime: pointer.Bool(true),
UseLatestRestorableTime: ptr.To(true),
SourceDBClusterIdentifier: "abcd",
RestoreType: pointer.String("full-copy"),
RestoreType: ptr.To("full-copy"),
}),
),
result: managed.ExternalCreation{
Expand Down Expand Up @@ -2456,9 +2456,9 @@ func TestCreate(t *testing.T) {
{Key: awsclient.String(testOtherTagKey), Value: awsclient.String(testOtherTagValue)},
},
RestoreToTime: &timeNow,
UseLatestRestorableTime: pointer.Bool(true),
SourceDBClusterIdentifier: pointer.String("abcd"),
RestoreType: pointer.String("full-copy"),
UseLatestRestorableTime: ptr.To(true),
SourceDBClusterIdentifier: ptr.To("abcd"),
RestoreType: ptr.To("full-copy"),
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/dynamodb/table/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
svcsdkapi "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface"
"github.com/google/go-cmp/cmp"
"github.com/pkg/errors"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand Down Expand Up @@ -106,7 +106,7 @@ func (e *updateClient) postUpdate(_ context.Context, cr *svcapitypes.Table, obj
pitrStatusBool := pitrStatusToBool(pitrStatus)

if !isPitrUpToDate(cr, pitrStatusBool) {
pitrSpecEnabled := pointer.BoolDeref(cr.Spec.ForProvider.PointInTimeRecoveryEnabled, false)
pitrSpecEnabled := ptr.Deref(cr.Spec.ForProvider.PointInTimeRecoveryEnabled, false)

pitrInput := &svcsdk.UpdateContinuousBackupsInput{
TableName: aws.String(meta.GetExternalName(cr)),
Expand Down Expand Up @@ -451,7 +451,7 @@ func (e *updateClient) isUpToDate(ctx context.Context, cr *svcapitypes.Table, re
}

func pitrStatusToBool(pitrStatus *string) bool {
return pointer.StringDeref(pitrStatus, "") == string(svcapitypes.PointInTimeRecoveryStatus_ENABLED)
return ptr.Deref(pitrStatus, "") == string(svcapitypes.PointInTimeRecoveryStatus_ENABLED)
}

type updateClient struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/ec2/vpcendpoint/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/pkg/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/crossplane-contrib/provider-aws/apis/ec2/v1alpha1"
Expand Down Expand Up @@ -585,7 +585,7 @@ func TestTagger(t *testing.T) {
}

tag := func(k, v string) *v1alpha1.Tag {
return &v1alpha1.Tag{Key: pointer.String(k), Value: pointer.String(v)}
return &v1alpha1.Tag{Key: ptr.To(k), Value: ptr.To(v)}
}

cases := map[string]struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
cpresource "github.com/crossplane/crossplane-runtime/pkg/resource"
"github.com/crossplane/crossplane-runtime/pkg/test"
"github.com/google/go-cmp/cmp"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/crossplane-contrib/provider-aws/apis/ec2/v1alpha1"
Expand Down Expand Up @@ -60,7 +60,7 @@ func TestTagger(t *testing.T) {
}

tag := func(k, v string) *v1alpha1.Tag {
return &v1alpha1.Tag{Key: pointer.String(k), Value: pointer.String(v)}
return &v1alpha1.Tag{Key: ptr.To(k), Value: ptr.To(v)}
}

cases := map[string]struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/ec2/vpcpeeringconnection/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
cpresource "github.com/crossplane/crossplane-runtime/pkg/resource"
"github.com/crossplane/crossplane-runtime/pkg/test"
"github.com/google/go-cmp/cmp"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/crossplane-contrib/provider-aws/apis/ec2/v1alpha1"
Expand Down Expand Up @@ -61,7 +61,7 @@ func TestTagger(t *testing.T) {
}

tag := func(k, v string) *v1alpha1.Tag {
return &v1alpha1.Tag{Key: pointer.String(k), Value: pointer.String(v)}
return &v1alpha1.Tag{Key: ptr.To(k), Value: ptr.To(v)}
}

cases := map[string]struct {
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/globalaccelerator/accelerator/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/crossplane/crossplane-runtime/pkg/meta"
"github.com/crossplane/crossplane-runtime/pkg/reconciler/managed"
"github.com/crossplane/crossplane-runtime/pkg/resource"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"

svcapitypes "github.com/crossplane-contrib/provider-aws/apis/globalaccelerator/v1alpha1"
Expand Down Expand Up @@ -90,7 +90,7 @@ func (d gaClient) preDelete(ctx context.Context, cr *svcapitypes.Accelerator, ob
return false, err
}

if pointer.BoolDeref(descResp.Accelerator.Enabled, true) && pointer.StringDeref(descResp.Accelerator.Status, "") != svcsdk.AcceleratorStatusInProgress {
if ptr.Deref(descResp.Accelerator.Enabled, true) && ptr.Deref(descResp.Accelerator.Status, "") != svcsdk.AcceleratorStatusInProgress {
enabled := false
updReq := &svcsdk.UpdateAcceleratorInput{
Enabled: &enabled,
Expand Down Expand Up @@ -135,11 +135,11 @@ func postCreate(_ context.Context, cr *svcapitypes.Accelerator, resp *svcsdk.Cre
}

func isUpToDate(_ context.Context, cr *svcapitypes.Accelerator, resp *svcsdk.DescribeAcceleratorOutput) (bool, string, error) {
if pointer.BoolDeref(cr.Spec.ForProvider.Enabled, false) != pointer.BoolDeref(resp.Accelerator.Enabled, false) {
if ptr.Deref(cr.Spec.ForProvider.Enabled, false) != ptr.Deref(resp.Accelerator.Enabled, false) {
return false, "", nil
}

if pointer.StringDeref(cr.Spec.ForProvider.Name, "") != pointer.StringDeref(resp.Accelerator.Name, "") {
if ptr.Deref(cr.Spec.ForProvider.Name, "") != ptr.Deref(resp.Accelerator.Name, "") {
return false, "", nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/globalaccelerator/endpointgroup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/crossplane/crossplane-runtime/pkg/meta"
"github.com/crossplane/crossplane-runtime/pkg/reconciler/managed"
"github.com/crossplane/crossplane-runtime/pkg/resource"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"

svcapitypes "github.com/crossplane-contrib/provider-aws/apis/globalaccelerator/v1alpha1"
Expand Down Expand Up @@ -63,7 +63,7 @@ func preObserve(ctx context.Context, cr *svcapitypes.EndpointGroup, obj *svcsdk.
}

func preCreate(_ context.Context, cr *svcapitypes.EndpointGroup, obj *svcsdk.CreateEndpointGroupInput) error {
obj.ListenerArn = aws.String(pointer.StringDeref(cr.Spec.ForProvider.CustomEndpointGroupParameters.ListenerARN, ""))
obj.ListenerArn = aws.String(ptr.Deref(cr.Spec.ForProvider.CustomEndpointGroupParameters.ListenerARN, ""))
obj.IdempotencyToken = aws.String(string(cr.UID))
return nil
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/globalaccelerator/listener/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/aws/aws-sdk-go/aws"
svcsdk "github.com/aws/aws-sdk-go/service/globalaccelerator"
"k8s.io/utils/ptr"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
"github.com/crossplane/crossplane-runtime/pkg/connection"
Expand All @@ -14,7 +15,6 @@ import (
"github.com/crossplane/crossplane-runtime/pkg/meta"
"github.com/crossplane/crossplane-runtime/pkg/reconciler/managed"
"github.com/crossplane/crossplane-runtime/pkg/resource"
"k8s.io/utils/pointer"
ctrl "sigs.k8s.io/controller-runtime"

svcapitypes "github.com/crossplane-contrib/provider-aws/apis/globalaccelerator/v1alpha1"
Expand Down Expand Up @@ -62,7 +62,7 @@ func preObserve(ctx context.Context, cr *svcapitypes.Listener, obj *svcsdk.Descr
}

func preCreate(_ context.Context, cr *svcapitypes.Listener, obj *svcsdk.CreateListenerInput) error {
obj.AcceleratorArn = aws.String(pointer.StringDeref(cr.Spec.ForProvider.CustomListenerParameters.AcceleratorArn, ""))
obj.AcceleratorArn = aws.String(ptr.Deref(cr.Spec.ForProvider.CustomListenerParameters.AcceleratorArn, ""))
obj.IdempotencyToken = aws.String(string(cr.UID))
return nil
}
Expand Down Expand Up @@ -119,11 +119,11 @@ func isUpToDate(_ context.Context, cr *svcapitypes.Listener, resp *svcsdk.Descri
}
}

if pointer.StringDeref(cr.Spec.ForProvider.ClientAffinity, "") != *resp.Listener.ClientAffinity {
if ptr.Deref(cr.Spec.ForProvider.ClientAffinity, "") != *resp.Listener.ClientAffinity {
return false, "", nil
}

if pointer.StringDeref(cr.Spec.ForProvider.Protocol, "") != *resp.Listener.Protocol {
if ptr.Deref(cr.Spec.ForProvider.Protocol, "") != *resp.Listener.Protocol {
return false, "", nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/s3/bucket/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/aws/smithy-go"
"github.com/crossplane/crossplane-runtime/pkg/test"
"github.com/google/go-cmp/cmp"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

"github.com/crossplane-contrib/provider-aws/apis/s3/common"
"github.com/crossplane-contrib/provider-aws/apis/s3/v1beta1"
Expand Down Expand Up @@ -177,7 +177,7 @@ func TestPolicyObserve(t *testing.T) {
Conditions: []common.ConditionPair{
{
ConditionKey: "aws:SecureTransport",
ConditionBooleanValue: pointer.Bool(false),
ConditionBooleanValue: ptr.To(false),
},
},
},
Expand Down

0 comments on commit a89348b

Please sign in to comment.