Skip to content

Commit

Permalink
chore: add a config flag for widget backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ReuDa committed Dec 11, 2024
1 parent 54bf550 commit ce6036c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
11 changes: 6 additions & 5 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
6 changes: 6 additions & 0 deletions exthttpcheck/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion exthttpcheck/fixAmount.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,20 @@ 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)",
Description: "Calls an http endpoint a specified number of times and checks the response",
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
Expand Down
7 changes: 6 additions & 1 deletion exthttpcheck/periodically.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,19 @@ 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)",
Description: "Calls a http endpoint periodically (requests / s) and checks the response",
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
Expand Down

0 comments on commit ce6036c

Please sign in to comment.