Skip to content

Commit 83873d0

Browse files
authored
fix: create a new map when deep copy (#37)
Signed-off-by: Nic <[email protected]>
1 parent e51e5e6 commit 83873d0

File tree

6 files changed

+28
-23
lines changed

6 files changed

+28
-23
lines changed

pkg/kube/apisix/apis/config/v2/types.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ func (p ApisixRoutePluginConfig) DeepCopyInto(out *ApisixRoutePluginConfig) {
190190
_ = json.Unmarshal(b, out)
191191
}
192192

193-
func (p *ApisixRoutePluginConfig) DeepCopy() *ApisixRoutePluginConfig {
193+
func (p ApisixRoutePluginConfig) DeepCopy() ApisixRoutePluginConfig {
194194
if p == nil {
195195
return nil
196196
}
197-
out := new(ApisixRoutePluginConfig)
198-
p.DeepCopyInto(out)
197+
out := make(ApisixRoutePluginConfig)
198+
p.DeepCopyInto(&out)
199199
return out
200200
}
201201

@@ -717,12 +717,12 @@ func (p Config) DeepCopyInto(out *Config) {
717717
_ = json.Unmarshal(b, out)
718718
}
719719

720-
func (p *Config) DeepCopy() *Config {
720+
func (p Config) DeepCopy() Config {
721721
if p == nil {
722722
return nil
723723
}
724-
out := new(Config)
725-
p.DeepCopyInto(out)
724+
out := make(Config)
725+
p.DeepCopyInto(&out)
726726
return out
727727
}
728728

pkg/kube/apisix/apis/config/v2/zz_generated.deepcopy.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/providers/ingress/translation/translator.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ func (t *translator) translateIngressV1(ing *networkingv1.Ingress, skipVerify bo
272272
route.Priority = _regexPriority
273273
}
274274
if len(ingress.Plugins) > 0 {
275-
route.Plugins = *(ingress.Plugins.DeepCopy())
275+
route.Plugins = ingress.Plugins.DeepCopy()
276276
}
277277

278278
if ingress.PluginConfigName != "" {
@@ -377,7 +377,7 @@ func (t *translator) translateIngressV1beta1(ing *networkingv1beta1.Ingress, ski
377377
route.Priority = _regexPriority
378378
}
379379
if len(ingress.Plugins) > 0 {
380-
route.Plugins = *(ingress.Plugins.DeepCopy())
380+
route.Plugins = ingress.Plugins.DeepCopy()
381381
}
382382
if ingress.Upstream.Retry > 0 {
383383
retry := ingress.Upstream.Retry

pkg/types/apisix/v1/plugin_types.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ func (p *Headers) DeepCopyInto(out *Headers) {
194194
_ = json.Unmarshal(b, out)
195195
}
196196

197-
func (p *Headers) DeepCopy() *Headers {
197+
func (p Headers) DeepCopy() Headers {
198198
if p == nil {
199199
return nil
200200
}
201-
out := new(Headers)
202-
p.DeepCopyInto(out)
201+
out := make(Headers)
202+
p.DeepCopyInto(&out)
203203
return out
204204
}
205205

pkg/types/apisix/v1/types.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,12 @@ func (p *Plugins) DeepCopyInto(out *Plugins) {
227227
_ = json.Unmarshal(b, out)
228228
}
229229

230-
func (p *Plugins) DeepCopy() *Plugins {
230+
func (p Plugins) DeepCopy() Plugins {
231231
if p == nil {
232232
return nil
233233
}
234-
out := new(Plugins)
235-
p.DeepCopyInto(out)
234+
out := make(Plugins)
235+
p.DeepCopyInto(&out)
236236
return out
237237
}
238238

pkg/types/apisix/v1/zz_generated.deepcopy.go

+12-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)