Advisor: Add human readable name to check types (#105717)
This commit is contained in:
@@ -29,6 +29,10 @@ func (c *check) ID() string {
|
||||
return CheckID
|
||||
}
|
||||
|
||||
func (c *check) Name() string {
|
||||
return "SSO Setting"
|
||||
}
|
||||
|
||||
func (c *check) Init(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -87,6 +87,10 @@ func (c *check) ID() string {
|
||||
return CheckID
|
||||
}
|
||||
|
||||
func (c *check) Name() string {
|
||||
return "Data Source"
|
||||
}
|
||||
|
||||
func (c *check) Init(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
@@ -154,7 +158,7 @@ func (s *healthCheckStep) Title() string {
|
||||
}
|
||||
|
||||
func (s *healthCheckStep) Description() string {
|
||||
return "Checks if a data sources is healthy."
|
||||
return "Checks if a data source is healthy."
|
||||
}
|
||||
|
||||
func (s *healthCheckStep) Resolution() string {
|
||||
@@ -228,7 +232,7 @@ func (s *missingPluginStep) Title() string {
|
||||
}
|
||||
|
||||
func (s *missingPluginStep) Description() string {
|
||||
return "Checks if the plugin associated with the data source is installed."
|
||||
return "Checks if the plugin associated with the data source is installed and available."
|
||||
}
|
||||
|
||||
func (s *missingPluginStep) Resolution() string {
|
||||
@@ -263,7 +267,7 @@ func (s *missingPluginStep) Run(ctx context.Context, log logging.Logger, obj *ad
|
||||
if len(plugins) > 0 {
|
||||
// Plugin is available in the repo
|
||||
links = append(links, advisor.CheckErrorLink{
|
||||
Message: "Install plugin",
|
||||
Message: "View plugin",
|
||||
Url: fmt.Sprintf("/plugins/%s", ds.Type),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import (
|
||||
type Check interface {
|
||||
// ID returns the unique identifier of the check
|
||||
ID() string
|
||||
// Name returns the human-readable name of the check
|
||||
Name() string
|
||||
// Item returns the item that will be checked
|
||||
Item(ctx context.Context, id string) (any, error)
|
||||
// Items returns the list of items that will be checked
|
||||
|
||||
@@ -45,6 +45,10 @@ func (c *check) ID() string {
|
||||
return CheckID
|
||||
}
|
||||
|
||||
func (c *check) Name() string {
|
||||
return "Plugin"
|
||||
}
|
||||
|
||||
func (c *check) Items(ctx context.Context) ([]any, error) {
|
||||
ps := c.PluginStore.Plugins(ctx)
|
||||
res := make([]any, len(ps))
|
||||
|
||||
@@ -18,6 +18,7 @@ const (
|
||||
RetryAnnotation = "advisor.grafana.app/retry"
|
||||
IgnoreStepsAnnotation = "advisor.grafana.app/ignore-steps"
|
||||
IgnoreStepsAnnotationList = "advisor.grafana.app/ignore-steps-list"
|
||||
NameAnnotation = "advisor.grafana.app/checktype-name"
|
||||
StatusAnnotationError = "error"
|
||||
StatusAnnotationProcessed = "processed"
|
||||
)
|
||||
|
||||
@@ -3,6 +3,7 @@ package checktyperegisterer
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"maps"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana-app-sdk/app"
|
||||
@@ -70,7 +71,9 @@ func (r *Runner) createOrUpdate(ctx context.Context, log logging.Logger, obj res
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
annotations := current.GetAnnotations()
|
||||
currentAnnotations := current.GetAnnotations()
|
||||
annotations := obj.GetAnnotations()
|
||||
maps.Copy(annotations, currentAnnotations)
|
||||
obj.SetAnnotations(annotations)
|
||||
_, err = r.client.Update(ctx, id, obj, resource.UpdateOptions{})
|
||||
if err != nil {
|
||||
@@ -103,6 +106,7 @@ func (r *Runner) Run(ctx context.Context) error {
|
||||
Name: t.ID(),
|
||||
Namespace: r.namespace,
|
||||
Annotations: map[string]string{
|
||||
checks.NameAnnotation: t.Name(),
|
||||
// Flag to indicate feature availability
|
||||
checks.RetryAnnotation: "1",
|
||||
checks.IgnoreStepsAnnotation: "1",
|
||||
|
||||
@@ -178,20 +178,34 @@ func (m *mockCheckRegistry) Checks() []checks.Check {
|
||||
}
|
||||
|
||||
type mockCheck struct {
|
||||
checks.Check
|
||||
|
||||
id string
|
||||
steps []checks.Step
|
||||
}
|
||||
|
||||
func (m *mockCheck) Init(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockCheck) ID() string {
|
||||
return m.id
|
||||
}
|
||||
|
||||
func (m *mockCheck) Name() string {
|
||||
return "mock"
|
||||
}
|
||||
|
||||
func (m *mockCheck) Steps() []checks.Step {
|
||||
return m.steps
|
||||
}
|
||||
|
||||
func (m *mockCheck) Item(ctx context.Context, id string) (any, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *mockCheck) Items(ctx context.Context) ([]any, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
type mockStep struct {
|
||||
id string
|
||||
title string
|
||||
|
||||
@@ -322,6 +322,10 @@ func (m *mockCheck) ID() string {
|
||||
return "mock"
|
||||
}
|
||||
|
||||
func (m *mockCheck) Name() string {
|
||||
return "Mock"
|
||||
}
|
||||
|
||||
func (m *mockCheck) Items(ctx context.Context) ([]any, error) {
|
||||
return m.items, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user