From 71f204d46510203d00a976421212525c1cf2a316 Mon Sep 17 00:00:00 2001 From: Johnny Steenbergen Date: Mon, 3 Feb 2020 13:26:50 -0800 Subject: [PATCH] fix(pkger): drop text color requirement for single stat charts --- pkger/models.go | 13 ++++----- pkger/parser_test.go | 68 ++------------------------------------------ 2 files changed, 9 insertions(+), 72 deletions(-) diff --git a/pkger/models.go b/pkger/models.go index 8ad67abd52..11dccf02d9 100644 --- a/pkger/models.go +++ b/pkger/models.go @@ -2354,9 +2354,7 @@ func (c chart) validProperties() []validationErr { case chartKindScatter: fails = append(fails, c.Axes.hasAxes("x", "y")...) case chartKindSingleStat: - fails = append(fails, c.Colors.hasTypes(colorTypeText)...) case chartKindSingleStatPlusLine: - fails = append(fails, c.Colors.hasTypes(colorTypeText)...) fails = append(fails, c.Axes.hasAxes("x", "y")...) fails = append(fails, validPosition(c.Position)...) case chartKindXY: @@ -2420,11 +2418,12 @@ func (c chart) validBaseProps() []validationErr { } const ( - colorTypeMin = "min" - colorTypeMax = "max" - colorTypeScale = "scale" - colorTypeText = "text" - colorTypeThreshold = "threshold" + colorTypeBackground = "background" + colorTypeMin = "min" + colorTypeMax = "max" + colorTypeScale = "scale" + colorTypeText = "text" + colorTypeThreshold = "threshold" ) const ( diff --git a/pkger/parser_test.go b/pkger/parser_test.go index 0e24a3745c..918cf3e86d 100644 --- a/pkger/parser_test.go +++ b/pkger/parser_test.go @@ -1970,48 +1970,6 @@ spec: suffix: y_suffix base: 10 scale: linear -`, - }, - { - name: "missing text color but has scale color", - validationErrs: 1, - valFields: []string{"charts[0].colors"}, - pkgStr: `apiVersion: influxdata.com/v2alpha1 -kind: Dashboard -metadata: - name: dash_1 -spec: - description: desc1 - charts: - - kind: Single_Stat_Plus_Line - name: single stat plus line - suffix: days - xPos: 1 - yPos: 2 - width: 6 - height: 3 - position: overlaid - queries: - - query: > - from(bucket: v.bucket) |> range(start: v.timeRangeStart) |> filter(fn: (r) => r._measurement == "mem") |> filter(fn: (r) => r._field == "used_percent") |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false) |> yield(name: "mean") - colors: - - name: android - type: scale - hex: "#F4CF31" - value: 1 - axes: - - name : "x" - label: x_label - prefix: x_prefix - suffix: x_suffix - base: 10 - scale: linear - - name: "y" - label: y_label - prefix: y_prefix - suffix: y_suffix - base: 10 - scale: linear `, }, { @@ -3373,13 +3331,7 @@ spec: }) t.Run("jsonnet support", func(t *testing.T) { - pkg := validParsedPkg(t, "testdata/bucket_associates_labels.jsonnet", EncodingJsonnet, baseAsserts{ - version: "0.1.0", - kind: KindPackage, - description: "pack description", - metaName: "pkg_name", - metaVersion: "1", - }) + pkg := validParsedPkg(t, "testdata/bucket_associates_labels.jsonnet", EncodingJsonnet) sum := pkg.Summary() @@ -3649,15 +3601,7 @@ func nextField(t *testing.T, field string) (string, int) { return "", -1 } -type baseAsserts struct { - version string - kind Kind - description string - metaName string - metaVersion string -} - -func validParsedPkg(t *testing.T, path string, encoding Encoding, expected baseAsserts) *Pkg { +func validParsedPkg(t *testing.T, path string, encoding Encoding) *Pkg { t.Helper() pkg, err := Parse(encoding, FromFile(path)) @@ -3705,13 +3649,7 @@ func testfileRunner(t *testing.T, path string, testFn func(t *testing.T, pkg *Pk fn := func(t *testing.T) { t.Helper() - pkg := validParsedPkg(t, path+tt.extension, tt.encoding, baseAsserts{ - version: "0.1.0", - kind: KindPackage, - description: "pack description", - metaName: "pkg_name", - metaVersion: "1", - }) + pkg := validParsedPkg(t, path+tt.extension, tt.encoding) if testFn != nil { testFn(t, pkg) }