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": {