Skip to content

Commit

Permalink
Fix panic
Browse files Browse the repository at this point in the history
  • Loading branch information
barchw committed Dec 13, 2024
1 parent 71a3b88 commit c526d0e
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions api/v1alpha2/istio_merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,34 +260,37 @@ func (i *Istio) mergeResources(op iopv1alpha1.IstioOperator) (iopv1alpha1.IstioO

if i.Spec.Components.Proxy != nil && i.Spec.Components.Proxy.K8S != nil && i.Spec.Components.Proxy.K8S.Resources != nil {
if i.Spec.Components.Proxy.K8S.Resources.Limits != nil {
err = valuesMap.SetPath("global.proxy.resources.limits.cpu", *i.Spec.Components.Proxy.K8S.Resources.Limits.Cpu)
if err != nil {
return iopv1alpha1.IstioOperator{}, err
}
}
if i.Spec.Components.Proxy.K8S.Resources.Limits != nil {
err = valuesMap.SetPath("global.proxy.resources.limits.memory", *i.Spec.Components.Proxy.K8S.Resources.Limits.Memory)
if err != nil {
return iopv1alpha1.IstioOperator{}, err
}
}

if i.Spec.Components.Proxy.K8S.Resources.Requests != nil {
if i.Spec.Components.Proxy.K8S.Resources.Requests.Cpu != nil {
err = valuesMap.SetPath("global.proxy.resources.requests.cpu", *i.Spec.Components.Proxy.K8S.Resources.Requests.Cpu)
if i.Spec.Components.Proxy.K8S.Resources.Limits.Cpu != nil {
err = valuesMap.SetPath("global.proxy.resources.limits.cpu", *i.Spec.Components.Proxy.K8S.Resources.Limits.Cpu)
if err != nil {
return iopv1alpha1.IstioOperator{}, err
}
}

if i.Spec.Components.Proxy.K8S.Resources.Requests.Memory != nil {
err = valuesMap.SetPath("global.proxy.resources.requests.memory", *i.Spec.Components.Proxy.K8S.Resources.Requests.Memory)
if i.Spec.Components.Proxy.K8S.Resources.Limits.Memory != nil {
err = valuesMap.SetPath("global.proxy.resources.limits.memory", *i.Spec.Components.Proxy.K8S.Resources.Limits.Memory)
if err != nil {
return iopv1alpha1.IstioOperator{}, err
}
}
}

if i.Spec.Components.Proxy.K8S.Resources.Requests != nil {
if i.Spec.Components.Proxy.K8S.Resources.Requests != nil {
if i.Spec.Components.Proxy.K8S.Resources.Requests.Cpu != nil {
err = valuesMap.SetPath("global.proxy.resources.requests.cpu", *i.Spec.Components.Proxy.K8S.Resources.Requests.Cpu)
if err != nil {
return iopv1alpha1.IstioOperator{}, err
}
}

if i.Spec.Components.Proxy.K8S.Resources.Requests.Memory != nil {
err = valuesMap.SetPath("global.proxy.resources.requests.memory", *i.Spec.Components.Proxy.K8S.Resources.Requests.Memory)
if err != nil {
return iopv1alpha1.IstioOperator{}, err
}
}
}
}
op.Spec.Values, err = values.ConvertMap[json.RawMessage](valuesMap)
}

Expand Down

0 comments on commit c526d0e

Please sign in to comment.