| 45 | } |
| 46 | |
| 47 | func (c Client) Install(ctx context.Context, plugin Plugin, options InstallOptions) (InstallResult, error) { |
| 48 | if errValidate := ValidatePlugin(plugin); errValidate != nil { |
| 49 | return InstallResult{}, errValidate |
| 50 | } |
| 51 | options = normalizeInstallOptions(options) |
| 52 | if PluginInstallType(plugin) == InstallTypeDirect { |
| 53 | plugin.Version = normalizeVersion(plugin.Version) |
| 54 | return c.InstallDirect(ctx, plugin, plugin.Install, options) |
| 55 | } |
| 56 | release, errRelease := c.FetchLatestRelease(ctx, plugin) |
| 57 | if errRelease != nil { |
| 58 | return InstallResult{}, errRelease |
| 59 | } |
| 60 | latestVersion, errVersion := ReleaseVersion(release) |
| 61 | if errVersion != nil { |
| 62 | return InstallResult{}, errVersion |
| 63 | } |
| 64 | plugin.Version = latestVersion |
| 65 | return c.installRelease(ctx, plugin, release, latestVersion, options) |
| 66 | } |
| 67 | |
| 68 | func (c Client) InstallManifest(ctx context.Context, manifest Manifest, options InstallOptions) (InstallResult, error) { |
| 69 | if errValidate := manifest.Validate(); errValidate != nil { |