chore: add additional logging to plugin installer

Signed-off-by: Evans Mungai <mbuevans@gmail.com>
pull/31249/head
Evans Mungai 3 weeks ago
parent 78cf5470d1
commit 3d23230ef8
No known key found for this signature in database
GPG Key ID: BBEB812143DD14E1

@ -18,6 +18,7 @@ package installer
import ( import (
"errors" "errors"
"fmt" "fmt"
"log/slog"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
@ -79,6 +80,7 @@ func InstallWithOptions(i Installer, opts Options) (*VerificationResult, error)
return nil, err return nil, err
} }
if _, pathErr := os.Stat(i.Path()); !os.IsNotExist(pathErr) { if _, pathErr := os.Stat(i.Path()); !os.IsNotExist(pathErr) {
slog.Warn("plugin already exists", "path", i.Path(), slog.Any("error", pathErr))
return nil, errors.New("plugin already exists") return nil, errors.New("plugin already exists")
} }
@ -130,6 +132,7 @@ func InstallWithOptions(i Installer, opts Options) (*VerificationResult, error)
// Update updates a plugin. // Update updates a plugin.
func Update(i Installer) error { func Update(i Installer) error {
if _, pathErr := os.Stat(i.Path()); os.IsNotExist(pathErr) { if _, pathErr := os.Stat(i.Path()); os.IsNotExist(pathErr) {
slog.Warn("plugin does not exist", "path", i.Path(), slog.Any("error", pathErr))
return errors.New("plugin does not exist") return errors.New("plugin does not exist")
} }
return i.Update() return i.Update()
@ -154,6 +157,7 @@ func NewForSource(source, version string) (Installer, error) {
func FindSource(location string) (Installer, error) { func FindSource(location string) (Installer, error) {
installer, err := existingVCSRepo(location) installer, err := existingVCSRepo(location)
if err != nil && err.Error() == "Cannot detect VCS" { if err != nil && err.Error() == "Cannot detect VCS" {
slog.Warn("cannot get information about plugin source", "location", location, slog.Any("error", err))
return installer, errors.New("cannot get information about plugin source") return installer, errors.New("cannot get information about plugin source")
} }
return installer, err return installer, err

Loading…
Cancel
Save