Chore: Remove provisional APIVersion from plugin info (#89831)
This commit is contained in:
@@ -322,10 +322,7 @@ func (s *Service) prepareInstanceSettings(ctx context.Context, settings *backend
|
||||
}
|
||||
|
||||
// When the APIVersion is set, the client must also implement AdmissionHandler
|
||||
if p.APIVersion == "" {
|
||||
if settings.APIVersion != "" {
|
||||
return nil, fmt.Errorf("invalid request apiVersion (datasource does not have one configured)")
|
||||
}
|
||||
if settings.APIVersion == "" {
|
||||
return settings, nil // NOOP
|
||||
}
|
||||
|
||||
@@ -367,7 +364,7 @@ func (s *Service) prepareInstanceSettings(ctx context.Context, settings *backend
|
||||
if err != nil {
|
||||
if errors.Is(err, plugins.ErrMethodNotImplemented) {
|
||||
return nil, errutil.Internal("plugin.unimplemented").
|
||||
Errorf("plugin (%s) with apiVersion=%s must implement ValidateAdmission", p.ID, p.APIVersion)
|
||||
Errorf("plugin (%s) with apiVersion=%s must implement ValidateAdmission", p.ID, settings.APIVersion)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
@@ -388,7 +385,7 @@ func (s *Service) prepareInstanceSettings(ctx context.Context, settings *backend
|
||||
if err != nil {
|
||||
if errors.Is(err, plugins.ErrMethodNotImplemented) {
|
||||
return nil, errutil.Internal("plugin.unimplemented").
|
||||
Errorf("plugin (%s) with apiVersion=%s must implement MutateAdmission", p.ID, p.APIVersion)
|
||||
Errorf("plugin (%s) with apiVersion=%s must implement MutateAdmission", p.ID, settings.APIVersion)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -110,10 +110,9 @@ func TestService_AddDataSource(t *testing.T) {
|
||||
dsService.pluginStore = &pluginstore.FakePluginStore{
|
||||
PluginList: []pluginstore.Plugin{{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "test",
|
||||
Type: plugins.TypeDataSource,
|
||||
Name: "test",
|
||||
APIVersion: "v0alpha1", // When a value exists in plugin.json, the callbacks will be executed
|
||||
ID: "test",
|
||||
Type: plugins.TypeDataSource,
|
||||
Name: "test",
|
||||
},
|
||||
}},
|
||||
}
|
||||
@@ -150,10 +149,9 @@ func TestService_AddDataSource(t *testing.T) {
|
||||
dsService.pluginStore = &pluginstore.FakePluginStore{
|
||||
PluginList: []pluginstore.Plugin{{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "test",
|
||||
Type: plugins.TypeDataSource,
|
||||
Name: "test",
|
||||
APIVersion: "v0alpha1", // When a value exists in plugin.json, the callbacks will be executed
|
||||
ID: "test",
|
||||
Type: plugins.TypeDataSource,
|
||||
Name: "test",
|
||||
},
|
||||
}},
|
||||
}
|
||||
@@ -200,10 +198,9 @@ func TestService_AddDataSource(t *testing.T) {
|
||||
dsService.pluginStore = &pluginstore.FakePluginStore{
|
||||
PluginList: []pluginstore.Plugin{{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "test",
|
||||
Type: plugins.TypeDataSource,
|
||||
Name: "test",
|
||||
APIVersion: "v0alpha1", // When a value exists in plugin.json, the callbacks will be executed
|
||||
ID: "test",
|
||||
Type: plugins.TypeDataSource,
|
||||
Name: "test",
|
||||
},
|
||||
}},
|
||||
}
|
||||
@@ -491,10 +488,9 @@ func TestService_UpdateDataSource(t *testing.T) {
|
||||
dsService.pluginStore = &pluginstore.FakePluginStore{
|
||||
PluginList: []pluginstore.Plugin{{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: "test",
|
||||
Type: plugins.TypeDataSource,
|
||||
Name: "test",
|
||||
APIVersion: "v0alpha1", // When a value exists in plugin.json, the callbacks will be executed
|
||||
ID: "test",
|
||||
Type: plugins.TypeDataSource,
|
||||
Name: "test",
|
||||
},
|
||||
}},
|
||||
}
|
||||
|
||||
@@ -54,7 +54,6 @@ func ProvideValidationStage(cfg *config.PluginManagementCfg, sv signature.Valida
|
||||
SignatureValidationStep(sv),
|
||||
validation.ModuleJSValidationStep(),
|
||||
validation.AngularDetectionStep(cfg, ai),
|
||||
validation.APIVersionValidationStep(),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ func (p *BaseProvider) GetBasePluginContext(ctx context.Context, plugin pluginst
|
||||
pCtx := backend.PluginContext{
|
||||
PluginID: plugin.ID,
|
||||
PluginVersion: plugin.Info.Version,
|
||||
APIVersion: plugin.APIVersion,
|
||||
}
|
||||
if user != nil && !user.IsNil() {
|
||||
pCtx.OrgID = user.GetOrgID()
|
||||
|
||||
@@ -26,17 +26,15 @@ import (
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
const (
|
||||
pluginID = "plugin-id"
|
||||
alias = "alias"
|
||||
apiVersion = "v0alpha1"
|
||||
pluginID = "plugin-id"
|
||||
alias = "alias"
|
||||
)
|
||||
|
||||
preg := registry.NewInMemory()
|
||||
require.NoError(t, preg.Add(context.Background(), &plugins.Plugin{
|
||||
JSONData: plugins.JSONData{
|
||||
ID: pluginID,
|
||||
AliasIDs: []string{alias},
|
||||
APIVersion: apiVersion,
|
||||
ID: pluginID,
|
||||
AliasIDs: []string{alias},
|
||||
},
|
||||
}))
|
||||
|
||||
@@ -61,7 +59,6 @@ func TestGet(t *testing.T) {
|
||||
pCtx, err := pcp.Get(context.Background(), tc.input, identity, identity.OrgID)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, pluginID, pCtx.PluginID)
|
||||
require.Equal(t, apiVersion, pCtx.APIVersion)
|
||||
require.NotNil(t, pCtx.GrafanaConfig)
|
||||
})
|
||||
|
||||
@@ -75,7 +72,6 @@ func TestGet(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, pluginID, pCtx.PluginID)
|
||||
require.Equal(t, apiVersion, pCtx.APIVersion)
|
||||
require.NotNil(t, pCtx.GrafanaConfig)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user