Compare commits
No commits in common. "f917d2b6f85a084d576161e2b39a49a79a64cc39" and "df8730463e41461caf63e1ed9844d7e74106b717" have entirely different histories.
f917d2b6f8
...
df8730463e
2 changed files with 11 additions and 12 deletions
|
|
@ -158,6 +158,9 @@ var downloadProfileCmd = &cobra.Command{
|
||||||
`,
|
`,
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Short: "Download a profile",
|
Short: "Download a profile",
|
||||||
|
// PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
// setenv(cmd, "host", "MAKESHIFT_HOST")
|
||||||
|
// },
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var (
|
var (
|
||||||
host, _ = cmd.Flags().GetString("host")
|
host, _ = cmd.Flags().GetString("host")
|
||||||
|
|
@ -214,6 +217,9 @@ var downloadPluginCmd = &cobra.Command{
|
||||||
`,
|
`,
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Short: "Download a plugin",
|
Short: "Download a plugin",
|
||||||
|
// PreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
// setenv(cmd, "host", "MAKESHIFT_HOST")
|
||||||
|
// },
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
var (
|
var (
|
||||||
host, _ = cmd.Flags().GetString("host")
|
host, _ = cmd.Flags().GetString("host")
|
||||||
|
|
@ -225,14 +231,9 @@ var downloadPluginCmd = &cobra.Command{
|
||||||
body []byte
|
body []byte
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
log.Debug().
|
|
||||||
Str("host", host).
|
|
||||||
Str("output", outputPath).
|
|
||||||
Send()
|
|
||||||
|
|
||||||
for _, pluginName := range args {
|
for _, pluginName := range args {
|
||||||
query = fmt.Sprintf("/plugin/%s", pluginName)
|
|
||||||
|
query = fmt.Sprintf("/profile/%s", pluginName)
|
||||||
res, body, err = c.MakeRequest(client.HTTPEnvelope{
|
res, body, err = c.MakeRequest(client.HTTPEnvelope{
|
||||||
Path: query,
|
Path: query,
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
|
|
@ -240,7 +241,6 @@ var downloadPluginCmd = &cobra.Command{
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).
|
log.Error().Err(err).
|
||||||
Str("host", host).
|
Str("host", host).
|
||||||
Str("query", query).
|
|
||||||
Msg("failed to make request")
|
Msg("failed to make request")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
makeshift "git.towk2.me/towk/makeshift/pkg"
|
makeshift "git.towk2.me/towk/makeshift/pkg"
|
||||||
"github.com/go-chi/chi/v5"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Service) ListPlugins() http.HandlerFunc {
|
func (s *Service) ListPlugins() http.HandlerFunc {
|
||||||
|
|
@ -42,14 +42,13 @@ func (s *Service) ListPlugins() http.HandlerFunc {
|
||||||
func (s *Service) GetPlugin() http.HandlerFunc {
|
func (s *Service) GetPlugin() http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
var (
|
var (
|
||||||
pluginName = chi.URLParam(r, "name")
|
pluginName = strings.TrimPrefix(r.URL.Path, "/plugin")
|
||||||
path = s.PathForPluginWithName(pluginName)
|
|
||||||
plugin makeshift.Plugin
|
plugin makeshift.Plugin
|
||||||
body []byte
|
body []byte
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
plugin, err = LoadPluginFromFile(path)
|
plugin, err = LoadPluginFromFile(pluginName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue