Skip to content

Commit 2dc5419

Browse files
authored
Merge pull request #4913 from camilamacedo86/fix-go-deploy-image
🐛 (deploy-image/v1-alpha1) - Revert changes to make status a pointer in favor of use omitzero; keep aligned with latest review changes for go/v4
2 parents cf9a6ee + f4080eb commit 2dc5419

File tree

12 files changed

+14
-55
lines changed

12 files changed

+14
-55
lines changed

pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/api/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ type {{ .Resource.Kind }} struct {
127127
128128
// metadata is a standard object metadata
129129
// +optional
130-
metav1.ObjectMeta ` + "`" + `json:"metadata,omitempty"` + "`" + `
130+
metav1.ObjectMeta ` + "`" + `json:"metadata,omitempty,omitzero"` + "`" + `
131131
132132
// spec defines the desired state of {{ .Resource.Kind }}
133133
// +required
134134
Spec {{ .Resource.Kind }}Spec ` + "`" + `json:"spec"` + "`" + `
135135
136136
// status defines the observed state of {{ .Resource.Kind }}
137137
// +optional
138-
Status *{{ .Resource.Kind }}Status ` + "`" + `json:"status,omitempty"` + "`" + `
138+
Status {{ .Resource.Kind }}Status ` + "`" + `json:"status,omitempty,omitzero"` + "`" + `
139139
}
140140
141141
// +kubebuilder:object:root=true

pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/controllers/controller.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,6 @@ func (r *{{ .Resource.Kind }}Reconciler) Reconcile(ctx context.Context, req ctrl
153153
log.Error(err, "Failed to get {{ lower .Resource.Kind }}")
154154
return ctrl.Result{}, err
155155
}
156-
157-
// Let's just set the status as Unknown when no status is available
158-
if {{ lower .Resource.Kind }}.Status == nil {
159-
{{ lower .Resource.Kind }}.Status = &{{ .Resource.ImportAlias }}.{{ .Resource.Kind }}Status{}
160-
}
161156
162157
if len({{ lower .Resource.Kind }}.Status.Conditions) == 0 {
163158
meta.SetStatusCondition(&{{ lower .Resource.Kind }}.Status.Conditions, metav1.Condition{Type: typeAvailable{{ .Resource.Kind }}, Status: metav1.ConditionUnknown, Reason: "Reconciling", Message: "Starting reconciliation"})

testdata/project-v4-multigroup/api/example.com/v1alpha1/busybox_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ type Busybox struct {
6666

6767
// metadata is a standard object metadata
6868
// +optional
69-
metav1.ObjectMeta `json:"metadata,omitempty"`
69+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
7070

7171
// spec defines the desired state of Busybox
7272
// +required
7373
Spec BusyboxSpec `json:"spec"`
7474

7575
// status defines the observed state of Busybox
7676
// +optional
77-
Status *BusyboxStatus `json:"status,omitempty"`
77+
Status BusyboxStatus `json:"status,omitempty,omitzero"`
7878
}
7979

8080
// +kubebuilder:object:root=true

testdata/project-v4-multigroup/api/example.com/v1alpha1/memcached_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ type Memcached struct {
7070

7171
// metadata is a standard object metadata
7272
// +optional
73-
metav1.ObjectMeta `json:"metadata,omitempty"`
73+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
7474

7575
// spec defines the desired state of Memcached
7676
// +required
7777
Spec MemcachedSpec `json:"spec"`
7878

7979
// status defines the observed state of Memcached
8080
// +optional
81-
Status *MemcachedStatus `json:"status,omitempty"`
81+
Status MemcachedStatus `json:"status,omitempty,omitzero"`
8282
}
8383

8484
// +kubebuilder:object:root=true

testdata/project-v4-multigroup/api/example.com/v1alpha1/zz_generated.deepcopy.go

Lines changed: 2 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testdata/project-v4-multigroup/internal/controller/example.com/busybox_controller.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,6 @@ func (r *BusyboxReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
9999
return ctrl.Result{}, err
100100
}
101101

102-
// Let's just set the status as Unknown when no status is available
103-
if busybox.Status == nil {
104-
busybox.Status = &examplecomv1alpha1.BusyboxStatus{}
105-
}
106-
107102
if len(busybox.Status.Conditions) == 0 {
108103
meta.SetStatusCondition(&busybox.Status.Conditions, metav1.Condition{Type: typeAvailableBusybox, Status: metav1.ConditionUnknown, Reason: "Reconciling", Message: "Starting reconciliation"})
109104
if err = r.Status().Update(ctx, busybox); err != nil {

testdata/project-v4-multigroup/internal/controller/example.com/memcached_controller.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,6 @@ func (r *MemcachedReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
9999
return ctrl.Result{}, err
100100
}
101101

102-
// Let's just set the status as Unknown when no status is available
103-
if memcached.Status == nil {
104-
memcached.Status = &examplecomv1alpha1.MemcachedStatus{}
105-
}
106-
107102
if len(memcached.Status.Conditions) == 0 {
108103
meta.SetStatusCondition(&memcached.Status.Conditions, metav1.Condition{Type: typeAvailableMemcached, Status: metav1.ConditionUnknown, Reason: "Reconciling", Message: "Starting reconciliation"})
109104
if err = r.Status().Update(ctx, memcached); err != nil {

testdata/project-v4-with-plugins/api/v1alpha1/busybox_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ type Busybox struct {
6666

6767
// metadata is a standard object metadata
6868
// +optional
69-
metav1.ObjectMeta `json:"metadata,omitempty"`
69+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
7070

7171
// spec defines the desired state of Busybox
7272
// +required
7373
Spec BusyboxSpec `json:"spec"`
7474

7575
// status defines the observed state of Busybox
7676
// +optional
77-
Status *BusyboxStatus `json:"status,omitempty"`
77+
Status BusyboxStatus `json:"status,omitempty,omitzero"`
7878
}
7979

8080
// +kubebuilder:object:root=true

testdata/project-v4-with-plugins/api/v1alpha1/memcached_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ type Memcached struct {
7070

7171
// metadata is a standard object metadata
7272
// +optional
73-
metav1.ObjectMeta `json:"metadata,omitempty"`
73+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
7474

7575
// spec defines the desired state of Memcached
7676
// +required
7777
Spec MemcachedSpec `json:"spec"`
7878

7979
// status defines the observed state of Memcached
8080
// +optional
81-
Status *MemcachedStatus `json:"status,omitempty"`
81+
Status MemcachedStatus `json:"status,omitempty,omitzero"`
8282
}
8383

8484
// +kubebuilder:object:root=true

testdata/project-v4-with-plugins/api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 2 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)