Skip to content

Commit

Permalink
configstore: add project run actions auth setting for org members
Browse files Browse the repository at this point in the history
update project type add CanMembersPerformRunActions
  • Loading branch information
alessandro-sorint committed Oct 10, 2023
1 parent 1326c5d commit eaf1329
Show file tree
Hide file tree
Showing 22 changed files with 1,290 additions and 161 deletions.
27 changes: 15 additions & 12 deletions internal/services/configstore/action/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,19 @@ func (h *ActionHandler) GetProject(ctx context.Context, projectRef string) (*typ
}

type CreateUpdateProjectRequest struct {
Name string
Parent types.Parent
Visibility types.Visibility
RemoteRepositoryConfigType types.RemoteRepositoryConfigType
RemoteSourceID string
LinkedAccountID string
RepositoryID string
RepositoryPath string
SSHPrivateKey string
SkipSSHHostKeyCheck bool
PassVarsToForkedPR bool
DefaultBranch string
Name string
Parent types.Parent
Visibility types.Visibility
RemoteRepositoryConfigType types.RemoteRepositoryConfigType
RemoteSourceID string
LinkedAccountID string
RepositoryID string
RepositoryPath string
SSHPrivateKey string
SkipSSHHostKeyCheck bool
PassVarsToForkedPR bool
DefaultBranch string
CanMembersPerformRunActions bool
}

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

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

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,
CanMembersPerformRunActions: req.CanMembersPerformRunActions,
}

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,
CanMembersPerformRunActions: req.CanMembersPerformRunActions,
}

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 eaf1329

Please # to comment.