Skip to content

Commit

Permalink
Make soft_min and soft_double Float64
Browse files Browse the repository at this point in the history
  • Loading branch information
iRevive committed Feb 22, 2024
1 parent 818c9ed commit 486f958
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
26 changes: 13 additions & 13 deletions internal/provider/grafana/panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,19 +396,19 @@ type (
Options map[string]interface{} `json:"options"`
}
FieldConfigCustom struct {
AxisLabel string `json:"axisLabel,omitempty"`
AxisPlacement string `json:"axisPlacement"`
AxisSoftMin *int64 `json:"axisSoftMin,omitempty"`
AxisSoftMax *int64 `json:"axisSoftMax,omitempty"`
BarAlignment int `json:"barAlignment"`
DrawStyle string `json:"drawStyle"`
FillOpacity int `json:"fillOpacity"`
GradientMode string `json:"gradientMode"`
LineInterpolation string `json:"lineInterpolation"`
LineWidth int `json:"lineWidth"`
PointSize int `json:"pointSize"`
ShowPoints string `json:"showPoints"`
SpanNulls bool `json:"spanNulls"`
AxisLabel string `json:"axisLabel,omitempty"`
AxisPlacement string `json:"axisPlacement"`
AxisSoftMin *float64 `json:"axisSoftMin,omitempty"`
AxisSoftMax *float64 `json:"axisSoftMax,omitempty"`
BarAlignment int `json:"barAlignment"`
DrawStyle string `json:"drawStyle"`
FillOpacity int `json:"fillOpacity"`
GradientMode string `json:"gradientMode"`
LineInterpolation string `json:"lineInterpolation"`
LineWidth int `json:"lineWidth"`
PointSize int `json:"pointSize"`
ShowPoints string `json:"showPoints"`
SpanNulls bool `json:"spanNulls"`
HideFrom struct {
Legend bool `json:"legend"`
Tooltip bool `json:"tooltip"`
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,11 @@ func (p *GrafanaDashboardBuilderProvider) Configure(ctx context.Context, req pro
}

if !axis.SoftMin.IsNull() {
defaults.Timeseries.Axis.SoftMin = axis.SoftMin.ValueInt64Pointer()
defaults.Timeseries.Axis.SoftMin = axis.SoftMin.ValueFloat64Pointer()
}

if !axis.SoftMax.IsNull() {
defaults.Timeseries.Axis.SoftMax = axis.SoftMax.ValueInt64Pointer()
defaults.Timeseries.Axis.SoftMax = axis.SoftMax.ValueFloat64Pointer()
}

for _, scale := range axis.Scale {
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/timeseries_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,11 @@ func (d *TimeseriesDataSource) Read(ctx context.Context, req datasource.ReadRequ
}

if !axis.SoftMin.IsNull() {
fieldConfig.Custom.AxisSoftMin = axis.SoftMin.ValueInt64Pointer()
fieldConfig.Custom.AxisSoftMin = axis.SoftMin.ValueFloat64Pointer()
}

if !axis.SoftMax.IsNull() {
fieldConfig.Custom.AxisSoftMax = axis.SoftMax.ValueInt64Pointer()
fieldConfig.Custom.AxisSoftMax = axis.SoftMax.ValueFloat64Pointer()
}

for _, scale := range axis.Scale {
Expand Down
12 changes: 6 additions & 6 deletions internal/provider/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ type TextSizeDefaults struct {
type AxisDefaults struct {
Label string
Placement string
SoftMin *int64
SoftMax *int64
SoftMin *float64
SoftMax *float64
Scale ScaleDefaults
}

Expand All @@ -148,8 +148,8 @@ type ScaleDefaults struct {
type AxisOptions struct {
Label types.String `tfsdk:"label"`
Placement types.String `tfsdk:"placement"`
SoftMin types.Int64 `tfsdk:"soft_min"`
SoftMax types.Int64 `tfsdk:"soft_max"`
SoftMin types.Float64 `tfsdk:"soft_min"`
SoftMax types.Float64 `tfsdk:"soft_max"`
Scale []ScaleOptions `tfsdk:"scale"`
}

Expand Down Expand Up @@ -341,7 +341,7 @@ func axisBlock() schema.Block {
stringvalidator.OneOf("auto", "left", "right", "hidden"),
},
},
"soft_min": schema.Int64Attribute{
"soft_min": schema.Float64Attribute{
Optional: true,
Description: "The soft minimum of y-axis.",
MarkdownDescription: "The soft minimum of y-axis. " +
Expand All @@ -350,7 +350,7 @@ func axisBlock() schema.Block {
"and hard min or max derived from standard min and max field options can prevent intermittent spikes " +
"from flattening useful detail by clipping the spikes past a defined point.",
},
"soft_max": schema.Int64Attribute{
"soft_max": schema.Float64Attribute{
Optional: true,
Description: "The soft maximum of y-axis.",
MarkdownDescription: "The soft maximum of y-axis. " +
Expand Down

0 comments on commit 486f958

Please sign in to comment.