Skip to content

Commit ab0e9cd

Browse files
committed
Omitempty
1 parent f9f30aa commit ab0e9cd

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

apis/v1alpha2/nginxproxy_types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,11 @@ type DeploymentSpec struct {
436436
// +optional
437437
Replicas *int32 `json:"replicas,omitempty"`
438438

439+
// Autoscaling defines the configuration for Horizontal Pod Autoscaling.
440+
//
441+
// +optional
442+
Autoscaling *HPASpec `json:"autoscaling,omitempty"`
443+
439444
// Pod defines Pod-specific fields.
440445
//
441446
// +optional
@@ -450,11 +455,6 @@ type DeploymentSpec struct {
450455
//
451456
// +optional
452457
Patches []Patch `json:"patches,omitempty"`
453-
454-
// Autoscaling defines the configuration for Horizontal Pod Autoscaling.
455-
//
456-
// +optional
457-
Autoscaling HPASpec `json:"autoscaling"`
458458
}
459459

460460
// DaemonSet is the configuration for the NGINX DaemonSet.

apis/v1alpha2/zz_generated.deepcopy.go

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/controller/provisioner/objects.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func (p *NginxProvisioner) buildNginxResourceObjects(
202202
}
203203

204204
func isAutoscalingEnabled(dep *ngfAPIv1alpha2.DeploymentSpec) bool {
205-
return dep != nil && dep.Autoscaling.Enabled
205+
return dep != nil && dep.Autoscaling != nil && dep.Autoscaling.Enabled
206206
}
207207

208208
func (p *NginxProvisioner) buildHPA(
@@ -1141,7 +1141,7 @@ func getMetricTargetByType(target autoscalingv2.MetricTarget) autoscalingv2.Metr
11411141

11421142
func buildNginxDeploymentHPA(
11431143
objectMeta metav1.ObjectMeta,
1144-
autoScaling ngfAPIv1alpha2.HPASpec,
1144+
autoScaling *ngfAPIv1alpha2.HPASpec,
11451145
) *autoscalingv2.HorizontalPodAutoscaler {
11461146
if !autoScaling.Enabled {
11471147
return nil

internal/controller/provisioner/objects_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ func TestBuildNginxResourceObjects_NginxProxyConfig(t *testing.T) {
287287
},
288288
Deployment: &ngfAPIv1alpha2.DeploymentSpec{
289289
Replicas: helpers.GetPointer[int32](3),
290-
Autoscaling: ngfAPIv1alpha2.HPASpec{
290+
Autoscaling: &ngfAPIv1alpha2.HPASpec{
291291
Enabled: true,
292292
MinReplicas: helpers.GetPointer[int32](1),
293293
MaxReplicas: 5,
@@ -438,7 +438,7 @@ func TestBuildNginxResourceObjects_DeploymentReplicasFromHPA(t *testing.T) {
438438
Kubernetes: &ngfAPIv1alpha2.KubernetesSpec{
439439
Deployment: &ngfAPIv1alpha2.DeploymentSpec{
440440
Replicas: nil, // Should be overridden by HPA
441-
Autoscaling: ngfAPIv1alpha2.HPASpec{Enabled: true},
441+
Autoscaling: &ngfAPIv1alpha2.HPASpec{Enabled: true},
442442
},
443443
},
444444
}

0 commit comments

Comments
 (0)