Skip to content

Commit

Permalink
mockgcp: monitoringDashboard should default minAlignmentPeriod in tim…
Browse files Browse the repository at this point in the history
…eSeriesTable
  • Loading branch information
justinsb committed Jul 1, 2024
1 parent f527f6e commit 0f2be4c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
18 changes: 18 additions & 0 deletions mockgcp/mockmonitoring/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"fmt"
"strings"
"time"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ spec:
- column: column2
visible: false
dataSets:
- timeSeriesQuery:
- minAlignmentPeriod: 0s
timeSeriesQuery:
timeSeriesFilter:
aggregation:
alignmentPeriod: "60"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ X-Xss-Protection: 0
],
"dataSets": [
{
"minAlignmentPeriod": "0s",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
Expand Down Expand Up @@ -812,6 +813,7 @@ X-Xss-Protection: 0
],
"dataSets": [
{
"minAlignmentPeriod": "0s",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
Expand Down Expand Up @@ -1261,6 +1263,7 @@ X-Xss-Protection: 0
],
"dataSets": [
{
"minAlignmentPeriod": "0s",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
Expand Down Expand Up @@ -1495,6 +1498,7 @@ X-Xss-Protection: 0
],
"dataSets": [
{
"minAlignmentPeriod": "0s",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ X-Xss-Protection: 0
"widget": {
"text": {
"content": "CollapsibleGroup content",
"format": "MARKDOWN",
"format": 1,
"style": {}
}
},
Expand Down Expand Up @@ -370,7 +370,7 @@ X-Xss-Protection: 0
"widget": {
"text": {
"content": "CollapsibleGroup content",
"format": "MARKDOWN",
"format": 1,
"style": {}
}
},
Expand Down Expand Up @@ -496,7 +496,7 @@ X-Xss-Protection: 0
"widget": {
"text": {
"content": "CollapsibleGroup content",
"format": "MARKDOWN",
"format": 1,
"style": {}
}
},
Expand Down Expand Up @@ -569,7 +569,7 @@ X-Xss-Protection: 0
"widget": {
"text": {
"content": "CollapsibleGroup content",
"format": "MARKDOWN",
"format": 1,
"style": {}
}
},
Expand Down

0 comments on commit 0f2be4c

Please sign in to comment.