gateway: update CreateProject api
remove currentuserid since we can get it directly in the action
This commit is contained in:
parent
e1d0318c9b
commit
a43be4a6be
|
@ -49,7 +49,6 @@ func (h *ActionHandler) GetProject(ctx context.Context, projectRef string) (*csa
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateProjectRequest struct {
|
type CreateProjectRequest struct {
|
||||||
CurrentUserID string
|
|
||||||
Name string
|
Name string
|
||||||
ParentRef string
|
ParentRef string
|
||||||
Visibility types.Visibility
|
Visibility types.Visibility
|
||||||
|
@ -59,9 +58,11 @@ type CreateProjectRequest struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateProjectRequest) (*csapi.Project, error) {
|
func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateProjectRequest) (*csapi.Project, error) {
|
||||||
user, resp, err := h.configstoreClient.GetUser(ctx, req.CurrentUserID)
|
curUserID := h.CurrentUserID(ctx)
|
||||||
|
|
||||||
|
user, resp, err := h.configstoreClient.GetUser(ctx, curUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, ErrFromRemote(resp, errors.Wrapf(err, "failed to get user %q", req.CurrentUserID))
|
return nil, ErrFromRemote(resp, errors.Wrapf(err, "failed to get user %q", curUserID))
|
||||||
}
|
}
|
||||||
parentRef := req.ParentRef
|
parentRef := req.ParentRef
|
||||||
if parentRef == "" {
|
if parentRef == "" {
|
||||||
|
|
|
@ -19,7 +19,6 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
csapi "github.com/sorintlab/agola/internal/services/configstore/api"
|
csapi "github.com/sorintlab/agola/internal/services/configstore/api"
|
||||||
"github.com/sorintlab/agola/internal/services/gateway/action"
|
"github.com/sorintlab/agola/internal/services/gateway/action"
|
||||||
"github.com/sorintlab/agola/internal/services/types"
|
"github.com/sorintlab/agola/internal/services/types"
|
||||||
|
@ -58,21 +57,12 @@ func (h *CreateProjectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
userIDVal := ctx.Value("userid")
|
|
||||||
if userIDVal == nil {
|
|
||||||
httpError(w, util.NewErrBadRequest(errors.Errorf("user not authenticated")))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
userID := userIDVal.(string)
|
|
||||||
h.log.Infof("userID: %q", userID)
|
|
||||||
|
|
||||||
areq := &action.CreateProjectRequest{
|
areq := &action.CreateProjectRequest{
|
||||||
Name: req.Name,
|
Name: req.Name,
|
||||||
ParentRef: req.ParentRef,
|
ParentRef: req.ParentRef,
|
||||||
Visibility: req.Visibility,
|
Visibility: req.Visibility,
|
||||||
RepoPath: req.RepoPath,
|
RepoPath: req.RepoPath,
|
||||||
RemoteSourceName: req.RemoteSourceName,
|
RemoteSourceName: req.RemoteSourceName,
|
||||||
CurrentUserID: userID,
|
|
||||||
SkipSSHHostKeyCheck: req.SkipSSHHostKeyCheck,
|
SkipSSHHostKeyCheck: req.SkipSSHHostKeyCheck,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue