Grafana Advisor: Automatically generate frontend types (#99807)
* Grafana Advisor: Frontend types * fix bad merge
This commit is contained in:
@@ -49,13 +49,13 @@ func (c *check) Run(ctx context.Context, obj *advisor.CheckSpec) (*advisor.Check
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dsErrs := []advisor.CheckV0alpha1StatusReportErrors{}
|
||||
dsErrs := []advisor.CheckReportError{}
|
||||
for _, ds := range dss {
|
||||
// Data source UID validation
|
||||
err := util.ValidateUID(ds.UID)
|
||||
if err != nil {
|
||||
dsErrs = append(dsErrs, advisor.CheckV0alpha1StatusReportErrors{
|
||||
Severity: advisor.CheckStatusSeverityLow,
|
||||
dsErrs = append(dsErrs, advisor.CheckReportError{
|
||||
Severity: advisor.CheckReportErrorSeverityLow,
|
||||
Reason: fmt.Sprintf("Invalid UID '%s' for data source %s", ds.UID, ds.Name),
|
||||
Action: "Check the <a href='https://grafana.com/docs/grafana/latest/upgrade-guide/upgrade-v11.2/#grafana-data-source-uid-format-enforcement' target=_blank>documentation</a> for more information.",
|
||||
})
|
||||
@@ -81,8 +81,8 @@ func (c *check) Run(ctx context.Context, obj *advisor.CheckSpec) (*advisor.Check
|
||||
continue
|
||||
}
|
||||
if resp.Status != backend.HealthStatusOk {
|
||||
dsErrs = append(dsErrs, advisor.CheckV0alpha1StatusReportErrors{
|
||||
Severity: advisor.CheckStatusSeverityHigh,
|
||||
dsErrs = append(dsErrs, advisor.CheckReportError{
|
||||
Severity: advisor.CheckReportErrorSeverityHigh,
|
||||
Reason: fmt.Sprintf("Health check failed for %s", ds.Name),
|
||||
Action: fmt.Sprintf(
|
||||
"Go to the <a href='/connections/datasources/edit/%s'>data source configuration</a>"+
|
||||
|
||||
@@ -43,7 +43,7 @@ func (c *check) Type() string {
|
||||
func (c *check) Run(ctx context.Context, _ *advisor.CheckSpec) (*advisor.CheckV0alpha1StatusReport, error) {
|
||||
ps := c.PluginStore.Plugins(ctx)
|
||||
|
||||
errs := []advisor.CheckV0alpha1StatusReportErrors{}
|
||||
errs := []advisor.CheckReportError{}
|
||||
for _, p := range ps {
|
||||
// Skip if it's a core plugin
|
||||
if p.IsCorePlugin() {
|
||||
@@ -56,8 +56,8 @@ func (c *check) Run(ctx context.Context, _ *advisor.CheckSpec) (*advisor.CheckV0
|
||||
continue
|
||||
}
|
||||
if i.Status == "deprecated" {
|
||||
errs = append(errs, advisor.CheckV0alpha1StatusReportErrors{
|
||||
Severity: advisor.CheckStatusSeverityHigh,
|
||||
errs = append(errs, advisor.CheckReportError{
|
||||
Severity: advisor.CheckReportErrorSeverityHigh,
|
||||
Reason: fmt.Sprintf("Plugin deprecated: %s", p.ID),
|
||||
Action: "Check the <a href='https://grafana.com/legal/plugin-deprecation/#a-plugin-i-use-is-deprecated-what-should-i-do' target=_blank>documentation</a> for recommended steps.",
|
||||
})
|
||||
@@ -73,8 +73,8 @@ func (c *check) Run(ctx context.Context, _ *advisor.CheckSpec) (*advisor.CheckV0
|
||||
continue
|
||||
}
|
||||
if hasUpdate(p, info) {
|
||||
errs = append(errs, advisor.CheckV0alpha1StatusReportErrors{
|
||||
Severity: advisor.CheckStatusSeverityLow,
|
||||
errs = append(errs, advisor.CheckReportError{
|
||||
Severity: advisor.CheckReportErrorSeverityLow,
|
||||
Reason: fmt.Sprintf("New version available for %s", p.ID),
|
||||
Action: fmt.Sprintf(
|
||||
"Go to the <a href='/plugins/%s?page=version-history'>plugin admin page</a>"+
|
||||
|
||||
@@ -21,12 +21,12 @@ func TestRun(t *testing.T) {
|
||||
pluginArchives map[string]*repo.PluginArchiveInfo
|
||||
pluginPreinstalled []string
|
||||
pluginManaged []string
|
||||
expectedErrors []advisor.CheckV0alpha1StatusReportErrors
|
||||
expectedErrors []advisor.CheckReportError
|
||||
}{
|
||||
{
|
||||
name: "No plugins",
|
||||
plugins: []pluginstore.Plugin{},
|
||||
expectedErrors: []advisor.CheckV0alpha1StatusReportErrors{},
|
||||
expectedErrors: []advisor.CheckReportError{},
|
||||
},
|
||||
{
|
||||
name: "Deprecated plugin",
|
||||
@@ -39,9 +39,9 @@ func TestRun(t *testing.T) {
|
||||
pluginArchives: map[string]*repo.PluginArchiveInfo{
|
||||
"plugin1": {Version: "1.0.0"},
|
||||
},
|
||||
expectedErrors: []advisor.CheckV0alpha1StatusReportErrors{
|
||||
expectedErrors: []advisor.CheckReportError{
|
||||
{
|
||||
Severity: advisor.CheckStatusSeverityHigh,
|
||||
Severity: advisor.CheckReportErrorSeverityHigh,
|
||||
Reason: "Plugin deprecated: plugin1",
|
||||
Action: "Check the <a href='https://grafana.com/legal/plugin-deprecation/#a-plugin-i-use-is-deprecated-what-should-i-do' target=_blank>documentation</a> for recommended steps.",
|
||||
},
|
||||
@@ -58,9 +58,9 @@ func TestRun(t *testing.T) {
|
||||
pluginArchives: map[string]*repo.PluginArchiveInfo{
|
||||
"plugin2": {Version: "1.1.0"},
|
||||
},
|
||||
expectedErrors: []advisor.CheckV0alpha1StatusReportErrors{
|
||||
expectedErrors: []advisor.CheckReportError{
|
||||
{
|
||||
Severity: advisor.CheckStatusSeverityLow,
|
||||
Severity: advisor.CheckReportErrorSeverityLow,
|
||||
Reason: "New version available for plugin2",
|
||||
Action: "Go to the <a href='/plugins/plugin2?page=version-history'>plugin admin page</a> and upgrade to the latest version.",
|
||||
},
|
||||
@@ -77,9 +77,9 @@ func TestRun(t *testing.T) {
|
||||
pluginArchives: map[string]*repo.PluginArchiveInfo{
|
||||
"plugin2": {Version: "beta"},
|
||||
},
|
||||
expectedErrors: []advisor.CheckV0alpha1StatusReportErrors{
|
||||
expectedErrors: []advisor.CheckReportError{
|
||||
{
|
||||
Severity: advisor.CheckStatusSeverityLow,
|
||||
Severity: advisor.CheckReportErrorSeverityLow,
|
||||
Reason: "New version available for plugin2",
|
||||
Action: "Go to the <a href='/plugins/plugin2?page=version-history'>plugin admin page</a> and upgrade to the latest version.",
|
||||
},
|
||||
@@ -97,7 +97,7 @@ func TestRun(t *testing.T) {
|
||||
"plugin3": {Version: "1.1.0"},
|
||||
},
|
||||
pluginPreinstalled: []string{"plugin3"},
|
||||
expectedErrors: []advisor.CheckV0alpha1StatusReportErrors{},
|
||||
expectedErrors: []advisor.CheckReportError{},
|
||||
},
|
||||
{
|
||||
name: "Managed plugin",
|
||||
@@ -111,7 +111,7 @@ func TestRun(t *testing.T) {
|
||||
"plugin4": {Version: "1.1.0"},
|
||||
},
|
||||
pluginManaged: []string{"plugin4"},
|
||||
expectedErrors: []advisor.CheckV0alpha1StatusReportErrors{},
|
||||
expectedErrors: []advisor.CheckReportError{},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user