*: rename deleteOrgMember to removeOrgMember

This commit is contained in:
Simone Gotti 2019-05-14 11:20:09 +02:00
parent c5cdf01332
commit aeda922a7d
7 changed files with 20 additions and 20 deletions

View File

@ -269,8 +269,8 @@ func (h *ActionHandler) AddOrgMember(ctx context.Context, orgRef, userRef string
return orgmember, err
}
// DeleteOrgMember deletes an org member.
func (h *ActionHandler) DeleteOrgMember(ctx context.Context, orgRef, userRef string) error {
// RemoveOrgMember removes an org member.
func (h *ActionHandler) RemoveOrgMember(ctx context.Context, orgRef, userRef string) error {
var org *types.Organization
var user *types.User
var orgmember *types.OrganizationMember

View File

@ -478,7 +478,7 @@ func (c *Client) AddOrgMember(ctx context.Context, orgRef, userRef string, role
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)
}

View File

@ -217,23 +217,23 @@ func (h *AddOrgMemberHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
}
}
type DeleteOrgMemberHandler struct {
type RemoveOrgMemberHandler struct {
log *zap.SugaredLogger
ah *action.ActionHandler
}
func NewDeleteOrgMemberHandler(logger *zap.Logger, ah *action.ActionHandler) *DeleteOrgMemberHandler {
return &DeleteOrgMemberHandler{log: logger.Sugar(), ah: ah}
func NewRemoveOrgMemberHandler(logger *zap.Logger, ah *action.ActionHandler) *RemoveOrgMemberHandler {
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()
vars := mux.Vars(r)
orgRef := vars["orgref"]
userRef := vars["userref"]
err := h.ah.DeleteOrgMember(ctx, orgRef, userRef)
err := h.ah.RemoveOrgMember(ctx, orgRef, userRef)
if httpError(w, err) {
h.log.Errorf("err: %+v", err)
return

View File

@ -165,7 +165,7 @@ func (s *Configstore) Run(ctx context.Context) error {
deleteOrgHandler := api.NewDeleteOrgHandler(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)
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/{orgref}", deleteOrgHandler).Methods("DELETE")
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", remoteSourcesHandler).Methods("GET")

View File

@ -139,7 +139,7 @@ func (h *ActionHandler) AddOrgMember(ctx context.Context, orgRef, userRef string
}, 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)
if err != nil {
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"))
}
resp, err = h.configstoreClient.DeleteOrgMember(ctx, orgRef, userRef)
resp, err = h.configstoreClient.RemoveOrgMember(ctx, orgRef, userRef)
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

View File

@ -253,23 +253,23 @@ func (h *AddOrgMemberHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
}
}
type DeleteOrgMemberHandler struct {
type RemoveOrgMemberHandler struct {
log *zap.SugaredLogger
ah *action.ActionHandler
}
func NewDeleteOrgMemberHandler(logger *zap.Logger, ah *action.ActionHandler) *DeleteOrgMemberHandler {
return &DeleteOrgMemberHandler{log: logger.Sugar(), ah: ah}
func NewRemoveOrgMemberHandler(logger *zap.Logger, ah *action.ActionHandler) *RemoveOrgMemberHandler {
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()
vars := mux.Vars(r)
orgRef := vars["orgref"]
userRef := vars["userref"]
err := h.ah.DeleteOrgMember(ctx, orgRef, userRef)
err := h.ah.RemoveOrgMember(ctx, orgRef, userRef)
if httpError(w, err) {
h.log.Errorf("err: %+v", err)
return

View File

@ -192,7 +192,7 @@ func (g *Gateway) Run(ctx context.Context) error {
deleteOrgHandler := api.NewDeleteOrgHandler(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)
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/{orgref}", authForcedHandler(deleteOrgHandler)).Methods("DELETE")
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}/actions", authForcedHandler(runActionsHandler)).Methods("PUT")