Skip to content

Commit

Permalink
Merge pull request #3303 from /issues/3237-use-ready-condition-builder
Browse files Browse the repository at this point in the history
Use the ready condition builder in relevant controllers
  • Loading branch information
tcdowney authored May 29, 2024
2 parents de464f7 + 1613cdc commit 7a499b7
Show file tree
Hide file tree
Showing 26 changed files with 450 additions and 559 deletions.
18 changes: 9 additions & 9 deletions api/repositories/buildpack_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"k8s.io/apimachinery/pkg/api/meta"

. "code.cloudfoundry.org/korifi/api/repositories"
"code.cloudfoundry.org/korifi/controllers/api/v1alpha1"
korifiv1alpha1 "code.cloudfoundry.org/korifi/controllers/api/v1alpha1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -83,7 +83,7 @@ var _ = Describe("BuildpackRepository", func() {
})

When("the BuilderInfo resource with the configured BuilderName is not ready", func() {
var builderInfo *v1alpha1.BuilderInfo
var builderInfo *korifiv1alpha1.BuilderInfo

BeforeEach(func() {
builderInfo = createBuilderInfoWithCleanup(ctx, builderName, "io.buildpacks.stacks.bionic", []buildpackInfo{
Expand All @@ -96,7 +96,7 @@ var _ = Describe("BuildpackRepository", func() {
When("there is a ready condition with a message", func() {
BeforeEach(func() {
meta.SetStatusCondition(&builderInfo.Status.Conditions, metav1.Condition{
Type: "Ready",
Type: korifiv1alpha1.StatusConditionReady,
Status: metav1.ConditionFalse,
Reason: "testing",
Message: "this is a test",
Expand All @@ -113,7 +113,7 @@ var _ = Describe("BuildpackRepository", func() {
When("there is a ready condition with an empty message", func() {
BeforeEach(func() {
meta.SetStatusCondition(&builderInfo.Status.Conditions, metav1.Condition{
Type: "Ready",
Type: korifiv1alpha1.StatusConditionReady,
Status: metav1.ConditionFalse,
Reason: "testing",
Message: "",
Expand All @@ -135,8 +135,8 @@ type buildpackInfo struct {
version string
}

func createBuilderInfoWithCleanup(ctx context.Context, name, stack string, buildpacks []buildpackInfo) *v1alpha1.BuilderInfo {
builderInfo := &v1alpha1.BuilderInfo{
func createBuilderInfoWithCleanup(ctx context.Context, name, stack string, buildpacks []buildpackInfo) *korifiv1alpha1.BuilderInfo {
builderInfo := &korifiv1alpha1.BuilderInfo{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: rootNamespace,
Expand All @@ -150,15 +150,15 @@ func createBuilderInfoWithCleanup(ctx context.Context, name, stack string, build
creationTimestamp := metav1.Time{Time: time.Now().Add(-24 * time.Hour)}
updatedTimestamp := metav1.Time{Time: time.Now().Add(-30 * time.Second)}

builderInfo.Status.Stacks = []v1alpha1.BuilderInfoStatusStack{
builderInfo.Status.Stacks = []korifiv1alpha1.BuilderInfoStatusStack{
{
Name: stack,
CreationTimestamp: metav1.Time{Time: time.Now()},
UpdatedTimestamp: metav1.Time{Time: time.Now()},
},
}
for _, b := range buildpacks {
builderInfo.Status.Buildpacks = append(builderInfo.Status.Buildpacks, v1alpha1.BuilderInfoStatusBuildpack{
builderInfo.Status.Buildpacks = append(builderInfo.Status.Buildpacks, korifiv1alpha1.BuilderInfoStatusBuildpack{
Name: b.name,
Version: b.version,
Stack: stack,
Expand All @@ -168,7 +168,7 @@ func createBuilderInfoWithCleanup(ctx context.Context, name, stack string, build
}

meta.SetStatusCondition(&builderInfo.Status.Conditions, metav1.Condition{
Type: "Ready",
Type: korifiv1alpha1.StatusConditionReady,
Status: metav1.ConditionTrue,
Reason: "testing",
})
Expand Down
6 changes: 3 additions & 3 deletions api/repositories/org_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var _ = Describe("OrgRepository", func() {
Expect(k8s.Patch(ctx, k8sClient, cfOrg, func() {
cfOrg.Status.GUID = cfOrg.Name
meta.SetStatusCondition(&cfOrg.Status.Conditions, metav1.Condition{
Type: "Ready",
Type: korifiv1alpha1.StatusConditionReady,
Status: conditionStatus,
Reason: "blah",
Message: conditionMessage,
Expand Down Expand Up @@ -199,15 +199,15 @@ var _ = Describe("OrgRepository", func() {
When("the org is not ready", func() {
BeforeEach(func() {
meta.SetStatusCondition(&(cfOrg1.Status.Conditions), metav1.Condition{
Type: "Ready",
Type: korifiv1alpha1.StatusConditionReady,
Status: metav1.ConditionFalse,
Reason: "because",
Message: "because",
})
Expect(k8sClient.Status().Update(ctx, cfOrg1)).To(Succeed())

meta.SetStatusCondition(&(cfOrg2.Status.Conditions), metav1.Condition{
Type: "Ready",
Type: korifiv1alpha1.StatusConditionReady,
Status: metav1.ConditionUnknown,
Reason: "because",
Message: "because",
Expand Down
8 changes: 4 additions & 4 deletions api/repositories/package_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ var _ = Describe("PackageRepository", func() {
BeforeEach(func() {
Expect(k8s.Patch(ctx, k8sClient, cfPackage, func() {
meta.SetStatusCondition(&cfPackage.Status.Conditions, metav1.Condition{
Type: "Ready",
Status: "True",
Type: korifiv1alpha1.StatusConditionReady,
Status: metav1.ConditionTrue,
Reason: "Ready",
ObservedGeneration: cfPackage.Generation,
})
Expand Down Expand Up @@ -507,8 +507,8 @@ var _ = Describe("PackageRepository", func() {
Expect(k8sClient.Create(ctx, cfPackage)).To(Succeed())
Expect(k8s.Patch(ctx, k8sClient, cfPackage, func() {
meta.SetStatusCondition(&cfPackage.Status.Conditions, metav1.Condition{
Type: "Ready",
Status: "True",
Type: korifiv1alpha1.StatusConditionReady,
Status: metav1.ConditionTrue,
Reason: "Ready",
ObservedGeneration: cfPackage.Generation,
})
Expand Down
4 changes: 2 additions & 2 deletions api/repositories/repositories_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func createOrgWithCleanup(ctx context.Context, displayName string) *korifiv1alph
Expect(k8sClient.Create(ctx, cfOrg)).To(Succeed())

meta.SetStatusCondition(&(cfOrg.Status.Conditions), metav1.Condition{
Type: "Ready",
Type: korifiv1alpha1.StatusConditionReady,
Status: metav1.ConditionTrue,
Reason: "cus",
Message: "cus",
Expand Down Expand Up @@ -191,7 +191,7 @@ func createSpaceWithCleanup(ctx context.Context, orgGUID, name string) *korifiv1

cfSpace.Status.GUID = cfSpace.Name
meta.SetStatusCondition(&(cfSpace.Status.Conditions), metav1.Condition{
Type: "Ready",
Type: korifiv1alpha1.StatusConditionReady,
Status: metav1.ConditionTrue,
Reason: "cus",
Message: "cus",
Expand Down
4 changes: 2 additions & 2 deletions api/repositories/space_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var _ = Describe("SpaceRepository", func() {
Expect(k8s.Patch(ctx, k8sClient, cfSpace, func() {
cfSpace.Status.GUID = cfSpace.Name
meta.SetStatusCondition(&cfSpace.Status.Conditions, metav1.Condition{
Type: "Ready",
Type: korifiv1alpha1.StatusConditionReady,
Status: conditionStatus,
Reason: "blah",
Message: conditionMessage,
Expand Down Expand Up @@ -227,7 +227,7 @@ var _ = Describe("SpaceRepository", func() {
When("the space anchor is not ready", func() {
BeforeEach(func() {
meta.SetStatusCondition(&(space11.Status.Conditions), metav1.Condition{
Type: "Ready",
Type: korifiv1alpha1.StatusConditionReady,
Status: metav1.ConditionFalse,
Reason: "cus",
Message: "cus",
Expand Down
Loading

0 comments on commit 7a499b7

Please sign in to comment.