gateway: rename projectid to projectref
This commit is contained in:
parent
f3781c9087
commit
763d77d899
|
@ -103,13 +103,13 @@ func NewProjectReconfigHandler(logger *zap.Logger, ch *command.CommandHandler, c
|
||||||
func (h *ProjectReconfigHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h *ProjectReconfigHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
projectID, err := url.PathUnescape(vars["projectid"])
|
projectRef, err := url.PathUnescape(vars["projectref"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := h.ch.ReconfigProject(ctx, projectID); err != nil {
|
if err := h.ch.ReconfigProject(ctx, projectRef); err != nil {
|
||||||
h.log.Errorf("err: %+v", err)
|
h.log.Errorf("err: %+v", err)
|
||||||
httpError(w, err)
|
httpError(w, err)
|
||||||
return
|
return
|
||||||
|
@ -128,16 +128,16 @@ func NewDeleteProjectHandler(logger *zap.Logger, configstoreClient *csapi.Client
|
||||||
func (h *DeleteProjectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h *DeleteProjectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
projectID, err := url.PathUnescape(vars["projectid"])
|
projectRef, err := url.PathUnescape(vars["projectref"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
project, resp, err := h.configstoreClient.GetProject(ctx, projectID)
|
project, resp, err := h.configstoreClient.GetProject(ctx, projectRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if resp != nil && resp.StatusCode == http.StatusNotFound {
|
if resp != nil && resp.StatusCode == http.StatusNotFound {
|
||||||
http.Error(w, fmt.Sprintf("project with id %q doesn't exist", projectID), http.StatusNotFound)
|
http.Error(w, fmt.Sprintf("project with ref %q doesn't exist", projectRef), http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
h.log.Errorf("err: %+v", err)
|
h.log.Errorf("err: %+v", err)
|
||||||
|
@ -169,13 +169,13 @@ func NewProjectHandler(logger *zap.Logger, configstoreClient *csapi.Client) *Pro
|
||||||
func (h *ProjectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h *ProjectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
projectID, err := url.PathUnescape(vars["projectid"])
|
projectRef, err := url.PathUnescape(vars["projectref"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
project, resp, err := h.configstoreClient.GetProject(ctx, projectID)
|
project, resp, err := h.configstoreClient.GetProject(ctx, projectRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if resp != nil && resp.StatusCode == http.StatusNotFound {
|
if resp != nil && resp.StatusCode == http.StatusNotFound {
|
||||||
http.Error(w, err.Error(), http.StatusNotFound)
|
http.Error(w, err.Error(), http.StatusNotFound)
|
||||||
|
|
|
@ -93,14 +93,13 @@ func NewProjectGroupHandler(logger *zap.Logger, configstoreClient *csapi.Client)
|
||||||
func (h *ProjectGroupHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h *ProjectGroupHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
projectGroupID, err := url.PathUnescape(vars["projectgroupid"])
|
projectGroupRef, err := url.PathUnescape(vars["projectgroupref"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
h.log.Infof("projectGroupID: %s", projectGroupID)
|
|
||||||
|
|
||||||
projectGroup, resp, err := h.configstoreClient.GetProjectGroup(ctx, projectGroupID)
|
projectGroup, resp, err := h.configstoreClient.GetProjectGroup(ctx, projectGroupRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if resp != nil && resp.StatusCode == http.StatusNotFound {
|
if resp != nil && resp.StatusCode == http.StatusNotFound {
|
||||||
http.Error(w, err.Error(), http.StatusNotFound)
|
http.Error(w, err.Error(), http.StatusNotFound)
|
||||||
|
@ -131,14 +130,13 @@ func NewProjectGroupProjectsHandler(logger *zap.Logger, configstoreClient *csapi
|
||||||
func (h *ProjectGroupProjectsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h *ProjectGroupProjectsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
projectGroupID, err := url.PathUnescape(vars["projectgroupid"])
|
projectGroupRef, err := url.PathUnescape(vars["projectgroupref"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
h.log.Infof("projectGroupID: %s", projectGroupID)
|
|
||||||
|
|
||||||
csprojects, resp, err := h.configstoreClient.GetProjectGroupProjects(ctx, projectGroupID)
|
csprojects, resp, err := h.configstoreClient.GetProjectGroupProjects(ctx, projectGroupRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if resp != nil && resp.StatusCode == http.StatusNotFound {
|
if resp != nil && resp.StatusCode == http.StatusNotFound {
|
||||||
http.Error(w, err.Error(), http.StatusNotFound)
|
http.Error(w, err.Error(), http.StatusNotFound)
|
||||||
|
@ -173,14 +171,13 @@ func NewProjectGroupSubgroupsHandler(logger *zap.Logger, configstoreClient *csap
|
||||||
func (h *ProjectGroupSubgroupsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h *ProjectGroupSubgroupsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
projectGroupID, err := url.PathUnescape(vars["projectgroupid"])
|
projectGroupRef, err := url.PathUnescape(vars["projectgroupref"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
h.log.Infof("projectGroupID: %s", projectGroupID)
|
|
||||||
|
|
||||||
cssubgroups, resp, err := h.configstoreClient.GetProjectGroupSubgroups(ctx, projectGroupID)
|
cssubgroups, resp, err := h.configstoreClient.GetProjectGroupSubgroups(ctx, projectGroupRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if resp != nil && resp.StatusCode == http.StatusNotFound {
|
if resp != nil && resp.StatusCode == http.StatusNotFound {
|
||||||
http.Error(w, err.Error(), http.StatusNotFound)
|
http.Error(w, err.Error(), http.StatusNotFound)
|
||||||
|
|
|
@ -151,8 +151,8 @@ func (c *CommandHandler) SetupProject(ctx context.Context, rs *types.RemoteSourc
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CommandHandler) ReconfigProject(ctx context.Context, projectID string) error {
|
func (c *CommandHandler) ReconfigProject(ctx context.Context, projectRef string) error {
|
||||||
p, _, err := c.configstoreClient.GetProject(ctx, projectID)
|
p, _, err := c.configstoreClient.GetProject(ctx, projectRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,16 +213,16 @@ func (g *Gateway) Run(ctx context.Context) error {
|
||||||
apirouter.Handle("/logs", logsHandler).Methods("GET")
|
apirouter.Handle("/logs", logsHandler).Methods("GET")
|
||||||
|
|
||||||
//apirouter.Handle("/projectgroups", authForcedHandler(projectsHandler)).Methods("GET")
|
//apirouter.Handle("/projectgroups", authForcedHandler(projectsHandler)).Methods("GET")
|
||||||
apirouter.Handle("/projectgroups/{projectgroupid}", authForcedHandler(projectGroupHandler)).Methods("GET")
|
apirouter.Handle("/projectgroups/{projectgroupref}", authForcedHandler(projectGroupHandler)).Methods("GET")
|
||||||
apirouter.Handle("/projectgroups/{projectgroupid}/subgroups", authForcedHandler(projectGroupSubgroupsHandler)).Methods("GET")
|
apirouter.Handle("/projectgroups/{projectgroupref}/subgroups", authForcedHandler(projectGroupSubgroupsHandler)).Methods("GET")
|
||||||
apirouter.Handle("/projectgroups/{projectgroupid}/projects", authForcedHandler(projectGroupProjectsHandler)).Methods("GET")
|
apirouter.Handle("/projectgroups/{projectgroupref}/projects", authForcedHandler(projectGroupProjectsHandler)).Methods("GET")
|
||||||
apirouter.Handle("/projectgroups", authForcedHandler(createProjectGroupHandler)).Methods("POST")
|
apirouter.Handle("/projectgroups", authForcedHandler(createProjectGroupHandler)).Methods("POST")
|
||||||
//apirouter.Handle("/projectgroups/{projectgroupid}", authForcedHandler(deleteProjectGroupHandler)).Methods("DELETE")
|
//apirouter.Handle("/projectgroups/{projectgroupref}", authForcedHandler(deleteProjectGroupHandler)).Methods("DELETE")
|
||||||
|
|
||||||
apirouter.Handle("/projects/{projectid}", authForcedHandler(projectHandler)).Methods("GET")
|
apirouter.Handle("/projects/{projectref}", authForcedHandler(projectHandler)).Methods("GET")
|
||||||
apirouter.Handle("/projects", authForcedHandler(createProjectHandler)).Methods("POST")
|
apirouter.Handle("/projects", authForcedHandler(createProjectHandler)).Methods("POST")
|
||||||
apirouter.Handle("/projects/{projectid}", authForcedHandler(deleteProjectHandler)).Methods("DELETE")
|
apirouter.Handle("/projects/{projectref}", authForcedHandler(deleteProjectHandler)).Methods("DELETE")
|
||||||
apirouter.Handle("/projects/{projectid}/reconfig", authForcedHandler(projectReconfigHandler)).Methods("PUT")
|
apirouter.Handle("/projects/{projectref}/reconfig", authForcedHandler(projectReconfigHandler)).Methods("PUT")
|
||||||
|
|
||||||
apirouter.Handle("/projectgroups/{projectgroupref}/secrets", authForcedHandler(secretHandler)).Methods("GET")
|
apirouter.Handle("/projectgroups/{projectgroupref}/secrets", authForcedHandler(secretHandler)).Methods("GET")
|
||||||
apirouter.Handle("/projects/{projectref}/secrets", authForcedHandler(secretHandler)).Methods("GET")
|
apirouter.Handle("/projects/{projectref}/secrets", authForcedHandler(secretHandler)).Methods("GET")
|
||||||
|
|
Loading…
Reference in New Issue