MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / ValidatePluginVersions

Function ValidatePluginVersions

internal/pluginstore/registry.go:232–259  ·  view source on GitHub ↗
(plugin Plugin)

Source from the content-addressed store, hash-verified

230}
231
232func ValidatePluginVersions(plugin Plugin) error {
233 if len(plugin.Versions) == 0 {
234 return nil
235 }
236 seen := make(map[string]struct{}, len(plugin.Versions))
237 for index, version := range plugin.Versions {
238 version.Version = normalizeVersion(version.Version)
239 if !validPluginVersion(version.Version) {
240 return fmt.Errorf("versions[%d]: invalid plugin version %q", index, version.Version)
241 }
242 if _, exists := seen[version.Version]; exists {
243 return fmt.Errorf("versions[%d]: duplicate plugin version %q", index, version.Version)
244 }
245 seen[version.Version] = struct{}{}
246 installType := strings.ToLower(strings.TrimSpace(version.Install.Type))
247 if installType == "" {
248 installType = PluginInstallType(plugin)
249 version.Install.Type = installType
250 }
251 if installType != PluginInstallType(plugin) {
252 return fmt.Errorf("versions[%d]: install type %q does not match plugin install type %q", index, installType, PluginInstallType(plugin))
253 }
254 if errPlan := ValidateInstallPlan(version.Install); errPlan != nil {
255 return fmt.Errorf("versions[%d]: %w", index, errPlan)
256 }
257 }
258 return nil
259}
260
261func PluginInstallType(plugin Plugin) string {
262 installType := strings.ToLower(strings.TrimSpace(plugin.Install.Type))

Callers 1

ValidatePluginFunction · 0.85

Calls 4

normalizeVersionFunction · 0.85
ValidateInstallPlanFunction · 0.85
validPluginVersionFunction · 0.70
PluginInstallTypeFunction · 0.70

Tested by

no test coverage detected