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{ req := &api.CreateProjectRequest{
Name: projectCreateOpts.name, Name: projectCreateOpts.name,
ParentID: projectCreateOpts.parentPath, ParentRef: projectCreateOpts.parentPath,
Visibility: types.Visibility(projectCreateOpts.visibility), Visibility: types.Visibility(projectCreateOpts.visibility),
RepoPath: projectCreateOpts.repoPath, RepoPath: projectCreateOpts.repoPath,
RemoteSourceName: projectCreateOpts.remoteSourceName, RemoteSourceName: projectCreateOpts.remoteSourceName,

View File

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

View File

@ -39,7 +39,7 @@ func (h *ActionHandler) GetProject(ctx context.Context, projectRef string) (*csa
type CreateProjectRequest struct { type CreateProjectRequest struct {
CurrentUserID string CurrentUserID string
Name string Name string
ParentID string ParentRef string
Visibility types.Visibility Visibility types.Visibility
RemoteSourceName string RemoteSourceName string
RepoPath 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")) 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 { if err != nil {
return nil, ErrFromRemote(resp, errors.Wrapf(err, "failed to get project group %q", req.Name)) 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") return nil, errors.Wrapf(err, "failed to generate ssh key pair")
} }
parentID := req.ParentID parentRef := req.ParentRef
if parentID == "" { if parentRef == "" {
// create project in current user namespace // create project in current user namespace
parentID = path.Join("user", user.Name) parentRef = path.Join("user", user.Name)
} }
p := &types.Project{ p := &types.Project{
Name: req.Name, Name: req.Name,
Parent: types.Parent{ Parent: types.Parent{
Type: types.ConfigTypeProjectGroup, Type: types.ConfigTypeProjectGroup,
ID: parentID, ID: parentRef,
}, },
Visibility: req.Visibility, Visibility: req.Visibility,
RemoteRepositoryConfigType: types.RemoteRepositoryConfigTypeRemoteSource, RemoteRepositoryConfigType: types.RemoteRepositoryConfigTypeRemoteSource,

View File

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

View File

@ -31,7 +31,7 @@ import (
type CreateProjectRequest struct { type CreateProjectRequest struct {
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
ParentID string `json:"parent_id,omitempty"` ParentRef string `json:"parent_ref,omitempty"`
Visibility types.Visibility `json:"visibility,omitempty"` Visibility types.Visibility `json:"visibility,omitempty"`
RepoPath string `json:"repo_path,omitempty"` RepoPath string `json:"repo_path,omitempty"`
RemoteSourceName string `json:"remote_source_name,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{ areq := &action.CreateProjectRequest{
Name: req.Name, Name: req.Name,
ParentID: req.ParentID, ParentRef: req.ParentRef,
Visibility: req.Visibility, Visibility: req.Visibility,
RepoPath: req.RepoPath, RepoPath: req.RepoPath,
RemoteSourceName: req.RemoteSourceName, RemoteSourceName: req.RemoteSourceName,

View File

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