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

Make all status.conditions fields optional and annotated with omitempty #2684

Merged
merged 1 commit into from
Jul 13, 2023
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
1 change: 0 additions & 1 deletion api/repositories/app_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,6 @@ func createAppWithGUID(space, guid string) *korifiv1alpha1.CFApp {
}
Expect(k8sClient.Create(context.Background(), cfApp)).To(Succeed())

cfApp.Status.Conditions = []metav1.Condition{}
Expect(k8sClient.Status().Update(context.Background(), cfApp)).To(Succeed())

return cfApp
Expand Down
4 changes: 0 additions & 4 deletions api/repositories/task_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ var _ = Describe("TaskRepository", func() {
setStatusAndUpdate := func(task *korifiv1alpha1.CFTask, conditionTypes ...string) {
GinkgoHelper()

if task.Status.Conditions == nil {
task.Status.Conditions = []metav1.Condition{}
}

for _, cond := range conditionTypes {
meta.SetStatusCondition(&(task.Status.Conditions), metav1.Condition{
Type: cond,
Expand Down
4 changes: 2 additions & 2 deletions controllers/api/v1alpha1/appworkload_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ type AppWorkloadSpec struct {

// AppWorkloadStatus defines the observed state of AppWorkload
type AppWorkloadStatus struct {
// Conditions capture the current status of the observed generation of the AppWorkload
Conditions []metav1.Condition `json:"conditions"`
//+kubebuilder:validation:Optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// ObservedGeneration captures the latest generation of the AppWorkload that has been reconciled
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Expand Down
3 changes: 2 additions & 1 deletion controllers/api/v1alpha1/builderinfo_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ type BuilderInfoSpec struct{}
type BuilderInfoStatus struct {
Stacks []BuilderInfoStatusStack `json:"stacks"`
Buildpacks []BuilderInfoStatusBuildpack `json:"buildpacks"`
Conditions []metav1.Condition `json:"conditions"`
//+kubebuilder:validation:Optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// ObservedGeneration captures the latest generation of the BuilderInfo that has been reconciled
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Expand Down
5 changes: 2 additions & 3 deletions controllers/api/v1alpha1/buildworkload_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ type BuildWorkloadSpec struct {

// BuildWorkloadStatus defines the observed state of BuildWorkload
type BuildWorkloadStatus struct {
// Conditions capture the current status of the observed generation of the BuildWorkload
// +optional
Conditions []metav1.Condition `json:"conditions"`
//+kubebuilder:validation:Optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

Droplet *BuildDropletStatus `json:"droplet,omitempty"`

Expand Down
4 changes: 2 additions & 2 deletions controllers/api/v1alpha1/cfapp_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ type DesiredState string

// CFAppStatus defines the observed state of CFApp
type CFAppStatus struct {
// Conditions capture the current status of the App
Conditions []metav1.Condition `json:"conditions"`
//+kubebuilder:validation:Optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// Deprecated: No longer used
//+kubebuilder:validation:Optional
Expand Down
4 changes: 2 additions & 2 deletions controllers/api/v1alpha1/cfbuild_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ type CFBuildSpec struct {
// CFBuildStatus defines the observed state of CFBuild
type CFBuildStatus struct {
Droplet *BuildDropletStatus `json:"droplet,omitempty"`
// Conditions capture the current status of the Build
Conditions []metav1.Condition `json:"conditions"`
//+kubebuilder:validation:Optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// ObservedGeneration captures the latest generation of the CFBuild that has been reconciled
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion controllers/api/v1alpha1/cfdomain_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type CFDomainSpec struct {

// CFDomainStatus defines the observed state of CFDomain
type CFDomainStatus struct {
// Conditions capture the current status of the domain
//+kubebuilder:validation:Optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// ObservedGeneration captures the latest generation of the CFDomain that has been reconciled
Expand Down
3 changes: 2 additions & 1 deletion controllers/api/v1alpha1/cforg_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ type CFOrgSpec struct {

// CFOrgStatus defines the observed state of CFOrg
type CFOrgStatus struct {
Conditions []metav1.Condition `json:"conditions"`
//+kubebuilder:validation:Optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

GUID string `json:"guid"`

Expand Down
4 changes: 2 additions & 2 deletions controllers/api/v1alpha1/cfpackage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ type PackageSource struct {

// CFPackageStatus defines the observed state of CFPackage
type CFPackageStatus struct {
// Conditions capture the current status of the Package
Conditions []metav1.Condition `json:"conditions"`
//+kubebuilder:validation:Optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// ObservedGeneration captures the latest generation of the CFPackage that has been reconciled
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions controllers/api/v1alpha1/cfprocess_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ type HealthCheckData struct {

// CFProcessStatus defines the observed state of CFProcess
type CFProcessStatus struct {
// Conditions capture the current status of the Process
Conditions []metav1.Condition `json:"conditions"`
//+kubebuilder:validation:Optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// ObservedGeneration captures the latest generation of the CFProcess that has been reconciled
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion controllers/api/v1alpha1/cfroute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type CFRouteStatus struct {
// The observed state of the destinations. This is mainly used to record the target port of the underlying service
Destinations []Destination `json:"destinations,omitempty"`

// Conditions capture the current status of the route
//+kubebuilder:validation:Optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// ObservedGeneration captures the latest generation of the CFRoute that has been reconciled
Expand Down
4 changes: 2 additions & 2 deletions controllers/api/v1alpha1/cfservicebinding_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ type CFServiceBindingStatus struct {
// +optional
Binding v1.LocalObjectReference `json:"binding"`

// Conditions capture the current status of the CFServiceBinding
Conditions []metav1.Condition `json:"conditions"`
//+kubebuilder:validation:Optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// ObservedGeneration captures the latest generation of the CFServiceBinding that has been reconciled
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions controllers/api/v1alpha1/cfserviceinstance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ type CFServiceInstanceStatus struct {
// +optional
Binding corev1.LocalObjectReference `json:"binding"`

// Conditions capture the current status of the CFServiceInstance
Conditions []metav1.Condition `json:"conditions"`
//+kubebuilder:validation:Optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// ObservedGeneration captures the latest generation of the CFServiceInstance that has been reconciled
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions controllers/api/v1alpha1/cfspace_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ type CFSpaceSpec struct {

// CFSpaceStatus defines the observed state of CFSpace
type CFSpaceStatus struct {
// Conditions capture the current status of the CFSpace
Conditions []metav1.Condition `json:"conditions"`
//+kubebuilder:validation:Optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

GUID string `json:"guid"`

Expand Down
4 changes: 2 additions & 2 deletions controllers/api/v1alpha1/cftask_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ type CFTaskSpec struct {

// CFTaskStatus defines the observed state of CFTask
type CFTaskStatus struct {
// +optional
Conditions []metav1.Condition `json:"conditions"`
//+kubebuilder:validation:Optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// +optional
SequenceID int64 `json:"sequenceId"`
Expand Down
2 changes: 1 addition & 1 deletion controllers/api/v1alpha1/runnerinfo_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type RunnerInfoSpec struct {
// RunnerInfoStatus defines the observed state of RunnerInfo
type RunnerInfoStatus struct {
//+kubebuilder:validation:Optional
Conditions []metav1.Condition `json:"conditions"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

Capabilities RunnerInfoCapabilities `json:"capabilities"`

Expand Down
4 changes: 2 additions & 2 deletions controllers/api/v1alpha1/taskworkload_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ type TaskWorkloadSpec struct {

// TaskWorkloadStatus defines the observed state of TaskWorkload
type TaskWorkloadStatus struct {
// +optional
Conditions []metav1.Condition `json:"conditions"`
//+kubebuilder:validation:Optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// ObservedGeneration captures the latest generation of the TaskWorkload that has been reconciled
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
Expand Down
4 changes: 0 additions & 4 deletions controllers/controllers/workloads/cfapp_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ func (r *CFAppReconciler) ReconcileResource(ctx context.Context, cfApp *korifiv1

cfApp.Status.VCAPServicesSecretName = secretName

if cfApp.Status.Conditions == nil {
cfApp.Status.Conditions = make([]metav1.Condition, 0)
}

if cfApp.Spec.CurrentDropletRef.Name == "" {
meta.SetStatusCondition(&cfApp.Status.Conditions, metav1.Condition{
Type: shared.StatusConditionReady,
Expand Down
1 change: 0 additions & 1 deletion controllers/controllers/workloads/cfapp_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ var _ = Describe("CFAppReconciler Integration Tests", func() {
}
Expect(adminClient.Create(ctx, serviceBinding)).To(Succeed())
Expect(k8s.Patch(ctx, adminClient, serviceBinding, func() {
serviceBinding.Status.Conditions = []metav1.Condition{}
serviceBinding.Status.Binding = corev1.LocalObjectReference{
Name: serviceInstanceSecret.Name,
}
Expand Down
3 changes: 0 additions & 3 deletions controllers/controllers/workloads/env/env_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ var _ = BeforeEach(func() {
ensureCreate(cfOrg)
orgNSName := testutils.PrefixedGUID("org")
ensurePatch(cfOrg, func(cfOrg *korifiv1alpha1.CFOrg) {
cfOrg.Status.Conditions = []metav1.Condition{}
cfOrg.Status.GUID = orgNSName
})
createNamespace(cfOrg.Status.GUID)
Expand All @@ -116,7 +115,6 @@ var _ = BeforeEach(func() {
ensureCreate(cfSpace)
cfNSName := testutils.PrefixedGUID("space")
ensurePatch(cfSpace, func(cfSpace *korifiv1alpha1.CFSpace) {
cfSpace.Status.Conditions = []metav1.Condition{}
cfSpace.Status.GUID = cfNSName
})
createNamespace(cfSpace.Status.GUID)
Expand All @@ -138,7 +136,6 @@ var _ = BeforeEach(func() {
ensureCreate(cfApp)
ensurePatch(cfApp, func(app *korifiv1alpha1.CFApp) {
app.Status = korifiv1alpha1.CFAppStatus{
Conditions: []metav1.Condition{},
VCAPServicesSecretName: "app-guid-vcap-services",
VCAPApplicationSecretName: "app-guid-vcap-application",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ var _ = Describe("Builder", func() {
ensureCreate(serviceBinding)
ensurePatch(serviceBinding, func(sb *korifiv1alpha1.CFServiceBinding) {
sb.Status = korifiv1alpha1.CFServiceBindingStatus{
Conditions: []metav1.Condition{},
Binding: corev1.LocalObjectReference{
Name: "service-binding-secret",
},
Expand Down Expand Up @@ -118,7 +117,6 @@ var _ = Describe("Builder", func() {
ensureCreate(serviceBinding2)
ensurePatch(serviceBinding2, func(sb *korifiv1alpha1.CFServiceBinding) {
sb.Status = korifiv1alpha1.CFServiceBindingStatus{
Conditions: []metav1.Condition{},
Binding: corev1.LocalObjectReference{
Name: "service-binding-secret-2",
},
Expand Down
1 change: 0 additions & 1 deletion controllers/controllers/workloads/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ func createBuildWithDroplet(ctx context.Context, k8sClient client.Client, cfBuil
k8sClient.Create(ctx, cfBuild),
).To(Succeed())
patchedCFBuild := cfBuild.DeepCopy()
patchedCFBuild.Status.Conditions = []metav1.Condition{}
patchedCFBuild.Status.Droplet = droplet
Expect(
k8sClient.Status().Patch(ctx, patchedCFBuild, client.MergeFrom(cfBuild)),
Expand Down
4 changes: 1 addition & 3 deletions controllers/webhooks/workloads/cftask_defaulter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ var _ = Describe("CFTaskMutatingWebhook", func() {
JustBeforeEach(func() {
Expect(adminClient.Create(context.Background(), cfTask)).To(Succeed())
Expect(k8s.Patch(context.Background(), adminClient, cfTask, func() {
cfTask.Status = korifiv1alpha1.CFTaskStatus{
Conditions: []metav1.Condition{},
}
cfTask.Status = korifiv1alpha1.CFTaskStatus{}
})).To(Succeed())
})

Expand Down
5 changes: 1 addition & 4 deletions controllers/webhooks/workloads/cftask_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ var _ = Describe("CFTask Creation", func() {

originalCfTask := cfTask.DeepCopy()
cfTask.Status = korifiv1alpha1.CFTaskStatus{
Conditions: []metav1.Condition{},
SequenceID: seqId,
}

Expand Down Expand Up @@ -141,9 +140,7 @@ var _ = Describe("CFTask Update", func() {
}
Expect(adminClient.Create(context.Background(), cfTask)).To(Succeed())
Expect(k8s.Patch(context.Background(), adminClient, cfTask, func() {
cfTask.Status = korifiv1alpha1.CFTaskStatus{
Conditions: []metav1.Condition{},
}
cfTask.Status = korifiv1alpha1.CFTaskStatus{}
})).To(Succeed())
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,6 @@ spec:
description: AppWorkloadStatus defines the observed state of AppWorkload
properties:
conditions:
description: Conditions capture the current status of the observed
generation of the AppWorkload
items:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
Expand Down Expand Up @@ -752,8 +750,6 @@ spec:
the AppWorkload that has been reconciled
format: int64
type: integer
required:
- conditions
type: object
type: object
served: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ spec:
type: array
required:
- buildpacks
- conditions
- stacks
type: object
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ spec:
description: BuildWorkloadStatus defines the observed state of BuildWorkload
properties:
conditions:
description: Conditions capture the current status of the observed
generation of the BuildWorkload
items:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ spec:
description: CFAppStatus defines the observed state of CFApp
properties:
conditions:
description: Conditions capture the current status of the App
items:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
Expand Down Expand Up @@ -192,8 +191,6 @@ spec:
description: VCAPServicesSecretName contains the name of the CFApp's
VCAP_SERVICES Secret, which should exist in the same namespace
type: string
required:
- conditions
type: object
type: object
served: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ spec:
description: CFBuildStatus defines the observed state of CFBuild
properties:
conditions:
description: Conditions capture the current status of the Build
items:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
Expand Down Expand Up @@ -243,8 +242,6 @@ spec:
the CFBuild that has been reconciled
format: int64
type: integer
required:
- conditions
type: object
type: object
served: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ spec:
description: CFDomainStatus defines the observed state of CFDomain
properties:
conditions:
description: Conditions capture the current status of the domain
items:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ spec:
format: int64
type: integer
required:
- conditions
- guid
type: object
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ spec:
description: CFPackageStatus defines the observed state of CFPackage
properties:
conditions:
description: Conditions capture the current status of the Package
items:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
Expand Down Expand Up @@ -171,8 +170,6 @@ spec:
the CFPackage that has been reconciled
format: int64
type: integer
required:
- conditions
type: object
type: object
served: true
Expand Down
Loading