Skip to content

Commit bacd371

Browse files
committed
Code Review
1 parent c53d713 commit bacd371

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

internal/controller/provisioner/objects.go

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -166,42 +166,30 @@ func (p *NginxProvisioner) buildNginxResourceObjects(
166166

167167
objects = append(objects, service, deployment)
168168

169-
if hpa := p.buildHPAIfEnabled(objectMeta, nProxyCfg); hpa != nil {
169+
if hpa := p.buildHPA(objectMeta, nProxyCfg); hpa != nil {
170170
objects = append(objects, hpa)
171171
}
172172

173173
return objects, err
174174
}
175175

176-
func autoscalingEnabled(dep *ngfAPIv1alpha2.DeploymentSpec) bool {
176+
func isAutoscalingEnabled(dep *ngfAPIv1alpha2.DeploymentSpec) bool {
177177
return dep != nil && dep.Autoscaling.Enabled
178178
}
179179

180-
func cloneHPAAnnotationMap(src map[string]string) map[string]string {
181-
if src == nil {
182-
return nil
183-
}
184-
annotations := make(map[string]string, len(src))
185-
for k, v := range src {
186-
annotations[k] = v
187-
}
188-
return annotations
189-
}
190-
191-
func (p *NginxProvisioner) buildHPAIfEnabled(
180+
func (p *NginxProvisioner) buildHPA(
192181
objectMeta metav1.ObjectMeta,
193182
nProxyCfg *graph.EffectiveNginxProxy,
194183
) client.Object {
195184
if nProxyCfg == nil || nProxyCfg.Kubernetes == nil {
196185
return nil
197186
}
198187

199-
if !autoscalingEnabled(nProxyCfg.Kubernetes.Deployment) {
188+
if !isAutoscalingEnabled(nProxyCfg.Kubernetes.Deployment) {
200189
return nil
201190
}
202191

203-
hpaAnnotations := cloneHPAAnnotationMap(nProxyCfg.Kubernetes.Deployment.Autoscaling.HPAAnnotations)
204-
objectMeta.Annotations = hpaAnnotations
192+
objectMeta.Annotations = nProxyCfg.Kubernetes.Deployment.Autoscaling.HPAAnnotations
205193

206194
return buildNginxDeploymentHPA(objectMeta, nProxyCfg)
207195
}

internal/controller/provisioner/objects_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ func TestBuildNginxResourceObjects_NginxProxyConfig(t *testing.T) {
285285
MinReplicas: 1,
286286
MaxReplicas: 5,
287287
TargetMemoryUtilizationPercentage: helpers.GetPointer[int32](60),
288-
// Behavior, AutoscalingTemplate, HPAAnnotations 등은 필요하면 채우고
289288
},
290289
Pod: ngfAPIv1alpha2.PodSpec{
291290
TerminationGracePeriodSeconds: helpers.GetPointer[int64](25),

0 commit comments

Comments
 (0)