signalfx / signalfx-go

Go client library and instrumentation bindings for SignalFx
https://www.signalfx.com
Apache License 2.0
14 stars 48 forks source link

ChartsWebUiFilter, string or slice again? #31

Closed doctornkz closed 5 years ago

doctornkz commented 5 years ago

Found issue with exporting configuration. Exception:

2019/07/09 12:28:49 Dashboard error: json: cannot unmarshal string into Go struct field ChartsWebUiFilter.value of type []string
2019/07/09 12:28:49 Can't fetch dashboard

We have the structure ChartsWebUiFilter:

// The specification for a filter that appears in the web UI. The filter compares the value of a dimension or custom property to a value specified in this filter. You can specify the following in the filter:<br>   * A default value   * A list of suggested values to display in the web UI   * A flag that controls user input; if set to `true`, users are limited     to the default and suggested values. <br> You can also force users to choose this filter in order to see data in the dashboard's charts.
type ChartsWebUiFilter struct {
    // A label for the filter. The system displays this label in the area preceding the input textarea for the filter in the web UI. <br> **Note:** A good way to indicate that the string is a label is to append a space and a colon (\":\") to it.
    Alias         string `json:"alias,omitempty"`
    ApplyIfExists bool   `json:"applyIfExists,omitempty"`
    Description   string `json:"description,omitempty"`
    // Array of strings containing values to place at the top of the **Suggested Values** dropdown in web UI for the dashboard. If `ChartsWebUIFilter.restricted`  is `true`, the filter must use one of the values in this array; users only have a choice of selecting a value from this array.
    PreferredSuggestions []string `json:"preferredSuggestions,omitempty"`
    // Name of a custom property or dimension to filter against.<br> **Note:** If the dimension or custom property doesn't exist in any of the charts for the dashboard, the system doesn't display any data in the charts.
    Property string `json:"property"`
    // Flag that controls the display of chart data. If `true`, users must use this filter in order to see data; otherwise, users can delete the filter.
    Required    bool `json:"required,omitempty"`
    ReplaceOnly bool `json:"replaceOnly,omitempty"`
    // Flag that controls the values allowed in the filter. If `true`, the only allowable values are those specified in the `ChartsWebUIFilter.preferredSuggestsions` array; otherwise, any value is allowed.
    Restricted bool `json:"restricted,omitempty"`
    // A list of values to compare to the value of the dimension or custom property specified in `ChartsWebUIFilter.property`. If the list contains more than one value, the filter becomes a set of queries between the value of `property` and each element of `value`. The system joins these queries with an implicit OR.
    Value []string `json:"value"`
}

I did that:

    // A list of values to compare to the value of the dimension or custom property specified in `ChartsWebUIFilter.property`. If the list contains more than one value, the filter becomes a set of queries between the value of `property` and each element of `value`. The system joins these queries with an implicit OR.
    //Value []string `json:"value"`
    Value StringOrSlice `json:"value"`

and it works now

cory-signalfx commented 5 years ago

Lemme investigate on my end, thanks for flagging!

cory-signalfx commented 5 years ago

Fixed in #32, thanks for flagging and giving me an opportunity to fix these up!