From 0f2be4c43ae161baf7f4a784887d827c04bd431a Mon Sep 17 00:00:00 2001 From: justinsb Date: Mon, 1 Jul 2024 11:05:08 -0400 Subject: [PATCH] mockgcp: monitoringDashboard should default minAlignmentPeriod in timeSeriesTable --- mockgcp/mockmonitoring/dashboard.go | 18 ++++++++++++++++++ ...rated_export_monitoringdashboardfull.golden | 3 ++- .../monitoringdashboardfull/_http.log | 4 ++++ .../monitoringdashboardmosaiclayout/_http.log | 8 ++++---- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/mockgcp/mockmonitoring/dashboard.go b/mockgcp/mockmonitoring/dashboard.go index de54cf608f..08029da286 100644 --- a/mockgcp/mockmonitoring/dashboard.go +++ b/mockgcp/mockmonitoring/dashboard.go @@ -18,6 +18,7 @@ import ( "context" "fmt" "strings" + "time" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -123,6 +124,12 @@ func (d *dashboardDefaulter) visitWidget(obj *pb.Widget) { case *pb.Widget_Text: d.visitTextWidget(content) + + case *pb.Widget_PieChart: + d.visitPieChart(content.PieChart) + + case *pb.Widget_TimeSeriesTable: + d.visitTimeSeriesTable(content.TimeSeriesTable) } } @@ -153,6 +160,17 @@ func (d *dashboardDefaulter) visitTextWidget(obj *pb.Widget_Text) { } } +func (d *dashboardDefaulter) visitPieChart(obj *pb.PieChart) { +} + +func (d *dashboardDefaulter) visitTimeSeriesTable(obj *pb.TimeSeriesTable) { + for _, dataSet := range obj.DataSets { + if dataSet.MinAlignmentPeriod == nil { + dataSet.MinAlignmentPeriod = durationpb.New(time.Duration(0)) + } + } +} + type dashboardValidator struct { errors []error } diff --git a/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_generated_export_monitoringdashboardfull.golden b/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_generated_export_monitoringdashboardfull.golden index 72939a72ef..e1e0283fc9 100644 --- a/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_generated_export_monitoringdashboardfull.golden +++ b/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_generated_export_monitoringdashboardfull.golden @@ -106,7 +106,8 @@ spec: - column: column2 visible: false dataSets: - - timeSeriesQuery: + - minAlignmentPeriod: 0s + timeSeriesQuery: timeSeriesFilter: aggregation: alignmentPeriod: "60" diff --git a/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_http.log b/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_http.log index 04cf8766d3..291268578b 100644 --- a/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_http.log +++ b/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardfull/_http.log @@ -578,6 +578,7 @@ X-Xss-Protection: 0 ], "dataSets": [ { + "minAlignmentPeriod": "0s", "timeSeriesQuery": { "timeSeriesFilter": { "aggregation": { @@ -812,6 +813,7 @@ X-Xss-Protection: 0 ], "dataSets": [ { + "minAlignmentPeriod": "0s", "timeSeriesQuery": { "timeSeriesFilter": { "aggregation": { @@ -1261,6 +1263,7 @@ X-Xss-Protection: 0 ], "dataSets": [ { + "minAlignmentPeriod": "0s", "timeSeriesQuery": { "timeSeriesFilter": { "aggregation": { @@ -1495,6 +1498,7 @@ X-Xss-Protection: 0 ], "dataSets": [ { + "minAlignmentPeriod": "0s", "timeSeriesQuery": { "timeSeriesFilter": { "aggregation": { diff --git a/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardmosaiclayout/_http.log b/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardmosaiclayout/_http.log index 914132427c..1355b42646 100644 --- a/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardmosaiclayout/_http.log +++ b/pkg/test/resourcefixture/testdata/basic/monitoring/v1beta1/monitoringdashboard/monitoringdashboardmosaiclayout/_http.log @@ -297,7 +297,7 @@ X-Xss-Protection: 0 "widget": { "text": { "content": "CollapsibleGroup content", - "format": "MARKDOWN", + "format": 1, "style": {} } }, @@ -370,7 +370,7 @@ X-Xss-Protection: 0 "widget": { "text": { "content": "CollapsibleGroup content", - "format": "MARKDOWN", + "format": 1, "style": {} } }, @@ -496,7 +496,7 @@ X-Xss-Protection: 0 "widget": { "text": { "content": "CollapsibleGroup content", - "format": "MARKDOWN", + "format": 1, "style": {} } }, @@ -569,7 +569,7 @@ X-Xss-Protection: 0 "widget": { "text": { "content": "CollapsibleGroup content", - "format": "MARKDOWN", + "format": 1, "style": {} } },