Skip to content

Commit

Permalink
refactor: move state from suffix to prefix in state name const
Browse files Browse the repository at this point in the history
  • Loading branch information
dushanpantic committed Dec 12, 2024
1 parent df75b80 commit 383c8d2
Show file tree
Hide file tree
Showing 101 changed files with 259 additions and 182 deletions.
4 changes: 2 additions & 2 deletions api/cloud-control/v1beta1/redisinstance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,11 @@ func (in *RedisInstance) CloneForPatchStatus() client.Object {
}

func (in *RedisInstance) SetStatusStateToReady() {
in.Status.State = ReadyState
in.Status.State = StateReady
}

func (in *RedisInstance) SetStatusStateToError() {
in.Status.State = ErrorState
in.Status.State = StateError
}

//+kubebuilder:object:root=true
Expand Down
10 changes: 5 additions & 5 deletions api/cloud-control/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package v1beta1
type StatusState string

const (
ReadyState StatusState = "Ready"
ErrorState StatusState = "Error"
ProcessingState StatusState = "Processing"
WarningState StatusState = "Warning"
DeletingState StatusState = "Deleting"
StateReady StatusState = "Ready"
StateError StatusState = "Error"
StateProcessing StatusState = "Processing"
StateWarning StatusState = "Warning"
StateDeleting StatusState = "Deleting"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions internal/controller/cloud-control/iprange_azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cloudcontrol

import (
"fmt"

"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v5"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns"
cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
Expand Down Expand Up @@ -140,7 +141,7 @@ var _ = Describe("Feature: KCP IpRange for Azure", func() {
})

By("When KCP CM Network has Ready condition", func() {
kcpNetworkCm.Status.State = string(cloudcontrolv1beta1.ReadyState)
kcpNetworkCm.Status.State = string(cloudcontrolv1beta1.StateReady)
meta.SetStatusCondition(&kcpNetworkCm.Status.Conditions, metav1.Condition{
Type: cloudcontrolv1beta1.ConditionTypeReady,
Status: metav1.ConditionTrue,
Expand Down Expand Up @@ -181,7 +182,7 @@ var _ = Describe("Feature: KCP IpRange for Azure", func() {
})

By("When KCP VpcPeering has Ready condition", func() {
kcpVpcPeering.Status.State = string(cloudcontrolv1beta1.ReadyState)
kcpVpcPeering.Status.State = string(cloudcontrolv1beta1.StateReady)
meta.SetStatusCondition(&kcpVpcPeering.Status.Conditions, metav1.Condition{
Type: cloudcontrolv1beta1.ConditionTypeReady,
Status: metav1.ConditionTrue,
Expand Down
5 changes: 3 additions & 2 deletions internal/controller/cloud-control/iprange_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cloudcontrol

import (
"fmt"

ec2Types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
"github.com/elliotchance/pie/v2"
cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
Expand Down Expand Up @@ -118,7 +119,7 @@ var _ = Describe("Feature: KCP IpRange deletion with dependant objects", func()
Eventually(LoadAndCheck).
WithArguments(infra.Ctx(), infra.KCP().Client(), iprange,
NewObjActions(),
HavingState(string(cloudcontrolv1beta1.WarningState)),
HavingState(string(cloudcontrolv1beta1.StateWarning)),
).
Should(Succeed())
})
Expand Down Expand Up @@ -263,7 +264,7 @@ var _ = Describe("Feature: KCP IpRange deletion with dependant objects", func()
Eventually(LoadAndCheck).
WithArguments(infra.Ctx(), infra.KCP().Client(), iprange,
NewObjActions(),
HavingState(string(cloudcontrolv1beta1.WarningState)),
HavingState(string(cloudcontrolv1beta1.StateWarning)),
).
Should(Succeed())
})
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/cloud-control/network_azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var _ = Describe("Feature: KCP Azure managed Network", func() {

By("Then KCP Network state is Ready", func() {
Eventually(LoadAndCheck).
WithArguments(infra.Ctx(), infra.KCP().Client(), net, NewObjActions(), HavingState(string(cloudcontrolv1beta1.ReadyState))).
WithArguments(infra.Ctx(), infra.KCP().Client(), net, NewObjActions(), HavingState(string(cloudcontrolv1beta1.StateReady))).
Should(Succeed())
})

Expand Down
21 changes: 11 additions & 10 deletions internal/controller/cloud-control/network_reference_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cloudcontrol

import (
"time"

cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
"github.com/kyma-project/cloud-manager/pkg/common"
kcpiprange "github.com/kyma-project/cloud-manager/pkg/kcp/iprange"
Expand All @@ -12,7 +14,6 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"time"
)

var _ = Describe("Feature: KCP Network reference", func() {
Expand Down Expand Up @@ -43,7 +44,7 @@ var _ = Describe("Feature: KCP Network reference", func() {

By("Then Network state is Ready", func() {
Eventually(LoadAndCheck).
WithArguments(infra.Ctx(), infra.KCP().Client(), net, NewObjActions(), HavingState(string(cloudcontrolv1beta1.ReadyState))).
WithArguments(infra.Ctx(), infra.KCP().Client(), net, NewObjActions(), HavingState(string(cloudcontrolv1beta1.StateReady))).
Should(Succeed())
})

Expand Down Expand Up @@ -103,7 +104,7 @@ var _ = Describe("Feature: KCP Network reference", func() {

By("And Given Network state is Ready", func() {
Eventually(LoadAndCheck).
WithArguments(infra.Ctx(), infra.KCP().Client(), net, NewObjActions(), HavingState(string(cloudcontrolv1beta1.ReadyState))).
WithArguments(infra.Ctx(), infra.KCP().Client(), net, NewObjActions(), HavingState(string(cloudcontrolv1beta1.StateReady))).
Should(Succeed())
})

Expand Down Expand Up @@ -131,7 +132,7 @@ var _ = Describe("Feature: KCP Network reference", func() {
Eventually(LoadAndCheck).
WithArguments(infra.Ctx(), infra.KCP().Client(), net,
NewObjActions(),
HavingState(string(cloudcontrolv1beta1.WarningState)),
HavingState(string(cloudcontrolv1beta1.StateWarning)),
).
Should(Succeed())
})
Expand Down Expand Up @@ -189,7 +190,7 @@ var _ = Describe("Feature: KCP Network reference", func() {

By("And Given local Network state is Ready", func() {
Eventually(LoadAndCheck).
WithArguments(infra.Ctx(), infra.KCP().Client(), localNet, NewObjActions(), HavingState(string(cloudcontrolv1beta1.ReadyState))).
WithArguments(infra.Ctx(), infra.KCP().Client(), localNet, NewObjActions(), HavingState(string(cloudcontrolv1beta1.StateReady))).
Should(Succeed())
})

Expand All @@ -201,7 +202,7 @@ var _ = Describe("Feature: KCP Network reference", func() {

By("And Given remote Network state is Ready", func() {
Eventually(LoadAndCheck).
WithArguments(infra.Ctx(), infra.KCP().Client(), remoteNet, NewObjActions(), HavingState(string(cloudcontrolv1beta1.ReadyState))).
WithArguments(infra.Ctx(), infra.KCP().Client(), remoteNet, NewObjActions(), HavingState(string(cloudcontrolv1beta1.StateReady))).
Should(Succeed())
})

Expand Down Expand Up @@ -230,7 +231,7 @@ var _ = Describe("Feature: KCP Network reference", func() {
Eventually(LoadAndCheck).
WithArguments(infra.Ctx(), infra.KCP().Client(), localNet,
NewObjActions(),
HavingState(string(cloudcontrolv1beta1.WarningState)),
HavingState(string(cloudcontrolv1beta1.StateWarning)),
).
Should(Succeed())
})
Expand Down Expand Up @@ -296,7 +297,7 @@ var _ = Describe("Feature: KCP Network reference", func() {

By("And Given local Network state is Ready", func() {
Eventually(LoadAndCheck).
WithArguments(infra.Ctx(), infra.KCP().Client(), localNet, NewObjActions(), HavingState(string(cloudcontrolv1beta1.ReadyState))).
WithArguments(infra.Ctx(), infra.KCP().Client(), localNet, NewObjActions(), HavingState(string(cloudcontrolv1beta1.StateReady))).
Should(Succeed())
})

Expand All @@ -308,7 +309,7 @@ var _ = Describe("Feature: KCP Network reference", func() {

By("And Given remote Network state is Ready", func() {
Eventually(LoadAndCheck).
WithArguments(infra.Ctx(), infra.KCP().Client(), remoteNet, NewObjActions(), HavingState(string(cloudcontrolv1beta1.ReadyState))).
WithArguments(infra.Ctx(), infra.KCP().Client(), remoteNet, NewObjActions(), HavingState(string(cloudcontrolv1beta1.StateReady))).
Should(Succeed())
})

Expand Down Expand Up @@ -337,7 +338,7 @@ var _ = Describe("Feature: KCP Network reference", func() {
Eventually(LoadAndCheck).
WithArguments(infra.Ctx(), infra.KCP().Client(), remoteNet,
NewObjActions(),
HavingState(string(cloudcontrolv1beta1.WarningState)),
HavingState(string(cloudcontrolv1beta1.StateWarning)),
).
Should(Succeed())
})
Expand Down
11 changes: 6 additions & 5 deletions internal/controller/cloud-control/nfsinstance_gcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package cloudcontrol

import (
"context"
"github.com/kyma-project/cloud-manager/pkg/composed"
"time"

"github.com/kyma-project/cloud-manager/pkg/composed"

cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
iprangePkg "github.com/kyma-project/cloud-manager/pkg/kcp/iprange"
client2 "github.com/kyma-project/cloud-manager/pkg/kcp/provider/gcp/client"
Expand Down Expand Up @@ -105,7 +106,7 @@ var _ = Describe("Feature: KCP NFSVolume for GCP", func() {
Should(BeTrue(), "expected NfsInstance for GCP with Ready condition")
})
By("And KCP NfsVolume has Ready state", func() {
Expect(gcpNfsInstance.Status.State).To(Equal(cloudcontrolv1beta1.ReadyState))
Expect(gcpNfsInstance.Status.State).To(Equal(cloudcontrolv1beta1.StateReady))
})
})

Expand Down Expand Up @@ -139,7 +140,7 @@ var _ = Describe("Feature: KCP NFSVolume for GCP", func() {
if err != nil {
return false, err
}
exists = gcpNfsInstance.Status.State == cloudcontrolv1beta1.ReadyState
exists = gcpNfsInstance.Status.State == cloudcontrolv1beta1.StateReady
return exists, nil
}, timeout, interval)
})
Expand Down Expand Up @@ -533,7 +534,7 @@ var _ = Describe("Feature: KCP NFSVolume for GCP", func() {
Should(BeTrue(), "expected NfsInstance for GCP with Ready condition")
})
By("And KCP NfsVolume has Ready state", func() {
Expect(gcpNfsInstance.Status.State).To(Equal(cloudcontrolv1beta1.ReadyState))
Expect(gcpNfsInstance.Status.State).To(Equal(cloudcontrolv1beta1.StateReady))
})
})

Expand Down Expand Up @@ -567,7 +568,7 @@ var _ = Describe("Feature: KCP NFSVolume for GCP", func() {
if err != nil {
return false, err
}
exists = gcpNfsInstance.Status.State == cloudcontrolv1beta1.ReadyState
exists = gcpNfsInstance.Status.State == cloudcontrolv1beta1.StateReady
return exists, nil
}, timeout, interval)
})
Expand Down
5 changes: 3 additions & 2 deletions internal/controller/cloud-control/redisinstance_azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package cloudcontrol

import (
"fmt"
"time"

"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redis/armredis"
azurecommon "github.com/kyma-project/cloud-manager/pkg/kcp/provider/azure/common"
azuremeta "github.com/kyma-project/cloud-manager/pkg/kcp/provider/azure/meta"
"k8s.io/utils/ptr"
"time"

cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
iprangePkg "github.com/kyma-project/cloud-manager/pkg/kcp/iprange"
Expand Down Expand Up @@ -124,7 +125,7 @@ var _ = Describe("Feature: KCP RedisInstance", func() {
})

By("And Then KCP RedisInstance has status state Ready", func() {
Expect(redisInstance.Status.State).To(Equal(cloudcontrolv1beta1.ReadyState))
Expect(redisInstance.Status.State).To(Equal(cloudcontrolv1beta1.StateReady))
})

By("And Then KCP RedisInstance has .status.primaryEndpoint set", func() {
Expand Down
5 changes: 3 additions & 2 deletions internal/controller/cloud-control/vpcpeering_aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cloudcontrol
import (
"errors"
"fmt"

ec2Types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
"github.com/kyma-project/cloud-manager/pkg/common"
Expand Down Expand Up @@ -463,7 +464,7 @@ var _ = Describe("Feature: KCP VpcPeering", func() {
To(Succeed())

localKcpNet.Status.Network = localKcpNet.Spec.Network.Reference.DeepCopy()
localKcpNet.Status.State = string(cloudcontrolv1beta1.ReadyState)
localKcpNet.Status.State = string(cloudcontrolv1beta1.StateReady)
meta.SetStatusCondition(&localKcpNet.Status.Conditions, metav1.Condition{
Type: cloudcontrolv1beta1.ConditionTypeReady,
Status: metav1.ConditionTrue,
Expand All @@ -487,7 +488,7 @@ var _ = Describe("Feature: KCP VpcPeering", func() {
Should(Succeed())

remoteKcpNet.Status.Network = remoteKcpNet.Spec.Network.Reference.DeepCopy()
remoteKcpNet.Status.State = string(cloudcontrolv1beta1.ReadyState)
remoteKcpNet.Status.State = string(cloudcontrolv1beta1.StateReady)
meta.SetStatusCondition(&remoteKcpNet.Status.Conditions, metav1.Condition{
Type: cloudcontrolv1beta1.ConditionTypeReady,
Status: metav1.ConditionTrue,
Expand Down
5 changes: 3 additions & 2 deletions internal/controller/cloud-control/vpcpeering_azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cloudcontrol

import (
"errors"

"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v5"
cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
"github.com/kyma-project/cloud-manager/pkg/common"
Expand Down Expand Up @@ -356,7 +357,7 @@ var _ = Describe("Feature: KCP VpcPeering", func() {
Should(Succeed())

localKcpNet.Status.Network = localKcpNet.Spec.Network.Reference.DeepCopy()
localKcpNet.Status.State = string(cloudcontrolv1beta1.ReadyState)
localKcpNet.Status.State = string(cloudcontrolv1beta1.StateReady)
meta.SetStatusCondition(&localKcpNet.Status.Conditions, metav1.Condition{
Type: cloudcontrolv1beta1.ConditionTypeReady,
Status: metav1.ConditionTrue,
Expand All @@ -380,7 +381,7 @@ var _ = Describe("Feature: KCP VpcPeering", func() {
Should(Succeed())

remoteKcpNet.Status.Network = remoteKcpNet.Spec.Network.Reference.DeepCopy()
remoteKcpNet.Status.State = string(cloudcontrolv1beta1.ReadyState)
remoteKcpNet.Status.State = string(cloudcontrolv1beta1.StateReady)
meta.SetStatusCondition(&remoteKcpNet.Status.Conditions, metav1.Condition{
Type: cloudcontrolv1beta1.ConditionTypeReady,
Status: metav1.ConditionTrue,
Expand Down
19 changes: 10 additions & 9 deletions internal/controller/cloud-resources/gcpnfsvolume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package cloudresources
import (
"context"
"fmt"
"github.com/kyma-project/cloud-manager/pkg/feature"
"time"

"github.com/kyma-project/cloud-manager/pkg/feature"

cloudcontrolv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-control/v1beta1"
cloudresourcesv1beta1 "github.com/kyma-project/cloud-manager/api/cloud-resources/v1beta1"
kcpiprange "github.com/kyma-project/cloud-manager/pkg/kcp/iprange"
Expand Down Expand Up @@ -195,7 +196,7 @@ var _ = Describe("Feature: SKR GcpNfsVolume", func() {
WithArguments(
infra.Ctx(), infra.KCP().Client(), kcpNfsInstance,
WithConditions(KcpReadyCondition()),
WithKcpNfsStatusState(cloudcontrolv1beta1.ReadyState),
WithKcpNfsStatusState(cloudcontrolv1beta1.StateReady),
WithKcpNfsStatusHost(nfsIpAddress),
WithKcpNfsStatusCapacity(gcpNfsVolume.Spec.CapacityGb),
).
Expand Down Expand Up @@ -382,7 +383,7 @@ var _ = Describe("Feature: SKR GcpNfsVolume", func() {
WithArguments(
infra.Ctx(), infra.KCP().Client(), kcpNfsInstance,
WithConditions(KcpReadyCondition()),
WithKcpNfsStatusState(cloudcontrolv1beta1.ReadyState),
WithKcpNfsStatusState(cloudcontrolv1beta1.StateReady),
WithKcpNfsStatusHost(nfsIpAddress),
WithKcpNfsStatusCapacity(gcpNfsVolume.Spec.CapacityGb),
).
Expand Down Expand Up @@ -464,7 +465,7 @@ var _ = Describe("Feature: SKR GcpNfsVolume", func() {
WithArguments(
infra.Ctx(), infra.KCP().Client(), kcpNfsInstance,
WithConditions(KcpReadyCondition()),
WithKcpNfsStatusState(cloudcontrolv1beta1.ReadyState),
WithKcpNfsStatusState(cloudcontrolv1beta1.StateReady),
WithKcpNfsStatusHost(nfsIpAddress),
WithKcpNfsStatusCapacity(updatedCapacityGb),
).
Expand Down Expand Up @@ -598,7 +599,7 @@ var _ = Describe("Feature: SKR GcpNfsVolume", func() {
WithArguments(
infra.Ctx(), infra.KCP().Client(), kcpNfsInstance,
WithConditions(KcpReadyCondition()),
WithKcpNfsStatusState(cloudcontrolv1beta1.ReadyState),
WithKcpNfsStatusState(cloudcontrolv1beta1.StateReady),
WithKcpNfsStatusHost(nfsIpAddress),
WithKcpNfsStatusCapacity(gcpNfsVolume.Spec.CapacityGb),
).
Expand Down Expand Up @@ -795,7 +796,7 @@ var _ = Describe("Feature: SKR GcpNfsVolume", func() {
WithArguments(
infra.Ctx(), infra.KCP().Client(), kcpNfsInstance,
WithConditions(KcpReadyCondition()),
WithKcpNfsStatusState(cloudcontrolv1beta1.ReadyState),
WithKcpNfsStatusState(cloudcontrolv1beta1.StateReady),
WithKcpNfsStatusHost(nfsIpAddress),
WithKcpNfsStatusCapacity(gcpNfsVolume.Spec.CapacityGb),
).
Expand Down Expand Up @@ -1001,7 +1002,7 @@ var _ = Describe("Feature: SKR GcpNfsVolume", func() {
WithArguments(
infra.Ctx(), infra.KCP().Client(), kcpNfsInstance,
WithConditions(KcpReadyCondition()),
WithKcpNfsStatusState(cloudcontrolv1beta1.ReadyState),
WithKcpNfsStatusState(cloudcontrolv1beta1.StateReady),
WithKcpNfsStatusHost(nfsIpAddress),
WithKcpNfsStatusCapacity(gcpNfsVolume.Spec.CapacityGb),
).
Expand Down Expand Up @@ -1082,7 +1083,7 @@ var _ = Describe("Feature: SKR GcpNfsVolume", func() {
WithArguments(
infra.Ctx(), infra.KCP().Client(), kcpNfsInstance,
WithConditions(KcpReadyCondition()),
WithKcpNfsStatusState(cloudcontrolv1beta1.ReadyState),
WithKcpNfsStatusState(cloudcontrolv1beta1.StateReady),
WithKcpNfsStatusHost(nfsIpAddress),
WithKcpNfsStatusCapacity(updatedCapacityGb),
).
Expand Down Expand Up @@ -1236,7 +1237,7 @@ var _ = Describe("Feature: SKR GcpNfsVolume", func() {
WithArguments(
infra.Ctx(), infra.KCP().Client(), kcpNfsInstance,
WithConditions(KcpReadyCondition()),
WithKcpNfsStatusState(cloudcontrolv1beta1.ReadyState),
WithKcpNfsStatusState(cloudcontrolv1beta1.StateReady),
WithKcpNfsStatusHost(nfsIpAddress),
WithKcpNfsStatusCapacity(gcpNfsVolume.Spec.CapacityGb),
).
Expand Down
Loading

0 comments on commit 383c8d2

Please sign in to comment.