Compare commits

..

2 commits

2 changed files with 12 additions and 11 deletions

View file

@ -158,9 +158,6 @@ var downloadProfileCmd = &cobra.Command{
`,
Args: cobra.ExactArgs(1),
Short: "Download a profile",
// PreRun: func(cmd *cobra.Command, args []string) {
// setenv(cmd, "host", "MAKESHIFT_HOST")
// },
Run: func(cmd *cobra.Command, args []string) {
var (
host, _ = cmd.Flags().GetString("host")
@ -217,9 +214,6 @@ var downloadPluginCmd = &cobra.Command{
`,
Args: cobra.ExactArgs(1),
Short: "Download a plugin",
// PreRun: func(cmd *cobra.Command, args []string) {
// setenv(cmd, "host", "MAKESHIFT_HOST")
// },
Run: func(cmd *cobra.Command, args []string) {
var (
host, _ = cmd.Flags().GetString("host")
@ -231,9 +225,14 @@ var downloadPluginCmd = &cobra.Command{
body []byte
err error
)
for _, pluginName := range args {
query = fmt.Sprintf("/profile/%s", pluginName)
log.Debug().
Str("host", host).
Str("output", outputPath).
Send()
for _, pluginName := range args {
query = fmt.Sprintf("/plugin/%s", pluginName)
res, body, err = c.MakeRequest(client.HTTPEnvelope{
Path: query,
Method: http.MethodGet,
@ -241,6 +240,7 @@ var downloadPluginCmd = &cobra.Command{
if err != nil {
log.Error().Err(err).
Str("host", host).
Str("query", query).
Msg("failed to make request")
os.Exit(1)
}

View file

@ -5,9 +5,9 @@ import (
"io"
"net/http"
"os"
"strings"
makeshift "git.towk2.me/towk/makeshift/pkg"
"github.com/go-chi/chi/v5"
)
func (s *Service) ListPlugins() http.HandlerFunc {
@ -42,13 +42,14 @@ func (s *Service) ListPlugins() http.HandlerFunc {
func (s *Service) GetPlugin() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var (
pluginName = strings.TrimPrefix(r.URL.Path, "/plugin")
pluginName = chi.URLParam(r, "name")
path = s.PathForPluginWithName(pluginName)
plugin makeshift.Plugin
body []byte
err error
)
plugin, err = LoadPluginFromFile(pluginName)
plugin, err = LoadPluginFromFile(path)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return