@@ -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}
0 commit comments