feat: change how incorrect profiles and plugins behave
This commit is contained in:
parent
215dbe8eff
commit
62b58f4cbb
2 changed files with 19 additions and 6 deletions
|
|
@ -24,8 +24,7 @@ const (
|
||||||
Name: {{ makeshift.plugin.name }}
|
Name: {{ makeshift.plugin.name }}
|
||||||
Version: {{ makeshift.plugin.version }}
|
Version: {{ makeshift.plugin.version }}
|
||||||
Description: {{ makeshift.plugin.description }}
|
Description: {{ makeshift.plugin.description }}
|
||||||
Author: {{ makeshift.plugin.metadata.name }} ({{ makeshift.plugin.metadata.email }})
|
Author: {{ makeshift.plugin.metadata }}
|
||||||
|
|
||||||
Profile Information:
|
Profile Information:
|
||||||
ID: {{ makeshift.profiles.default.id }}
|
ID: {{ makeshift.profiles.default.id }}
|
||||||
Description: {{ makeshift.profiles.default.description }}
|
Description: {{ makeshift.profiles.default.description }}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"git.towk2.me/towk/makeshift/internal/kwargs"
|
"git.towk2.me/towk/makeshift/internal/kwargs"
|
||||||
makeshift "git.towk2.me/towk/makeshift/pkg"
|
makeshift "git.towk2.me/towk/makeshift/pkg"
|
||||||
"git.towk2.me/towk/makeshift/pkg/storage"
|
"git.towk2.me/towk/makeshift/pkg/storage"
|
||||||
|
"git.towk2.me/towk/makeshift/pkg/util"
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
@ -56,7 +57,11 @@ func (s *Service) Download() http.HandlerFunc {
|
||||||
// prepare profiles
|
// prepare profiles
|
||||||
errs = s.loadProfiles(profileIDs, store, errs)
|
errs = s.loadProfiles(profileIDs, store, errs)
|
||||||
if len(errs) > 0 {
|
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{}
|
errs = []error{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,8 +95,13 @@ func (s *Service) Download() http.HandlerFunc {
|
||||||
// prepare plugins
|
// prepare plugins
|
||||||
hooks, errs = s.loadPlugins(pluginNames, store, pluginArgs, errs)
|
hooks, errs = s.loadPlugins(pluginNames, store, pluginArgs, errs)
|
||||||
if len(errs) > 0 {
|
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{}
|
errs = []error{}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// create an archive of the directory, run hooks, and download
|
// create an archive of the directory, run hooks, and download
|
||||||
|
|
@ -132,12 +142,16 @@ func (s *Service) Download() http.HandlerFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare plugins
|
// prepare plugins
|
||||||
|
|
||||||
store.Set("file", contents)
|
store.Set("file", contents)
|
||||||
hooks, errs = s.loadPlugins(pluginNames, store, nil, errs)
|
hooks, errs = s.loadPlugins(pluginNames, store, nil, errs)
|
||||||
if len(errs) > 0 {
|
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{}
|
errs = []error{}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if len(hooks) > 0 {
|
if len(hooks) > 0 {
|
||||||
// run pre-hooks to modify the contents of the file before archiving
|
// run pre-hooks to modify the contents of the file before archiving
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue