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

Function directPluginVersion

internal/pluginstore/install.go:211–241  ·  view source on GitHub ↗
(plugin Plugin, id string, version string)

Source from the content-addressed store, hash-verified

209}
210
211func directPluginVersion(plugin Plugin, id string, version string) (Plugin, error) {
212 id = strings.TrimSpace(id)
213 version = normalizeVersion(version)
214 if normalizeVersion(plugin.Version) == version {
215 plugin.Version = version
216 plugin.Install = NormalizeInstallPlan(plugin.Install)
217 plugin.Install.Type = InstallTypeDirect
218 if errPlan := ValidateInstallPlan(plugin.Install); errPlan != nil {
219 return Plugin{}, fmt.Errorf("direct install plugin %q version %q: %w", id, version, errPlan)
220 }
221 return plugin, nil
222 }
223 for _, candidate := range plugin.Versions {
224 if normalizeVersion(candidate.Version) != version {
225 continue
226 }
227 plugin.Version = version
228 plugin.Install = NormalizeInstallPlan(candidate.Install)
229 if plugin.Install.Type == "" {
230 plugin.Install.Type = InstallTypeDirect
231 }
232 if plugin.Install.Type != InstallTypeDirect {
233 return Plugin{}, fmt.Errorf("direct install plugin %q version %q resolved as %q", id, version, plugin.Install.Type)
234 }
235 if errPlan := ValidateInstallPlan(plugin.Install); errPlan != nil {
236 return Plugin{}, fmt.Errorf("direct install plugin %q version %q: %w", id, version, errPlan)
237 }
238 return plugin, nil
239 }
240 return Plugin{}, fmt.Errorf("direct install plugin %q version %q not found in source", id, version)
241}
242
243func InstallArchive(archiveData []byte, plugin Plugin, options InstallOptions) (InstallResult, error) {
244 options = normalizeInstallOptions(options)

Callers 1

Calls 3

normalizeVersionFunction · 0.85
NormalizeInstallPlanFunction · 0.85
ValidateInstallPlanFunction · 0.85

Tested by

no test coverage detected