@@ -104,6 +104,10 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex
104104}
105105
106106func outputResult (p * print.Printer , outputFormat string , instance * mongodbflex.Instance ) error {
107+ if instance == nil {
108+ return fmt .Errorf ("instance is nil" )
109+ }
110+
107111 output := struct {
108112 BackupSchedule string `json:"backup_schedule"`
109113 DailySnaphotRetentionDays string `json:"daily_snapshot_retention_days"`
@@ -112,12 +116,14 @@ func outputResult(p *print.Printer, outputFormat string, instance *mongodbflex.I
112116 SnapshotRetentionDays string `json:"snapshot_retention_days"`
113117 WeeklySnapshotRetentionWeeks string `json:"weekly_snapshot_retention_weeks"`
114118 }{
115- BackupSchedule : * instance .BackupSchedule ,
116- DailySnaphotRetentionDays : (* instance .Options )["dailySnapshotRetentionDays" ],
117- MonthlySnapshotRetentionMonths : (* instance .Options )["monthlySnapshotRetentionDays" ],
118- PointInTimeWindowHours : (* instance .Options )["pointInTimeWindowHours" ],
119- SnapshotRetentionDays : (* instance .Options )["snapshotRetentionDays" ],
120- WeeklySnapshotRetentionWeeks : (* instance .Options )["weeklySnapshotRetentionWeeks" ],
119+ BackupSchedule : utils .PtrString (instance .BackupSchedule ),
120+ }
121+ if instance .Options != nil {
122+ output .DailySnaphotRetentionDays = (* instance .Options )["dailySnapshotRetentionDays" ]
123+ output .MonthlySnapshotRetentionMonths = (* instance .Options )["monthlySnapshotRetentionDays" ]
124+ output .PointInTimeWindowHours = (* instance .Options )["pointInTimeWindowHours" ]
125+ output .SnapshotRetentionDays = (* instance .Options )["snapshotRetentionDays" ]
126+ output .WeeklySnapshotRetentionWeeks = (* instance .Options )["weeklySnapshotRetentionWeeks" ]
121127 }
122128
123129 switch outputFormat {
@@ -139,20 +145,19 @@ func outputResult(p *print.Printer, outputFormat string, instance *mongodbflex.I
139145 return nil
140146 default :
141147 table := tables .NewTable ()
142- table .AddRow ("BACKUP SCHEDULE (UTC)" , utils . PtrString ( instance . BackupSchedule ) )
148+ table .AddRow ("BACKUP SCHEDULE (UTC)" , output . BackupSchedule )
143149 table .AddSeparator ()
144- if instance .Options != nil {
145- table .AddRow ("DAILY SNAPSHOT RETENTION (DAYS)" , (* instance .Options )["dailySnapshotRetentionDays" ])
146- table .AddSeparator ()
147- table .AddRow ("MONTHLY SNAPSHOT RETENTION (MONTHS)" , (* instance .Options )["monthlySnapshotRetentionMonths" ])
148- table .AddSeparator ()
149- table .AddRow ("POINT IN TIME WINDOW (HOURS)" , (* instance .Options )["pointInTimeWindowHours" ])
150- table .AddSeparator ()
151- table .AddRow ("SNAPSHOT RETENTION (DAYS)" , (* instance .Options )["snapshotRetentionDays" ])
152- table .AddSeparator ()
153- table .AddRow ("WEEKLY SNAPSHOT RETENTION (WEEKS)" , (* instance .Options )["weeklySnapshotRetentionWeeks" ])
154- table .AddSeparator ()
155- }
150+ table .AddRow ("DAILY SNAPSHOT RETENTION (DAYS)" , output .DailySnaphotRetentionDays )
151+ table .AddSeparator ()
152+ table .AddRow ("MONTHLY SNAPSHOT RETENTION (MONTHS)" , output .MonthlySnapshotRetentionMonths )
153+ table .AddSeparator ()
154+ table .AddRow ("POINT IN TIME WINDOW (HOURS)" , output .PointInTimeWindowHours )
155+ table .AddSeparator ()
156+ table .AddRow ("SNAPSHOT RETENTION (DAYS)" , output .SnapshotRetentionDays )
157+ table .AddSeparator ()
158+ table .AddRow ("WEEKLY SNAPSHOT RETENTION (WEEKS)" , output .WeeklySnapshotRetentionWeeks )
159+ table .AddSeparator ()
160+
156161 err := table .Display (p )
157162 if err != nil {
158163 return fmt .Errorf ("render table: %w" , err )
0 commit comments