Plugins: Remove plugin dependency version (#103728)

remove plugin dependency version
This commit is contained in:
Will Browne
2025-04-10 15:02:05 +01:00
committed by GitHub
parent a255ae6b0b
commit a1b792b1f5
10 changed files with 21 additions and 28 deletions

View File

@ -191,10 +191,6 @@
}, },
"name": { "name": {
"type": "string" "type": "string"
},
"version": {
"type": "string",
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$"
} }
} }
} }

View File

@ -125,7 +125,7 @@ func doInstallPlugin(ctx context.Context, pluginID, version string, o pluginInst
if p, ok := services.PluginVersionInstalled(pluginID, version, o.pluginDir); ok { if p, ok := services.PluginVersionInstalled(pluginID, version, o.pluginDir); ok {
services.Logger.Successf("Plugin %s v%s already installed.", pluginID, version) services.Logger.Successf("Plugin %s v%s already installed.", pluginID, version)
for _, depP := range p.JSONData.Dependencies.Plugins { for _, depP := range p.JSONData.Dependencies.Plugins {
if err := doInstallPlugin(ctx, depP.ID, depP.Version, o, installing); err != nil { if err := doInstallPlugin(ctx, depP.ID, "", o, installing); err != nil {
return err return err
} }
} }
@ -159,7 +159,7 @@ func doInstallPlugin(ctx context.Context, pluginID, version string, o pluginInst
if p, ok := services.PluginVersionInstalled(pluginID, archiveInfo.Version, o.pluginDir); ok { if p, ok := services.PluginVersionInstalled(pluginID, archiveInfo.Version, o.pluginDir); ok {
services.Logger.Successf("Plugin %s v%s already installed.", pluginID, archiveInfo.Version) services.Logger.Successf("Plugin %s v%s already installed.", pluginID, archiveInfo.Version)
for _, depP := range p.JSONData.Dependencies.Plugins { for _, depP := range p.JSONData.Dependencies.Plugins {
if err = doInstallPlugin(ctx, depP.ID, depP.Version, o, installing); err != nil { if err = doInstallPlugin(ctx, depP.ID, "", o, installing); err != nil {
return err return err
} }
} }
@ -179,7 +179,7 @@ func doInstallPlugin(ctx context.Context, pluginID, version string, o pluginInst
for _, dep := range extractedArchive.Dependencies { for _, dep := range extractedArchive.Dependencies {
services.Logger.Infof("Fetching %s dependency %s...", pluginID, dep.ID) services.Logger.Infof("Fetching %s dependency %s...", pluginID, dep.ID)
err = doInstallPlugin(ctx, dep.ID, dep.Version, pluginInstallOpts{ err = doInstallPlugin(ctx, dep.ID, "", pluginInstallOpts{
insecure: o.insecure, insecure: o.insecure,
repoURL: o.repoURL, repoURL: o.repoURL,
pluginDir: o.pluginDir, pluginDir: o.pluginDir,

View File

@ -68,7 +68,7 @@ func (m *PluginInstaller) Add(ctx context.Context, pluginID, version string, opt
for _, dep := range archive.Dependencies { for _, dep := range archive.Dependencies {
m.log.Info(fmt.Sprintf("Fetching %s dependency %s...", pluginID, dep.ID)) m.log.Info(fmt.Sprintf("Fetching %s dependency %s...", pluginID, dep.ID))
err = m.Add(ctx, dep.ID, dep.Version, opts) err = m.Add(ctx, dep.ID, "", opts)
if err != nil { if err != nil {
var dupeErr plugins.DuplicateError var dupeErr plugins.DuplicateError
if errors.As(err, &dupeErr) { if errors.As(err, &dupeErr) {

View File

@ -179,8 +179,8 @@ func TestFinder_Find(t *testing.T) {
Dependencies: plugins.Dependencies{ Dependencies: plugins.Dependencies{
GrafanaVersion: "3.x.x", GrafanaVersion: "3.x.x",
Plugins: []plugins.Dependency{ Plugins: []plugins.Dependency{
{ID: "graphite", Type: "datasource", Name: "Graphite", Version: "1.0.0"}, {ID: "graphite", Type: "datasource", Name: "Graphite"},
{ID: "graph", Type: "panel", Name: "Graph", Version: "1.0.0"}, {ID: "graph", Type: "panel", Name: "Graph"},
}, },
Extensions: plugins.ExtensionsDependencies{ Extensions: plugins.ExtensionsDependencies{
ExposedComponents: []string{}, ExposedComponents: []string{},

View File

@ -166,8 +166,8 @@ func TestLoader_Load(t *testing.T) {
Dependencies: plugins.Dependencies{ Dependencies: plugins.Dependencies{
GrafanaVersion: "3.x.x", GrafanaVersion: "3.x.x",
Plugins: []plugins.Dependency{ Plugins: []plugins.Dependency{
{Type: "datasource", ID: "graphite", Name: "Graphite", Version: "1.0.0"}, {Type: "datasource", ID: "graphite", Name: "Graphite"},
{Type: "panel", ID: "graph", Name: "Graph", Version: "1.0.0"}, {Type: "panel", ID: "graph", Name: "Graph"},
}, },
Extensions: plugins.ExtensionsDependencies{ Extensions: plugins.ExtensionsDependencies{
ExposedComponents: []string{}, ExposedComponents: []string{},

View File

@ -174,10 +174,9 @@ func (e Includes) RequiresRBACAction() bool {
} }
type Dependency struct { type Dependency struct {
ID string `json:"id"` ID string `json:"id"`
Type string `json:"type"` Type string `json:"type"`
Name string `json:"name"` Name string `json:"name"`
Version string `json:"version"`
} }
type BuildInfo struct { type BuildInfo struct {

View File

@ -64,8 +64,8 @@ func Test_ReadPluginJSON(t *testing.T) {
Dependencies: Dependencies{ Dependencies: Dependencies{
GrafanaVersion: "3.x.x", GrafanaVersion: "3.x.x",
Plugins: []Dependency{ Plugins: []Dependency{
{Type: "datasource", ID: "graphite", Name: "Graphite", Version: "1.0.0"}, {Type: "datasource", ID: "graphite", Name: "Graphite"},
{Type: "panel", ID: "graph", Name: "Graph", Version: "1.0.0"}, {Type: "panel", ID: "graph", Name: "Graph"},
}, },
Extensions: ExtensionsDependencies{ Extensions: ExtensionsDependencies{
ExposedComponents: []string{}, ExposedComponents: []string{},

View File

@ -53,8 +53,7 @@ func (fs *FS) Extract(ctx context.Context, pluginID string, dirNameFunc DirNameG
deps := make([]*Dependency, 0, len(pluginJSON.Dependencies.Plugins)) deps := make([]*Dependency, 0, len(pluginJSON.Dependencies.Plugins))
for _, plugin := range pluginJSON.Dependencies.Plugins { for _, plugin := range pluginJSON.Dependencies.Plugins {
deps = append(deps, &Dependency{ deps = append(deps, &Dependency{
ID: plugin.ID, ID: plugin.ID,
Version: plugin.Version,
}) })
} }

View File

@ -18,6 +18,5 @@ type ExtractedPluginArchive struct {
} }
type Dependency struct { type Dependency struct {
ID string ID string
Version string
} }

View File

@ -165,8 +165,8 @@ func TestLoader_Load(t *testing.T) {
Dependencies: plugins.Dependencies{ Dependencies: plugins.Dependencies{
GrafanaVersion: "3.x.x", GrafanaVersion: "3.x.x",
Plugins: []plugins.Dependency{ Plugins: []plugins.Dependency{
{Type: "datasource", ID: "graphite", Name: "Graphite", Version: "1.0.0"}, {Type: "datasource", ID: "graphite", Name: "Graphite"},
{Type: "panel", ID: "graph", Name: "Graph", Version: "1.0.0"}, {Type: "panel", ID: "graph", Name: "Graph"},
}, },
Extensions: plugins.ExtensionsDependencies{ Extensions: plugins.ExtensionsDependencies{
ExposedComponents: []string{}, ExposedComponents: []string{},
@ -979,8 +979,8 @@ func TestLoader_Load_DuplicatePlugins(t *testing.T) {
Dependencies: plugins.Dependencies{ Dependencies: plugins.Dependencies{
GrafanaVersion: "3.x.x", GrafanaVersion: "3.x.x",
Plugins: []plugins.Dependency{ Plugins: []plugins.Dependency{
{Type: "datasource", ID: "graphite", Name: "Graphite", Version: "1.0.0"}, {Type: "datasource", ID: "graphite", Name: "Graphite"},
{Type: "panel", ID: "graph", Name: "Graph", Version: "1.0.0"}, {Type: "panel", ID: "graph", Name: "Graph"},
}, },
Extensions: plugins.ExtensionsDependencies{ Extensions: plugins.ExtensionsDependencies{
ExposedComponents: []string{}, ExposedComponents: []string{},
@ -1071,8 +1071,8 @@ func TestLoader_Load_SkipUninitializedPlugins(t *testing.T) {
Dependencies: plugins.Dependencies{ Dependencies: plugins.Dependencies{
GrafanaVersion: "3.x.x", GrafanaVersion: "3.x.x",
Plugins: []plugins.Dependency{ Plugins: []plugins.Dependency{
{Type: "datasource", ID: "graphite", Name: "Graphite", Version: "1.0.0"}, {Type: "datasource", ID: "graphite", Name: "Graphite"},
{Type: "panel", ID: "graph", Name: "Graph", Version: "1.0.0"}, {Type: "panel", ID: "graph", Name: "Graph"},
}, },
Extensions: plugins.ExtensionsDependencies{ Extensions: plugins.ExtensionsDependencies{
ExposedComponents: []string{}, ExposedComponents: []string{},