Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix lint issues #353

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/cloud-resources/v1beta1/awsnfsvolume_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ type AwsNfsVolumeStatus struct {
Id string `json:"id,omitempty"`

// +optional
Server string `json:"server,omitempty" json:"server,omitempty"`
Server string `json:"server,omitempty"`

// List of status conditions
// +optional
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

// +optional
State string `json:"state,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion api/cloud-resources/v1beta1/awsnfsvolumebackup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ type AwsNfsVolumeBackupStatus struct {
// +optional
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
2 changes: 1 addition & 1 deletion api/cloud-resources/v1beta1/cloudresources_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type CloudResourcesStatus struct {
// +optional
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
2 changes: 1 addition & 1 deletion api/cloud-resources/v1beta1/gcpnfsvolumebackup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ type GcpNfsVolumeBackupStatus struct {
// +optional
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

// Operation Identifier to track the Hyperscaler Restore Operation
// +optional
Expand Down
2 changes: 1 addition & 1 deletion api/cloud-resources/v1beta1/gcpnfsvolumerestore_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type GcpNfsVolumeRestoreStatus struct {
// +optional
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

// Operation Identifier to track the Hyperscaler Restore Operation
// +optional
Expand Down
2 changes: 1 addition & 1 deletion api/cloud-resources/v1beta1/nfsbackupschedule_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ type NfsBackupScheduleStatus struct {
// +optional
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

// NextRunTimes contains 0 or more entries of time when the next backup will be created
// +optional
Expand Down
12 changes: 6 additions & 6 deletions cmd/cli/cmdGardenShootCreateAws.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

var (
Expand Down Expand Up @@ -57,9 +57,9 @@ var cmdGardenShootCreateAws = &cobra.Command{
Region: cfg.Region,
Networking: &gardenerTypes.Networking{
IPFamilies: []gardenerTypes.IPFamily{gardenerTypes.IPFamilyIPv4},
Nodes: pointer.String("10.180.0.0/16"),
Pods: pointer.String("100.64.0.0/12"),
Services: pointer.String("100.104.0.0/13"),
Nodes: ptr.To("10.180.0.0/16"),
Pods: ptr.To("100.64.0.0/12"),
Services: ptr.To("100.104.0.0/13"),
},
Provider: gardenerTypes.Provider{
Type: "aws",
Expand All @@ -71,7 +71,7 @@ var cmdGardenShootCreateAws = &cobra.Command{
},
Networks: awsgardener.Networks{
VPC: awsgardener.VPC{
CIDR: pointer.String("10.180.0.0/16"),
CIDR: ptr.To("10.180.0.0/16"),
},
Zones: []awsgardener.Zone{
{
Expand All @@ -97,7 +97,7 @@ var cmdGardenShootCreateAws = &cobra.Command{
},
},
},
SecretBindingName: pointer.String(shootName),
SecretBindingName: ptr.To(shootName),
},
}
err = c.Create(context.Background(), shoot)
Expand Down
36 changes: 17 additions & 19 deletions internal/controller/cloud-control/iprange_aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
. "github.com/kyma-project/cloud-manager/pkg/testinfra/dsl"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

var _ = Describe("Feature: KCP IpRange", func() {
Expand Down Expand Up @@ -119,9 +119,9 @@ var _ = Describe("Feature: KCP IpRange", func() {
for _, iprangeSubnet := range iprange.Status.Subnets {
found := false
for _, awsSubnet := range subnets {
if iprangeSubnet.Id == pointer.StringDeref(awsSubnet.SubnetId, "") {
Expect(pointer.StringDeref(awsSubnet.AvailabilityZone, "")).To(Equal(iprangeSubnet.Zone))
Expect(pointer.StringDeref(awsSubnet.CidrBlock, "")).To(Equal(iprangeSubnet.Range))
if iprangeSubnet.Id == ptr.Deref(awsSubnet.SubnetId, "") {
Expect(ptr.Deref(awsSubnet.AvailabilityZone, "")).To(Equal(iprangeSubnet.Zone))
Expect(ptr.Deref(awsSubnet.CidrBlock, "")).To(Equal(iprangeSubnet.Range))
found = true
break
}
Expand All @@ -133,7 +133,7 @@ var _ = Describe("Feature: KCP IpRange", func() {
By("And Then KCP IpRange AWS VPC Cidr block is created", func() {
found := false
for _, cidrBlock := range theVpc.CidrBlockAssociationSet {
if pointer.StringDeref(cidrBlock.CidrBlock, "") == iprange.Spec.Cidr {
if ptr.Deref(cidrBlock.CidrBlock, "") == iprange.Spec.Cidr {
found = true
}
}
Expand Down Expand Up @@ -212,7 +212,7 @@ var _ = Describe("Feature: KCP IpRange", func() {
Expect(err).NotTo(HaveOccurred())
for _, iprangeSubnet := range iprange.Status.Subnets {
for _, awsSubnet := range awsSubnets {
if iprangeSubnet.Id == pointer.StringDeref(awsSubnet.SubnetId, "") {
if iprangeSubnet.Id == ptr.Deref(awsSubnet.SubnetId, "") {
theAwsSubnets = append(theAwsSubnets, awsSubnet)
break
}
Expand All @@ -238,14 +238,14 @@ var _ = Describe("Feature: KCP IpRange", func() {

for _, deletedSubnet := range theAwsSubnets {
for _, existingSubnet := range subnets {
Expect(pointer.StringDeref(deletedSubnet.SubnetId, "")).
Expect(ptr.Deref(deletedSubnet.SubnetId, "")).
NotTo(
Equal(pointer.StringDeref(existingSubnet.SubnetId, "")),
Equal(ptr.Deref(existingSubnet.SubnetId, "")),
fmt.Sprintf(
"expected subnet %s/%s/%s to be deleted, but it still exists",
pointer.StringDeref(deletedSubnet.SubnetId, ""),
pointer.StringDeref(deletedSubnet.AvailabilityZone, ""),
pointer.StringDeref(deletedSubnet.CidrBlock, ""),
ptr.Deref(deletedSubnet.SubnetId, ""),
ptr.Deref(deletedSubnet.AvailabilityZone, ""),
ptr.Deref(deletedSubnet.CidrBlock, ""),
),
)
}
Expand All @@ -254,10 +254,8 @@ var _ = Describe("Feature: KCP IpRange", func() {

By("And Then KCP IpRange Cidr block does not exist", func() {
for _, cidrBlock := range theVpc.CidrBlockAssociationSet {
Expect(pointer.StringDeref(cidrBlock.CidrBlock, "")).
NotTo(Equal(iprangeCidr),
fmt.Sprintf("expected VPC Cidr block not to exist, but it still exists"),
)
Expect(ptr.Deref(cidrBlock.CidrBlock, "")).
NotTo(Equal(iprangeCidr), "expected VPC Cidr block not to exist, but it still exists")
}
})

Expand Down Expand Up @@ -357,9 +355,9 @@ var _ = Describe("Feature: KCP IpRange", func() {
for _, iprangeSubnet := range iprange.Status.Subnets {
found := false
for _, awsSubnet := range subnets {
if iprangeSubnet.Id == pointer.StringDeref(awsSubnet.SubnetId, "") {
Expect(pointer.StringDeref(awsSubnet.AvailabilityZone, "")).To(Equal(iprangeSubnet.Zone))
Expect(pointer.StringDeref(awsSubnet.CidrBlock, "")).To(Equal(iprangeSubnet.Range))
if iprangeSubnet.Id == ptr.Deref(awsSubnet.SubnetId, "") {
Expect(ptr.Deref(awsSubnet.AvailabilityZone, "")).To(Equal(iprangeSubnet.Zone))
Expect(ptr.Deref(awsSubnet.CidrBlock, "")).To(Equal(iprangeSubnet.Range))
found = true
break
}
Expand All @@ -372,7 +370,7 @@ var _ = Describe("Feature: KCP IpRange", func() {
found := false
var allBlocks []string
for _, cidrBlock := range theVpc.CidrBlockAssociationSet {
cidr := pointer.StringDeref(cidrBlock.CidrBlock, "")
cidr := ptr.Deref(cidrBlock.CidrBlock, "")
allBlocks = append(allBlocks, cidr)
if cidr == iprange.Status.Cidr {
found = true
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/cloud-control/nfsinstance_aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cloudcontrol

import (
"fmt"
"k8s.io/utils/ptr"
"time"

efsTypes "github.com/aws/aws-sdk-go-v2/service/efs/types"
Expand All @@ -14,7 +15,6 @@ import (
. "github.com/kyma-project/cloud-manager/pkg/testinfra/dsl"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/utils/pointer"
)

var _ = Describe("Feature: KCP NfsInstance", func() {
Expand Down Expand Up @@ -111,11 +111,11 @@ var _ = Describe("Feature: KCP NfsInstance", func() {
})

By("And Then EFS has mount targets", func() {
list, err := infra.AwsMock().DescribeMountTargets(infra.Ctx(), pointer.StringDeref(theEfs.FileSystemId, ""))
list, err := infra.AwsMock().DescribeMountTargets(infra.Ctx(), ptr.Deref(theEfs.FileSystemId, ""))
Expect(err).NotTo(HaveOccurred(), "failed listing EFS mount targets")
Expect(list).To(HaveLen(3), "expected 3 EFS mount targets to exist")
subnetList := pie.Sort(pie.Map(list, func(x efsTypes.MountTargetDescription) string {
return pointer.StringDeref(x.SubnetId, "")
return ptr.Deref(x.SubnetId, "")
}))
for _, subnet := range iprange.Status.Subnets {
Expect(subnetList).Should(ContainElement(subnet.Id), fmt.Sprintf("expected mount target in %s subnet with id %s, but its missing", subnet.Zone, subnet.Id))
Expand All @@ -131,7 +131,7 @@ var _ = Describe("Feature: KCP NfsInstance", func() {
})

By("And When AWS EFS state is deleted", func() {
infra.AwsMock().SetFileSystemLifeCycleState(pointer.StringDeref(theEfs.FileSystemId, ""), efsTypes.LifeCycleStateDeleted)
infra.AwsMock().SetFileSystemLifeCycleState(ptr.Deref(theEfs.FileSystemId, ""), efsTypes.LifeCycleStateDeleted)
})

By("Then NfsInstance does not exist", func() {
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/cloud-control/vpcpeering_aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
. "github.com/kyma-project/cloud-manager/pkg/testinfra/dsl"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"time"
)

Expand Down Expand Up @@ -102,7 +102,7 @@ var _ = Describe("Feature: KCP VpcPeering", func() {

var connection ec2Types.VpcPeeringConnection
for _, p := range list {
if obj.Status.Id == pointer.StringDeref(p.VpcPeeringConnectionId, "") {
if obj.Status.Id == ptr.Deref(p.VpcPeeringConnectionId, "") {
connection = p
}
}
Expand All @@ -112,7 +112,7 @@ var _ = Describe("Feature: KCP VpcPeering", func() {
})

By("And Then KCP VpcPeering has status.Id equal to existing AWS Connection id", func() {
Expect(obj.Status.Id).To(Equal(pointer.StringDeref(connection.VpcPeeringConnectionId, "xxx")))
Expect(obj.Status.Id).To(Equal(ptr.Deref(connection.VpcPeeringConnectionId, "xxx")))
})

// DELETE
Expand All @@ -133,7 +133,7 @@ var _ = Describe("Feature: KCP VpcPeering", func() {
list, _ = infra.AwsMock().DescribeVpcPeeringConnections(infra.Ctx())

found := pie.Any(list, func(x ec2Types.VpcPeeringConnection) bool {
return pointer.StringDeref(x.VpcPeeringConnectionId, "xxx") == obj.Status.Id
return ptr.Deref(x.VpcPeeringConnectionId, "xxx") == obj.Status.Id
})

Expect(found).To(Equal(false))
Expand Down
12 changes: 6 additions & 6 deletions internal/controller/cloud-control/vpcpeering_azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
. "github.com/kyma-project/cloud-manager/pkg/testinfra/dsl"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"time"
)

Expand Down Expand Up @@ -42,7 +42,7 @@ var _ = Describe("Feature: KCP VpcPeering", func() {
subscriptionId := scope.Spec.Scope.Azure.SubscriptionId
resourceGroupName := virtualNetworkName //TODO resource group name is the same as VPC name

infra.AzureMock().AddNetwork(remoteSubscription, remoteResourceGroup, remoteVnetName, map[string]*string{"shoot-name": pointer.String(kymaName)})
infra.AzureMock().AddNetwork(remoteSubscription, remoteResourceGroup, remoteVnetName, map[string]*string{"shoot-name": ptr.To(kymaName)})

obj := &cloudcontrolv1beta1.VpcPeering{}

Expand Down Expand Up @@ -72,7 +72,7 @@ var _ = Describe("Feature: KCP VpcPeering", func() {
peering, _ := c.GetPeering(infra.Ctx(), resourceGroupName, virtualNetworkName, vpcpeeringName)

By("And Then found VirtualNetworkPeering has ID equal to Status.Id", func() {
Expect(pointer.StringDeref(peering.ID, "xxx")).To(Equal(obj.Status.Id))
Expect(ptr.Deref(peering.ID, "xxx")).To(Equal(obj.Status.Id))
})

virtualNetworkPeeringName := fmt.Sprintf("%s-%s",
Expand All @@ -84,17 +84,17 @@ var _ = Describe("Feature: KCP VpcPeering", func() {
remotePeering, _ := r.GetPeering(infra.Ctx(), remoteResourceGroup, remoteVnetName, virtualNetworkPeeringName)

By("And Then found remote VirtualNetworkPeering has ID equal to Status.RemoteId", func() {
Expect(pointer.StringDeref(remotePeering.ID, "xxx")).To(Equal(obj.Status.RemoteId))
Expect(ptr.Deref(remotePeering.ID, "xxx")).To(Equal(obj.Status.RemoteId))
})

By("And Then found VirtualNetworkPeering has RemoteVirtualNetwork.ID equal remote vpc id", func() {
Expect(pointer.StringDeref(peering.Properties.RemoteVirtualNetwork.ID, "xxx")).To(Equal(remoteVnet))
Expect(ptr.Deref(peering.Properties.RemoteVirtualNetwork.ID, "xxx")).To(Equal(remoteVnet))
})

remotePeeringId := util.VirtualNetworkPeeringResourceId(remoteSubscription, remoteResourceGroup, remoteVnetName, virtualNetworkPeeringName)

By("And Then found remote VirtualNetworkPeering has ID equal to remote vpc peering id", func() {
Expect(pointer.StringDeref(remotePeering.ID, "xxx")).To(Equal(remotePeeringId))
Expect(ptr.Deref(remotePeering.ID, "xxx")).To(Equal(remotePeeringId))
})

// DELETE
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/cloud-resources/gcpnfsvolume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ var _ = Describe("Feature: SKR GcpNfsVolume", func() {

By("And has the Capacity matching that of the SKR GcpNfsVolume.")
expectedCapacity := int64(updatedCapacityGb) * 1024 * 1024 * 1024
quantity, _ := pv.Spec.Capacity["storage"]
quantity := pv.Spec.Capacity["storage"]
pvQuantity, _ := quantity.AsInt64()
Expect(pvQuantity).To(Equal(expectedCapacity))

Expand Down
6 changes: 0 additions & 6 deletions internal/controller/cloud-resources/iprange_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ import (
"github.com/kyma-project/cloud-manager/pkg/skr/iprange"
skrruntime "github.com/kyma-project/cloud-manager/pkg/skr/runtime"
reconcile2 "github.com/kyma-project/cloud-manager/pkg/skr/runtime/reconcile"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/cluster"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

ctrl "sigs.k8s.io/controller-runtime"
Expand All @@ -42,10 +40,6 @@ func (f *IpRangeReconcilerFactory) New(args reconcile2.ReconcilerArguments) reco
// IpRangeReconciler reconciles a IpRange object
type IpRangeReconciler struct {
reconciler reconcile.Reconciler

kymaRef klog.ObjectRef
kcpCluster cluster.Cluster
skrCluster cluster.Cluster
}

//+kubebuilder:rbac:groups=cloud-resources.kyma-project.io,resources=ipranges,verbs=get;list;watch;create;update;patch;delete
Expand Down
12 changes: 6 additions & 6 deletions pkg/kcp/provider/aws/iprange/v1/createSubnets.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/kyma-project/cloud-manager/pkg/composed"
awsmeta "github.com/kyma-project/cloud-manager/pkg/kcp/provider/aws/meta"
awsutil "github.com/kyma-project/cloud-manager/pkg/kcp/provider/aws/util"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

func createSubnets(ctx context.Context, st composed.State) (error, context.Context) {
Expand All @@ -33,8 +33,8 @@ func createSubnets(ctx context.Context, st composed.State) (error, context.Conte

for _, subnet := range state.cloudResourceSubnets {
subnetName := awsutil.GetEc2TagValue(subnet.Tags, "Name")
zoneValue := pointer.StringDeref(subnet.AvailabilityZone, "")
rangeValue := pointer.StringDeref(subnet.CidrBlock, "")
zoneValue := ptr.Deref(subnet.AvailabilityZone, "")
rangeValue := ptr.Deref(subnet.CidrBlock, "")
key := fmt.Sprintf("%s/%s", zoneValue, rangeValue)
if len(key) <= 3 {
logger.
Expand Down Expand Up @@ -92,9 +92,9 @@ func createSubnets(ctx context.Context, st composed.State) (error, context.Conte
logger.WithValues("subnetId", subnet.SubnetId).Info("Subnet created")

state.ObjAsIpRange().Status.Subnets = append(state.ObjAsIpRange().Status.Subnets, cloudcontrolv1beta1.IpRangeSubnet{
Id: pointer.StringDeref(subnet.SubnetId, ""),
Zone: pointer.StringDeref(subnet.AvailabilityZone, ""),
Range: pointer.StringDeref(subnet.CidrBlock, ""),
Id: ptr.Deref(subnet.SubnetId, ""),
Zone: ptr.Deref(subnet.AvailabilityZone, ""),
Range: ptr.Deref(subnet.CidrBlock, ""),
})
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/kcp/provider/aws/iprange/v1/deleteSubnets.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
ec2Types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
"github.com/kyma-project/cloud-manager/pkg/composed"
awsmeta "github.com/kyma-project/cloud-manager/pkg/kcp/provider/aws/meta"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

func deleteSubnets(ctx context.Context, st composed.State) (error, context.Context) {
Expand All @@ -21,7 +21,7 @@ func deleteSubnets(ctx context.Context, st composed.State) (error, context.Conte
continue
}

subnetId := pointer.StringDeref(subnet.SubnetId, "")
subnetId := ptr.Deref(subnet.SubnetId, "")

lll := logger.WithValues("subnetId", subnetId)
lll.Info("Deleting subnet")
Expand Down
Loading
Loading