(plugin Plugin, id string, version string)
| 209 | } |
| 210 | |
| 211 | func 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 | |
| 243 | func InstallArchive(archiveData []byte, plugin Plugin, options InstallOptions) (InstallResult, error) { |
| 244 | options = normalizeInstallOptions(options) |
no test coverage detected