Advisor: Allow to retry checks for a single element (#104279)
This commit is contained in:
@@ -61,6 +61,14 @@ func (c *check) Items(ctx context.Context) ([]any, error) {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (c *check) Item(ctx context.Context, id string) (any, error) {
|
||||
p, exists := c.PluginStore.Plugin(ctx, id)
|
||||
if !exists {
|
||||
return nil, fmt.Errorf("plugin %s not found", id)
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func (c *check) Steps() []checks.Step {
|
||||
return []checks.Step{
|
||||
&deprecationStep{
|
||||
@@ -118,6 +126,7 @@ func (s *deprecationStep) Run(ctx context.Context, _ *advisor.CheckSpec, it any)
|
||||
return checks.NewCheckReportFailure(
|
||||
advisor.CheckReportFailureSeverityHigh,
|
||||
s.ID(),
|
||||
p.Name,
|
||||
p.ID,
|
||||
[]advisor.CheckErrorLink{
|
||||
{
|
||||
@@ -190,6 +199,7 @@ func (s *updateStep) Run(ctx context.Context, _ *advisor.CheckSpec, i any) (*adv
|
||||
return checks.NewCheckReportFailure(
|
||||
advisor.CheckReportFailureSeverityLow,
|
||||
s.ID(),
|
||||
p.Name,
|
||||
p.ID,
|
||||
[]advisor.CheckErrorLink{
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ func TestRun(t *testing.T) {
|
||||
{
|
||||
name: "Deprecated plugin",
|
||||
plugins: []pluginstore.Plugin{
|
||||
{JSONData: plugins.JSONData{ID: "plugin1", Info: plugins.Info{Version: "1.0.0"}}},
|
||||
{JSONData: plugins.JSONData{ID: "plugin1", Name: "Plugin 1", Info: plugins.Info{Version: "1.0.0"}}},
|
||||
},
|
||||
pluginInfo: map[string]*repo.PluginInfo{
|
||||
"plugin1": {Status: "deprecated"},
|
||||
@@ -45,7 +45,8 @@ func TestRun(t *testing.T) {
|
||||
{
|
||||
Severity: advisor.CheckReportFailureSeverityHigh,
|
||||
StepID: "deprecation",
|
||||
Item: "plugin1",
|
||||
Item: "Plugin 1",
|
||||
ItemID: "plugin1",
|
||||
Links: []advisor.CheckErrorLink{
|
||||
{
|
||||
Url: "/plugins/plugin1",
|
||||
@@ -58,7 +59,7 @@ func TestRun(t *testing.T) {
|
||||
{
|
||||
name: "Plugin with update",
|
||||
plugins: []pluginstore.Plugin{
|
||||
{JSONData: plugins.JSONData{ID: "plugin2", Info: plugins.Info{Version: "1.0.0"}}},
|
||||
{JSONData: plugins.JSONData{ID: "plugin2", Name: "Plugin 2", Info: plugins.Info{Version: "1.0.0"}}},
|
||||
},
|
||||
pluginInfo: map[string]*repo.PluginInfo{
|
||||
"plugin2": {Status: "active"},
|
||||
@@ -70,7 +71,8 @@ func TestRun(t *testing.T) {
|
||||
{
|
||||
Severity: advisor.CheckReportFailureSeverityLow,
|
||||
StepID: "update",
|
||||
Item: "plugin2",
|
||||
Item: "Plugin 2",
|
||||
ItemID: "plugin2",
|
||||
Links: []advisor.CheckErrorLink{
|
||||
{
|
||||
Url: "/plugins/plugin2?page=version-history",
|
||||
@@ -83,7 +85,7 @@ func TestRun(t *testing.T) {
|
||||
{
|
||||
name: "Plugin with update (non semver)",
|
||||
plugins: []pluginstore.Plugin{
|
||||
{JSONData: plugins.JSONData{ID: "plugin2", Info: plugins.Info{Version: "alpha"}}},
|
||||
{JSONData: plugins.JSONData{ID: "plugin2", Name: "Plugin 2", Info: plugins.Info{Version: "alpha"}}},
|
||||
},
|
||||
pluginInfo: map[string]*repo.PluginInfo{
|
||||
"plugin2": {Status: "active"},
|
||||
@@ -95,7 +97,8 @@ func TestRun(t *testing.T) {
|
||||
{
|
||||
Severity: advisor.CheckReportFailureSeverityLow,
|
||||
StepID: "update",
|
||||
Item: "plugin2",
|
||||
Item: "Plugin 2",
|
||||
ItemID: "plugin2",
|
||||
Links: []advisor.CheckErrorLink{
|
||||
{
|
||||
Url: "/plugins/plugin2?page=version-history",
|
||||
@@ -108,7 +111,7 @@ func TestRun(t *testing.T) {
|
||||
{
|
||||
name: "Plugin pinned",
|
||||
plugins: []pluginstore.Plugin{
|
||||
{JSONData: plugins.JSONData{ID: "plugin3", Info: plugins.Info{Version: "1.0.0"}}},
|
||||
{JSONData: plugins.JSONData{ID: "plugin3", Name: "Plugin 3", Info: plugins.Info{Version: "1.0.0"}}},
|
||||
},
|
||||
pluginInfo: map[string]*repo.PluginInfo{
|
||||
"plugin3": {Status: "active"},
|
||||
@@ -122,7 +125,7 @@ func TestRun(t *testing.T) {
|
||||
{
|
||||
name: "Managed plugin",
|
||||
plugins: []pluginstore.Plugin{
|
||||
{JSONData: plugins.JSONData{ID: "plugin4", Info: plugins.Info{Version: "1.0.0"}}},
|
||||
{JSONData: plugins.JSONData{ID: "plugin4", Name: "Plugin 4", Info: plugins.Info{Version: "1.0.0"}}},
|
||||
},
|
||||
pluginInfo: map[string]*repo.PluginInfo{
|
||||
"plugin4": {Status: "active"},
|
||||
@@ -136,7 +139,7 @@ func TestRun(t *testing.T) {
|
||||
{
|
||||
name: "Provisioned plugin",
|
||||
plugins: []pluginstore.Plugin{
|
||||
{JSONData: plugins.JSONData{ID: "plugin5", Info: plugins.Info{Version: "1.0.0"}}},
|
||||
{JSONData: plugins.JSONData{ID: "plugin5", Name: "Plugin 5", Info: plugins.Info{Version: "1.0.0"}}},
|
||||
},
|
||||
pluginInfo: map[string]*repo.PluginInfo{
|
||||
"plugin5": {Status: "active"},
|
||||
|
||||
Reference in New Issue
Block a user