From ce6036c97d1216513109ddbf5e8dd0e9fb9992c9 Mon Sep 17 00:00:00 2001 From: Daniel Reuter Date: Wed, 11 Dec 2024 14:41:11 +0100 Subject: [PATCH] chore: add a config flag for widget backward compatibility --- config/config.go | 11 ++++++----- exthttpcheck/common.go | 6 ++++++ exthttpcheck/fixAmount.go | 8 +++++++- exthttpcheck/periodically.go | 7 ++++++- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/config/config.go b/config/config.go index 5021863..036787d 100644 --- a/config/config.go +++ b/config/config.go @@ -13,11 +13,12 @@ import ( // through environment variables. Learn more through the documentation of the envconfig package. // https://github.com/kelseyhightower/envconfig type Specification struct { - KubernetesClusterName string `json:"kubernetesClusterName" split_words:"true" required:"false"` - KubernetesNodeName string `json:"kubernetesNodeName" split_words:"true" required:"false"` - KubernetesPodName string `json:"kubernetesPodName" split_words:"true" required:"false"` - KubernetesNamespace string `json:"kubernetesNamespace" split_words:"true" required:"false"` - EnableLocationSelection bool `json:"enableLocationSelection" split_words:"true" required:"false"` + KubernetesClusterName string `json:"kubernetesClusterName" split_words:"true" required:"false"` + KubernetesNodeName string `json:"kubernetesNodeName" split_words:"true" required:"false"` + KubernetesPodName string `json:"kubernetesPodName" split_words:"true" required:"false"` + KubernetesNamespace string `json:"kubernetesNamespace" split_words:"true" required:"false"` + EnableLocationSelection bool `json:"enableLocationSelection" split_words:"true" required:"false"` + EnableWidgetBackwardCompatibility bool `json:"enableWidgetBackwardCompatibility" split_words:"true" required:"false" default:"true"` } var ( diff --git a/exthttpcheck/common.go b/exthttpcheck/common.go index 2b7f65f..be34ad1 100644 --- a/exthttpcheck/common.go +++ b/exthttpcheck/common.go @@ -222,6 +222,12 @@ var ( Advanced: extutil.Ptr(true), Order: extutil.Ptr(22), } + widgetsBackwardCompatiblity = extutil.Ptr([]action_kit_api.Widget{ + action_kit_api.PredefinedWidget{ + Type: action_kit_api.ComSteadybitWidgetPredefined, + PredefinedWidgetId: "com.steadybit.widget.predefined.HttpCheck", + }, + }) widgets = extutil.Ptr([]action_kit_api.Widget{ action_kit_api.LineChartWidget{ Type: action_kit_api.ComSteadybitWidgetLineChart, diff --git a/exthttpcheck/fixAmount.go b/exthttpcheck/fixAmount.go index bc245dc..14c9600 100644 --- a/exthttpcheck/fixAmount.go +++ b/exthttpcheck/fixAmount.go @@ -36,6 +36,12 @@ func (l *httpCheckActionFixedAmount) NewEmptyState() HTTPCheckState { // Describe returns the action description for the platform with all required information. func (l *httpCheckActionFixedAmount) Describe() action_kit_api.ActionDescription { + + widgetToUse := widgets + if config.Config.EnableWidgetBackwardCompatibility { + widgetToUse = widgetsBackwardCompatiblity + } + description := action_kit_api.ActionDescription{ Id: ActionIDFixedAmount, Label: "HTTP (# of Requests)", @@ -43,7 +49,7 @@ func (l *httpCheckActionFixedAmount) Describe() action_kit_api.ActionDescription Version: extbuild.GetSemverVersionStringOrUnknown(), Icon: extutil.Ptr(actionIconFixedAmount), TargetSelection: targetSelection, - Widgets: widgets, + Widgets: widgetToUse, Technology: extutil.Ptr("HTTP"), Category: extutil.Ptr("HTTP"), //Can be removed in Q1/24 - support for backward compatibility of old sidebar diff --git a/exthttpcheck/periodically.go b/exthttpcheck/periodically.go index e4dc762..c8ac2d1 100644 --- a/exthttpcheck/periodically.go +++ b/exthttpcheck/periodically.go @@ -35,6 +35,11 @@ func (l *httpCheckActionPeriodically) NewEmptyState() HTTPCheckState { // Describe returns the action description for the platform with all required information. func (l *httpCheckActionPeriodically) Describe() action_kit_api.ActionDescription { + widgetToUse := widgets + if config.Config.EnableWidgetBackwardCompatibility { + widgetToUse = widgetsBackwardCompatiblity + } + description := action_kit_api.ActionDescription{ Id: ActionIDPeriodically, Label: "HTTP (Requests / s)", @@ -42,7 +47,7 @@ func (l *httpCheckActionPeriodically) Describe() action_kit_api.ActionDescriptio Version: extbuild.GetSemverVersionStringOrUnknown(), Icon: extutil.Ptr(actionIconPeriodically), TargetSelection: targetSelection, - Widgets: widgets, + Widgets: widgetToUse, Technology: extutil.Ptr("HTTP"), Category: extutil.Ptr("HTTP"), //Can be removed in Q1/24 - support for backward compatibility of old sidebar