Skip to content

Commit

Permalink
configstore: add ability to org members to restart stop cancel a proj…
Browse files Browse the repository at this point in the history
…ect run

update project type add MembersCanPerformRunActions
  • Loading branch information
alessandro-sorint committed Oct 12, 2023
1 parent d34a652 commit 90db6db
Show file tree
Hide file tree
Showing 23 changed files with 1,255 additions and 143 deletions.
4 changes: 4 additions & 0 deletions internal/services/configstore/action/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ type CreateUpdateProjectRequest struct {
SkipSSHHostKeyCheck bool
PassVarsToForkedPR bool
DefaultBranch string
//MembersCanPerformRunActions define if users of the organization can restart stop cancel a project run
MembersCanPerformRunActions bool
}

func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateUpdateProjectRequest) (*types.Project, error) {
Expand Down Expand Up @@ -163,6 +165,7 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateUpdateProj
project.SkipSSHHostKeyCheck = req.SkipSSHHostKeyCheck
project.PassVarsToForkedPR = req.PassVarsToForkedPR
project.DefaultBranch = req.DefaultBranch
project.MembersCanPerformRunActions = req.MembersCanPerformRunActions

// generate the Secret and the WebhookSecret
// TODO(sgotti) move this to the gateway?
Expand Down Expand Up @@ -273,6 +276,7 @@ func (h *ActionHandler) UpdateProject(ctx context.Context, curProjectRef string,
project.SkipSSHHostKeyCheck = req.SkipSSHHostKeyCheck
project.PassVarsToForkedPR = req.PassVarsToForkedPR
project.DefaultBranch = req.DefaultBranch
project.MembersCanPerformRunActions = req.MembersCanPerformRunActions

if err := h.d.UpdateProject(tx, project); err != nil {
return errors.WithStack(err)
Expand Down
50 changes: 26 additions & 24 deletions internal/services/configstore/api/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,19 @@ func (h *CreateProjectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
}

areq := &action.CreateUpdateProjectRequest{
Name: req.Name,
Parent: req.Parent,
Visibility: req.Visibility,
RemoteRepositoryConfigType: req.RemoteRepositoryConfigType,
RemoteSourceID: req.RemoteSourceID,
LinkedAccountID: req.LinkedAccountID,
RepositoryID: req.RepositoryID,
RepositoryPath: req.RepositoryPath,
SSHPrivateKey: req.SSHPrivateKey,
SkipSSHHostKeyCheck: req.SkipSSHHostKeyCheck,
PassVarsToForkedPR: req.PassVarsToForkedPR,
DefaultBranch: req.DefaultBranch,
Name: req.Name,
Parent: req.Parent,
Visibility: req.Visibility,
RemoteRepositoryConfigType: req.RemoteRepositoryConfigType,
RemoteSourceID: req.RemoteSourceID,
LinkedAccountID: req.LinkedAccountID,
RepositoryID: req.RepositoryID,
RepositoryPath: req.RepositoryPath,
SSHPrivateKey: req.SSHPrivateKey,
SkipSSHHostKeyCheck: req.SkipSSHHostKeyCheck,
PassVarsToForkedPR: req.PassVarsToForkedPR,
DefaultBranch: req.DefaultBranch,
MembersCanPerformRunActions: req.MembersCanPerformRunActions,
}

project, err := h.ah.CreateProject(ctx, areq)
Expand Down Expand Up @@ -230,18 +231,19 @@ func (h *UpdateProjectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
}

areq := &action.CreateUpdateProjectRequest{
Name: req.Name,
Parent: req.Parent,
Visibility: req.Visibility,
RemoteRepositoryConfigType: req.RemoteRepositoryConfigType,
RemoteSourceID: req.RemoteSourceID,
LinkedAccountID: req.LinkedAccountID,
RepositoryID: req.RepositoryID,
RepositoryPath: req.RepositoryPath,
SSHPrivateKey: req.SSHPrivateKey,
SkipSSHHostKeyCheck: req.SkipSSHHostKeyCheck,
PassVarsToForkedPR: req.PassVarsToForkedPR,
DefaultBranch: req.DefaultBranch,
Name: req.Name,
Parent: req.Parent,
Visibility: req.Visibility,
RemoteRepositoryConfigType: req.RemoteRepositoryConfigType,
RemoteSourceID: req.RemoteSourceID,
LinkedAccountID: req.LinkedAccountID,
RepositoryID: req.RepositoryID,
RepositoryPath: req.RepositoryPath,
SSHPrivateKey: req.SSHPrivateKey,
SkipSSHHostKeyCheck: req.SkipSSHHostKeyCheck,
PassVarsToForkedPR: req.PassVarsToForkedPR,
DefaultBranch: req.DefaultBranch,
MembersCanPerformRunActions: req.MembersCanPerformRunActions,
}

project, err := h.ah.UpdateProject(ctx, projectRef, areq)
Expand Down
4 changes: 2 additions & 2 deletions internal/services/configstore/db/ddl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/services/configstore/db/dml.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 90db6db

Please # to comment.