(out io.Writer)
| 120 | } |
| 121 | |
| 122 | func (o *pluginInstallOptions) run(out io.Writer) error { |
| 123 | i, err := o.newInstallerForSource() |
| 124 | if err != nil { |
| 125 | return err |
| 126 | } |
| 127 | |
| 128 | // Determine if we should verify based on installer type and flags |
| 129 | shouldVerify := o.verify |
| 130 | |
| 131 | // Check if this is a local directory installation (for development) |
| 132 | if localInst, ok := i.(*installer.LocalInstaller); ok && !localInst.SupportsVerification() { |
| 133 | // Local directory installations are allowed without verification |
| 134 | shouldVerify = false |
| 135 | fmt.Fprint(out, "Installing plugin from local directory (development mode)\n") |
| 136 | } else if shouldVerify { |
| 137 | // For remote installations, check if verification is supported |
| 138 | if verifier, ok := i.(installer.Verifier); !ok || !verifier.SupportsVerification() { |
| 139 | return errors.New("plugin source does not support verification. Use --verify=false to skip verification") |
| 140 | } |
| 141 | } else { |
| 142 | // User explicitly disabled verification |
| 143 | fmt.Fprint(out, "WARNING: Skipping plugin signature verification\n") |
| 144 | } |
| 145 | |
| 146 | // Set up installation options |
| 147 | opts := installer.Options{ |
| 148 | Verify: shouldVerify, |
| 149 | Keyring: o.keyring, |
| 150 | } |
| 151 | |
| 152 | // If verify is requested, show verification output |
| 153 | if shouldVerify { |
| 154 | fmt.Fprint(out, "Verifying plugin signature...\n") |
| 155 | } |
| 156 | |
| 157 | // Install the plugin with options |
| 158 | verifyResult, err := installer.InstallWithOptions(i, opts) |
| 159 | if err != nil { |
| 160 | return err |
| 161 | } |
| 162 | |
| 163 | // If verification was successful, show the details |
| 164 | if verifyResult != nil { |
| 165 | for _, signer := range verifyResult.SignedBy { |
| 166 | fmt.Fprintf(out, "Signed by: %s\n", signer) |
| 167 | } |
| 168 | fmt.Fprintf(out, "Using Key With Fingerprint: %s\n", verifyResult.Fingerprint) |
| 169 | fmt.Fprintf(out, "Plugin Hash Verified: %s\n", verifyResult.FileHash) |
| 170 | } |
| 171 | |
| 172 | slog.Debug("loading plugin", "path", i.Path()) |
| 173 | p, err := plugin.LoadDir(i.Path()) |
| 174 | if err != nil { |
| 175 | return fmt.Errorf("plugin is installed but unusable: %w", err) |
| 176 | } |
| 177 | |
| 178 | if err := runHook(p, plugin.Install); err != nil { |
| 179 | return err |
no test coverage detected