From 62b58f4cbb3b0a42e8c1ae67ae241efc41ec30ae Mon Sep 17 00:00:00 2001 From: "David J. Allen" Date: Thu, 4 Sep 2025 10:08:09 -0600 Subject: [PATCH] feat: change how incorrect profiles and plugins behave --- pkg/service/constants.go | 3 +-- pkg/service/routes.go | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/pkg/service/constants.go b/pkg/service/constants.go index b94b34a..649fa86 100644 --- a/pkg/service/constants.go +++ b/pkg/service/constants.go @@ -24,8 +24,7 @@ const ( Name: {{ makeshift.plugin.name }} Version: {{ makeshift.plugin.version }} Description: {{ makeshift.plugin.description }} - Author: {{ makeshift.plugin.metadata.name }} ({{ makeshift.plugin.metadata.email }}) - + Author: {{ makeshift.plugin.metadata }} Profile Information: ID: {{ makeshift.profiles.default.id }} Description: {{ makeshift.profiles.default.description }} diff --git a/pkg/service/routes.go b/pkg/service/routes.go index 5f552d1..1cbfc7f 100644 --- a/pkg/service/routes.go +++ b/pkg/service/routes.go @@ -15,6 +15,7 @@ import ( "git.towk2.me/towk/makeshift/internal/kwargs" makeshift "git.towk2.me/towk/makeshift/pkg" "git.towk2.me/towk/makeshift/pkg/storage" + "git.towk2.me/towk/makeshift/pkg/util" "github.com/go-chi/chi/v5" "github.com/rs/zerolog/log" ) @@ -56,7 +57,11 @@ func (s *Service) Download() http.HandlerFunc { // prepare profiles errs = s.loadProfiles(profileIDs, store, errs) if len(errs) > 0 { - log.Error().Errs("errs", errs).Msg("errors occurred loading profiles") + log.Error(). + Errs("errs", errs). + Msg("errors occurred loading profiles") + err = util.FormatErrors("failed to load plugins", "", errs) + http.Error(w, err.Error(), http.StatusInternalServerError) errs = []error{} } @@ -90,8 +95,13 @@ func (s *Service) Download() http.HandlerFunc { // prepare plugins hooks, errs = s.loadPlugins(pluginNames, store, pluginArgs, errs) if len(errs) > 0 { - log.Error().Errs("errs", errs).Msg("errors occurred loading plugins") + log.Error(). + Errs("errs", errs). + Msg("errors occurred loading plugins") + err = util.FormatErrors("failed to load plugins", "", errs) + http.Error(w, err.Error(), http.StatusInternalServerError) errs = []error{} + return } // create an archive of the directory, run hooks, and download @@ -132,12 +142,16 @@ func (s *Service) Download() http.HandlerFunc { } // prepare plugins - store.Set("file", contents) hooks, errs = s.loadPlugins(pluginNames, store, nil, errs) if len(errs) > 0 { - log.Error().Errs("errs", errs).Msg("errors occurred loading plugins") + log.Error(). + Errs("errs", errs). + Msg("errors occurred loading plugins") + err = util.FormatErrors("failed to load plugins", "", errs) + http.Error(w, err.Error(), http.StatusInternalServerError) errs = []error{} + return } if len(hooks) > 0 { // run pre-hooks to modify the contents of the file before archiving