gateway: project(group) create: rename parentID to parentRef

This commit is contained in:
Simone Gotti 2019-05-05 17:19:23 +02:00
parent 05ae46a72d
commit 6dfb789e77
6 changed files with 17 additions and 17 deletions

View File

@ -73,7 +73,7 @@ func projectCreate(cmd *cobra.Command, args []string) error {
req := &api.CreateProjectRequest{
Name: projectCreateOpts.name,
ParentID: projectCreateOpts.parentPath,
ParentRef: projectCreateOpts.parentPath,
Visibility: types.Visibility(projectCreateOpts.visibility),
RepoPath: projectCreateOpts.repoPath,
RemoteSourceName: projectCreateOpts.remoteSourceName,

View File

@ -65,7 +65,7 @@ func projectGroupCreate(cmd *cobra.Command, args []string) error {
req := &api.CreateProjectGroupRequest{
Name: projectGroupCreateOpts.name,
ParentID: projectGroupCreateOpts.parentPath,
ParentRef: projectGroupCreateOpts.parentPath,
Visibility: types.Visibility(projectCreateOpts.visibility),
}

View File

@ -39,7 +39,7 @@ func (h *ActionHandler) GetProject(ctx context.Context, projectRef string) (*csa
type CreateProjectRequest struct {
CurrentUserID string
Name string
ParentID string
ParentRef string
Visibility types.Visibility
RemoteSourceName string
RepoPath string
@ -57,7 +57,7 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateProjectReq
return nil, util.NewErrBadRequest(errors.Errorf("empty remote repo path"))
}
pg, resp, err := h.configstoreClient.GetProjectGroup(ctx, req.ParentID)
pg, resp, err := h.configstoreClient.GetProjectGroup(ctx, req.ParentRef)
if err != nil {
return nil, ErrFromRemote(resp, errors.Wrapf(err, "failed to get project group %q", req.Name))
}
@ -110,17 +110,17 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateProjectReq
return nil, errors.Wrapf(err, "failed to generate ssh key pair")
}
parentID := req.ParentID
if parentID == "" {
parentRef := req.ParentRef
if parentRef == "" {
// create project in current user namespace
parentID = path.Join("user", user.Name)
parentRef = path.Join("user", user.Name)
}
p := &types.Project{
Name: req.Name,
Parent: types.Parent{
Type: types.ConfigTypeProjectGroup,
ID: parentID,
ID: parentRef,
},
Visibility: req.Visibility,
RemoteRepositoryConfigType: types.RemoteRepositoryConfigTypeRemoteSource,

View File

@ -52,7 +52,7 @@ func (h *ActionHandler) GetProjectGroupProjects(ctx context.Context, projectGrou
type CreateProjectGroupRequest struct {
CurrentUserID string
Name string
ParentID string
ParentRef string
Visibility types.Visibility
}
@ -66,17 +66,17 @@ func (h *ActionHandler) CreateProjectGroup(ctx context.Context, req *CreateProje
return nil, ErrFromRemote(resp, errors.Wrapf(err, "failed to get user %q", req.CurrentUserID))
}
parentID := req.ParentID
if parentID == "" {
parentRef := req.ParentRef
if parentRef == "" {
// create projectGroup in current user namespace
parentID = path.Join("user", user.Name)
parentRef = path.Join("user", user.Name)
}
p := &types.ProjectGroup{
Name: req.Name,
Parent: types.Parent{
Type: types.ConfigTypeProjectGroup,
ID: parentID,
ID: parentRef,
},
Visibility: req.Visibility,
}

View File

@ -31,7 +31,7 @@ import (
type CreateProjectRequest struct {
Name string `json:"name,omitempty"`
ParentID string `json:"parent_id,omitempty"`
ParentRef string `json:"parent_ref,omitempty"`
Visibility types.Visibility `json:"visibility,omitempty"`
RepoPath string `json:"repo_path,omitempty"`
RemoteSourceName string `json:"remote_source_name,omitempty"`
@ -68,7 +68,7 @@ func (h *CreateProjectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
areq := &action.CreateProjectRequest{
Name: req.Name,
ParentID: req.ParentID,
ParentRef: req.ParentRef,
Visibility: req.Visibility,
RepoPath: req.RepoPath,
RemoteSourceName: req.RemoteSourceName,

View File

@ -31,7 +31,7 @@ import (
type CreateProjectGroupRequest struct {
Name string `json:"name,omitempty"`
ParentID string `json:"parent_id,omitempty"`
ParentRef string `json:"parent_ref,omitempty"`
Visibility types.Visibility `json:"visibility,omitempty"`
}
@ -65,7 +65,7 @@ func (h *CreateProjectGroupHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
creq := &action.CreateProjectGroupRequest{
Name: req.Name,
ParentID: req.ParentID,
ParentRef: req.ParentRef,
Visibility: req.Visibility,
CurrentUserID: userID,
}