@@ -17,7 +17,10 @@ limitations under the License.
1717package v1
1818
1919import (
20+ "fmt"
2021 "reflect"
22+ "regexp"
23+ "strconv"
2124
2225 "go.mongodb.org/atlas/mongodbatlas"
2326 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -306,10 +309,28 @@ type ProcessArgs struct {
306309
307310func (specArgs ProcessArgs ) ToAtlas () (* mongodbatlas.ProcessArgs , error ) {
308311 result := & mongodbatlas.ProcessArgs {}
312+ if err := convertOplogMinRetentionHours (& specArgs , result ); err != nil {
313+ return nil , err
314+ }
315+
309316 err := compat .JSONCopy (result , specArgs )
310317 return result , err
311318}
312319
320+ func convertOplogMinRetentionHours (specArgs * ProcessArgs , atlasArgs * mongodbatlas.ProcessArgs ) error {
321+ if specArgs != nil && specArgs .OplogMinRetentionHours != "" {
322+ OplogMinRetentionHours , err := strconv .ParseFloat (specArgs .OplogMinRetentionHours , 64 )
323+ if err != nil {
324+ return err
325+ }
326+
327+ atlasArgs .OplogMinRetentionHours = & OplogMinRetentionHours
328+ specArgs .OplogMinRetentionHours = ""
329+ }
330+
331+ return nil
332+ }
333+
313334func (specArgs ProcessArgs ) IsEqual (newArgs interface {}) bool {
314335 specV := reflect .ValueOf (specArgs )
315336 newV := reflect .Indirect (reflect .ValueOf (newArgs ))
@@ -330,21 +351,30 @@ func (specArgs ProcessArgs) IsEqual(newArgs interface{}) bool {
330351 if specValue .IsNil () {
331352 continue
332353 }
354+ specValue = specValue .Elem ()
355+ }
356+
357+ if newValue .Kind () == reflect .Ptr {
333358 if newValue .IsNil () {
334359 return false
335360 }
336- specValue = specValue .Elem ()
337361 newValue = newValue .Elem ()
338362 }
339363
340- if specValue .Interface () != newValue .Interface () {
364+ if stringValue ( specValue .Interface ()) != stringValue ( newValue .Interface () ) {
341365 return false
342366 }
343367 }
344368
345369 return true
346370}
347371
372+ var TrailingZerosRegex = regexp .MustCompile (`\.[0]*$` )
373+
374+ func stringValue (v interface {}) string {
375+ return TrailingZerosRegex .ReplaceAllString (fmt .Sprint (v ), "" )
376+ }
377+
348378// Check compatibility with library type.
349379var _ = ComputeSpec (mongodbatlas.Compute {})
350380
0 commit comments