From ce3a8ed750f4fdcbdbf4bd8e58d7d15982ab4981 Mon Sep 17 00:00:00 2001 From: George MacRorie Date: Wed, 20 Nov 2024 10:23:25 +0000 Subject: [PATCH] fix(ui): call correct promote endpoint --- server.go | 10 ++++++++++ ui/package.json | 2 +- ui/src/services/api.ts | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/server.go b/server.go index 2e8dd7b..d8e3f0d 100644 --- a/server.go +++ b/server.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "io/fs" + "log/slog" "net/http" "github.com/get-glu/glu/pkg/core" @@ -159,6 +160,7 @@ func (s *Server) listPipelines(w http.ResponseWriter, r *http.Request) { for _, pipeline := range s.system.pipelines { response, err := s.createPipelineResponse(ctx, pipeline) if err != nil { + slog.Error("building pipeline response", "path", r.URL.Path, "error", err) http.Error(w, err.Error(), http.StatusInternalServerError) return } @@ -169,6 +171,7 @@ func (s *Server) listPipelines(w http.ResponseWriter, r *http.Request) { if err := json.NewEncoder(w).Encode(listPipelinesResponse{ Pipelines: pipelineResponses, }); err != nil { + slog.Error("encoding pipeline", "path", r.URL.Path, "error", err) http.Error(w, err.Error(), http.StatusInternalServerError) return } @@ -179,12 +182,14 @@ func (s *Server) getPipeline(w http.ResponseWriter, r *http.Request) { pipeline, err := s.system.GetPipeline(chi.URLParam(r, "pipeline")) if err != nil { + slog.Debug("resource not found", "path", r.URL.Path, "error", err) http.Error(w, err.Error(), http.StatusNotFound) return } response, err := s.createPipelineResponse(ctx, pipeline) if err != nil { + slog.Error("building pipeline response", "path", r.URL.Path, "error", err) http.Error(w, err.Error(), http.StatusInternalServerError) return } @@ -204,6 +209,7 @@ func (s *Server) getPhase(w http.ResponseWriter, r *http.Request) { if err != nil { status := http.StatusInternalServerError if errors.Is(err, core.ErrNotFound) { + slog.Debug("resource not found", "path", r.URL.Path, "error", err) status = http.StatusNotFound } @@ -221,6 +227,7 @@ func (s *Server) getPhase(w http.ResponseWriter, r *http.Request) { response.Value = v if err := json.NewEncoder(w).Encode(response); err != nil { + slog.Error("encoding response", "path", r.URL.Path, "error", err) http.Error(w, err.Error(), http.StatusInternalServerError) return } @@ -229,6 +236,7 @@ func (s *Server) getPhase(w http.ResponseWriter, r *http.Request) { func (s *Server) promotePhase(w http.ResponseWriter, r *http.Request) { pipeline, err := s.system.GetPipeline(chi.URLParam(r, "pipeline")) if err != nil { + slog.Debug("resource not found", "path", r.URL.Path, "error", err) http.Error(w, err.Error(), http.StatusNotFound) return } @@ -238,6 +246,7 @@ func (s *Server) promotePhase(w http.ResponseWriter, r *http.Request) { if err != nil { status := http.StatusInternalServerError if errors.Is(err, core.ErrNotFound) { + slog.Debug("resource not found", "path", r.URL.Path, "error", err) status = http.StatusNotFound } @@ -246,6 +255,7 @@ func (s *Server) promotePhase(w http.ResponseWriter, r *http.Request) { } if err := phase.Promote(r.Context()); err != nil { + slog.Error("performing promotion", "path", r.URL.Path, "error", err) http.Error(w, err.Error(), http.StatusInternalServerError) return } diff --git a/ui/package.json b/ui/package.json index ee23bf6..1682ca9 100644 --- a/ui/package.json +++ b/ui/package.json @@ -5,7 +5,7 @@ "source": "src/index.html", "scripts": { "start": "parcel --no-cache", - "build": "parcel build", + "build": "parcel build --no-cache", "lint": "eslint --fix .", "format": "prettier --write ." }, diff --git a/ui/src/services/api.ts b/ui/src/services/api.ts index 3d767ae..01aee4d 100644 --- a/ui/src/services/api.ts +++ b/ui/src/services/api.ts @@ -17,7 +17,7 @@ export const listPipelines = async (): Promise => { }; export const promotePhase = async (pipeline: string, phase: string) => { - const response = await api.post(`/pipelines/${pipeline}/phase/${phase}/promote`); + const response = await api.post(`/pipelines/${pipeline}/phases/${phase}/promote`); if (response.status !== 200) { throw new Error(`unexpected status ${response.status}`); }