*: rename deleteOrgMember to removeOrgMember
This commit is contained in:
parent
c5cdf01332
commit
aeda922a7d
|
@ -269,8 +269,8 @@ func (h *ActionHandler) AddOrgMember(ctx context.Context, orgRef, userRef string
|
||||||
return orgmember, err
|
return orgmember, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteOrgMember deletes an org member.
|
// RemoveOrgMember removes an org member.
|
||||||
func (h *ActionHandler) DeleteOrgMember(ctx context.Context, orgRef, userRef string) error {
|
func (h *ActionHandler) RemoveOrgMember(ctx context.Context, orgRef, userRef string) error {
|
||||||
var org *types.Organization
|
var org *types.Organization
|
||||||
var user *types.User
|
var user *types.User
|
||||||
var orgmember *types.OrganizationMember
|
var orgmember *types.OrganizationMember
|
||||||
|
|
|
@ -478,7 +478,7 @@ func (c *Client) AddOrgMember(ctx context.Context, orgRef, userRef string, role
|
||||||
return orgmember, resp, err
|
return orgmember, resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) DeleteOrgMember(ctx context.Context, orgRef, userRef string) (*http.Response, error) {
|
func (c *Client) RemoveOrgMember(ctx context.Context, orgRef, userRef string) (*http.Response, error) {
|
||||||
return c.getResponse(ctx, "DELETE", fmt.Sprintf("/orgs/%s/members/%s", orgRef, userRef), nil, jsonContent, nil)
|
return c.getResponse(ctx, "DELETE", fmt.Sprintf("/orgs/%s/members/%s", orgRef, userRef), nil, jsonContent, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -217,23 +217,23 @@ func (h *AddOrgMemberHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeleteOrgMemberHandler struct {
|
type RemoveOrgMemberHandler struct {
|
||||||
log *zap.SugaredLogger
|
log *zap.SugaredLogger
|
||||||
ah *action.ActionHandler
|
ah *action.ActionHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDeleteOrgMemberHandler(logger *zap.Logger, ah *action.ActionHandler) *DeleteOrgMemberHandler {
|
func NewRemoveOrgMemberHandler(logger *zap.Logger, ah *action.ActionHandler) *RemoveOrgMemberHandler {
|
||||||
return &DeleteOrgMemberHandler{log: logger.Sugar(), ah: ah}
|
return &RemoveOrgMemberHandler{log: logger.Sugar(), ah: ah}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *DeleteOrgMemberHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h *RemoveOrgMemberHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
orgRef := vars["orgref"]
|
orgRef := vars["orgref"]
|
||||||
userRef := vars["userref"]
|
userRef := vars["userref"]
|
||||||
|
|
||||||
err := h.ah.DeleteOrgMember(ctx, orgRef, userRef)
|
err := h.ah.RemoveOrgMember(ctx, orgRef, userRef)
|
||||||
if httpError(w, err) {
|
if httpError(w, err) {
|
||||||
h.log.Errorf("err: %+v", err)
|
h.log.Errorf("err: %+v", err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -165,7 +165,7 @@ func (s *Configstore) Run(ctx context.Context) error {
|
||||||
deleteOrgHandler := api.NewDeleteOrgHandler(logger, s.ah)
|
deleteOrgHandler := api.NewDeleteOrgHandler(logger, s.ah)
|
||||||
|
|
||||||
addOrgMemberHandler := api.NewAddOrgMemberHandler(logger, s.ah)
|
addOrgMemberHandler := api.NewAddOrgMemberHandler(logger, s.ah)
|
||||||
deleteOrgMemberHandler := api.NewDeleteOrgMemberHandler(logger, s.ah)
|
removeOrgMemberHandler := api.NewRemoveOrgMemberHandler(logger, s.ah)
|
||||||
|
|
||||||
remoteSourceHandler := api.NewRemoteSourceHandler(logger, s.readDB)
|
remoteSourceHandler := api.NewRemoteSourceHandler(logger, s.readDB)
|
||||||
remoteSourcesHandler := api.NewRemoteSourcesHandler(logger, s.readDB)
|
remoteSourcesHandler := api.NewRemoteSourcesHandler(logger, s.readDB)
|
||||||
|
@ -219,7 +219,7 @@ func (s *Configstore) Run(ctx context.Context) error {
|
||||||
apirouter.Handle("/orgs", createOrgHandler).Methods("POST")
|
apirouter.Handle("/orgs", createOrgHandler).Methods("POST")
|
||||||
apirouter.Handle("/orgs/{orgref}", deleteOrgHandler).Methods("DELETE")
|
apirouter.Handle("/orgs/{orgref}", deleteOrgHandler).Methods("DELETE")
|
||||||
apirouter.Handle("/orgs/{orgref}/members/{userref}", addOrgMemberHandler).Methods("PUT")
|
apirouter.Handle("/orgs/{orgref}/members/{userref}", addOrgMemberHandler).Methods("PUT")
|
||||||
apirouter.Handle("/orgs/{orgref}/members/{userref}", deleteOrgMemberHandler).Methods("DELETE")
|
apirouter.Handle("/orgs/{orgref}/members/{userref}", removeOrgMemberHandler).Methods("DELETE")
|
||||||
|
|
||||||
apirouter.Handle("/remotesources/{remotesourceref}", remoteSourceHandler).Methods("GET")
|
apirouter.Handle("/remotesources/{remotesourceref}", remoteSourceHandler).Methods("GET")
|
||||||
apirouter.Handle("/remotesources", remoteSourcesHandler).Methods("GET")
|
apirouter.Handle("/remotesources", remoteSourcesHandler).Methods("GET")
|
||||||
|
|
|
@ -139,7 +139,7 @@ func (h *ActionHandler) AddOrgMember(ctx context.Context, orgRef, userRef string
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ActionHandler) DeleteOrgMember(ctx context.Context, orgRef, userRef string) error {
|
func (h *ActionHandler) RemoveOrgMember(ctx context.Context, orgRef, userRef string) error {
|
||||||
org, resp, err := h.configstoreClient.GetOrg(ctx, orgRef)
|
org, resp, err := h.configstoreClient.GetOrg(ctx, orgRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ErrFromRemote(resp, err)
|
return ErrFromRemote(resp, err)
|
||||||
|
@ -153,9 +153,9 @@ func (h *ActionHandler) DeleteOrgMember(ctx context.Context, orgRef, userRef str
|
||||||
return util.NewErrForbidden(errors.Errorf("user not authorized"))
|
return util.NewErrForbidden(errors.Errorf("user not authorized"))
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err = h.configstoreClient.DeleteOrgMember(ctx, orgRef, userRef)
|
resp, err = h.configstoreClient.RemoveOrgMember(ctx, orgRef, userRef)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ErrFromRemote(resp, errors.Wrapf(err, "failed to add/update organization member"))
|
return ErrFromRemote(resp, errors.Wrapf(err, "failed to remove organization member"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -253,23 +253,23 @@ func (h *AddOrgMemberHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeleteOrgMemberHandler struct {
|
type RemoveOrgMemberHandler struct {
|
||||||
log *zap.SugaredLogger
|
log *zap.SugaredLogger
|
||||||
ah *action.ActionHandler
|
ah *action.ActionHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDeleteOrgMemberHandler(logger *zap.Logger, ah *action.ActionHandler) *DeleteOrgMemberHandler {
|
func NewRemoveOrgMemberHandler(logger *zap.Logger, ah *action.ActionHandler) *RemoveOrgMemberHandler {
|
||||||
return &DeleteOrgMemberHandler{log: logger.Sugar(), ah: ah}
|
return &RemoveOrgMemberHandler{log: logger.Sugar(), ah: ah}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *DeleteOrgMemberHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h *RemoveOrgMemberHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
orgRef := vars["orgref"]
|
orgRef := vars["orgref"]
|
||||||
userRef := vars["userref"]
|
userRef := vars["userref"]
|
||||||
|
|
||||||
err := h.ah.DeleteOrgMember(ctx, orgRef, userRef)
|
err := h.ah.RemoveOrgMember(ctx, orgRef, userRef)
|
||||||
if httpError(w, err) {
|
if httpError(w, err) {
|
||||||
h.log.Errorf("err: %+v", err)
|
h.log.Errorf("err: %+v", err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -192,7 +192,7 @@ func (g *Gateway) Run(ctx context.Context) error {
|
||||||
deleteOrgHandler := api.NewDeleteOrgHandler(logger, g.ah)
|
deleteOrgHandler := api.NewDeleteOrgHandler(logger, g.ah)
|
||||||
|
|
||||||
addOrgMemberHandler := api.NewAddOrgMemberHandler(logger, g.ah)
|
addOrgMemberHandler := api.NewAddOrgMemberHandler(logger, g.ah)
|
||||||
deleteOrgMemberHandler := api.NewDeleteOrgMemberHandler(logger, g.ah)
|
removeOrgMemberHandler := api.NewRemoveOrgMemberHandler(logger, g.ah)
|
||||||
|
|
||||||
runHandler := api.NewRunHandler(logger, g.ah)
|
runHandler := api.NewRunHandler(logger, g.ah)
|
||||||
runsHandler := api.NewRunsHandler(logger, g.ah)
|
runsHandler := api.NewRunsHandler(logger, g.ah)
|
||||||
|
@ -273,7 +273,7 @@ func (g *Gateway) Run(ctx context.Context) error {
|
||||||
apirouter.Handle("/orgs", authForcedHandler(createOrgHandler)).Methods("POST")
|
apirouter.Handle("/orgs", authForcedHandler(createOrgHandler)).Methods("POST")
|
||||||
apirouter.Handle("/orgs/{orgref}", authForcedHandler(deleteOrgHandler)).Methods("DELETE")
|
apirouter.Handle("/orgs/{orgref}", authForcedHandler(deleteOrgHandler)).Methods("DELETE")
|
||||||
apirouter.Handle("/orgs/{orgref}/members/{userref}", authForcedHandler(addOrgMemberHandler)).Methods("PUT")
|
apirouter.Handle("/orgs/{orgref}/members/{userref}", authForcedHandler(addOrgMemberHandler)).Methods("PUT")
|
||||||
apirouter.Handle("/orgs/{orgref}/members/{userref}", authForcedHandler(deleteOrgMemberHandler)).Methods("DELETE")
|
apirouter.Handle("/orgs/{orgref}/members/{userref}", authForcedHandler(removeOrgMemberHandler)).Methods("DELETE")
|
||||||
|
|
||||||
apirouter.Handle("/runs/{runid}", authForcedHandler(runHandler)).Methods("GET")
|
apirouter.Handle("/runs/{runid}", authForcedHandler(runHandler)).Methods("GET")
|
||||||
apirouter.Handle("/runs/{runid}/actions", authForcedHandler(runActionsHandler)).Methods("PUT")
|
apirouter.Handle("/runs/{runid}/actions", authForcedHandler(runActionsHandler)).Methods("PUT")
|
||||||
|
|
Loading…
Reference in New Issue