diff --git a/internal/kubernetes/operator/convert/convert.go b/internal/kubernetes/operator/convert/convert.go new file mode 100644 index 0000000000..b2c674922d --- /dev/null +++ b/internal/kubernetes/operator/convert/convert.go @@ -0,0 +1,23 @@ +// Copyright 2024 MongoDB Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package convert + +func IntToInt64(source *int) *int64 { + if source == nil { + return nil + } + x := int64(*source) + return &x +} diff --git a/internal/kubernetes/operator/deployment/deployment.go b/internal/kubernetes/operator/deployment/deployment.go index 9e9066f08f..c050174bfd 100644 --- a/internal/kubernetes/operator/deployment/deployment.go +++ b/internal/kubernetes/operator/deployment/deployment.go @@ -17,6 +17,7 @@ package deployment import ( "fmt" + "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/kubernetes/operator/convert" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/kubernetes/operator/features" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/kubernetes/operator/resources" "github.com/mongodb/mongodb-atlas-cli/atlascli/internal/pointer" @@ -389,7 +390,7 @@ func buildReplicationSpec(atlasRepSpec []atlasv2.ReplicationSpec) []*akov2.Advan var analyticsSpecs *akov2.Specs if rc.AnalyticsSpecs != nil { analyticsSpecs = &akov2.Specs{ - DiskIOPS: pointer.Get(int64(rc.AnalyticsSpecs.GetDiskIOPS())), + DiskIOPS: convert.IntToInt64(rc.AnalyticsSpecs.DiskIOPS), EbsVolumeType: rc.AnalyticsSpecs.GetEbsVolumeType(), InstanceSize: rc.AnalyticsSpecs.GetInstanceSize(), NodeCount: rc.AnalyticsSpecs.NodeCount, @@ -398,7 +399,7 @@ func buildReplicationSpec(atlasRepSpec []atlasv2.ReplicationSpec) []*akov2.Advan var electableSpecs *akov2.Specs if rc.ElectableSpecs != nil { electableSpecs = &akov2.Specs{ - DiskIOPS: pointer.Get(int64(rc.ElectableSpecs.GetDiskIOPS())), + DiskIOPS: convert.IntToInt64(rc.ElectableSpecs.DiskIOPS), EbsVolumeType: rc.ElectableSpecs.GetEbsVolumeType(), InstanceSize: rc.ElectableSpecs.GetInstanceSize(), NodeCount: rc.ElectableSpecs.NodeCount, @@ -408,7 +409,7 @@ func buildReplicationSpec(atlasRepSpec []atlasv2.ReplicationSpec) []*akov2.Advan var readOnlySpecs *akov2.Specs if rc.ReadOnlySpecs != nil { readOnlySpecs = &akov2.Specs{ - DiskIOPS: pointer.Get(int64(rc.ReadOnlySpecs.GetDiskIOPS())), + DiskIOPS: convert.IntToInt64(rc.ReadOnlySpecs.DiskIOPS), EbsVolumeType: rc.ReadOnlySpecs.GetEbsVolumeType(), InstanceSize: rc.ReadOnlySpecs.GetInstanceSize(), NodeCount: rc.ReadOnlySpecs.NodeCount,