mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-29 16:08:21 +00:00
* Adding policy_check support into yaml config * Added policy check model and runtime structs * Adding BuildPolicyCheckCommand to ProjectCommandBuilder * Return incorrectly deleted code * Remove BuildAutoPolicyPlanCommand from ProjectCommandBuilder * Split runAutoCommand into two functions runAutoPlanCommand - does what originally RunAutoplancommand was doing except now it returns CommandResult and []models.ProjectCommandContext runAutoPolicyCheckCommand - accepts CommandContext, CommandResult, and []models.ProjectCommandContext as arguments and runs PolicyCheckStep runner * Refactor RunCommentCommand * Remove BuildPolicyCheckCommand and rename StepCmdExec back to TerraformExec * Add policy step runner logic and conftest interfaces. * Add show step runner to policy check stage. * Adding models.PolicyCheckCommand to buildCtx This also means buildPlanAllCommands call buildCtx twice once with models.PlanCommand and once with models.PolicyCheckCommand * Adding new project_command_builder that supports policy_check * Refactoring PolicyCheck specific logic into a PolicyCheckProjectCommandBuilder * Moving events.CommandContext to models.CommandContext this will allow me to remove buildCtx method and move ProjectCommandContext creation into models package * Policy Owners might be different types, for that reason we are refactoring Owners into its own struct with specific keys defining different owner types Co-authored-by: Nish Krishnan <nishk@lyft.com> Co-authored-by: Nish Krishnan <nishkrishnan@users.noreply.github.com>
53 lines
1007 B
Go
53 lines
1007 B
Go
package events
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/remeh/sizedwaitgroup"
|
|
"github.com/runatlantis/atlantis/server/events/models"
|
|
)
|
|
|
|
type prjCmdRunnerFunc func(ctx models.ProjectCommandContext) models.ProjectResult
|
|
|
|
func runProjectCmdsParallel(
|
|
cmds []models.ProjectCommandContext,
|
|
runnerFunc prjCmdRunnerFunc,
|
|
poolSize int,
|
|
) CommandResult {
|
|
var results []models.ProjectResult
|
|
mux := &sync.Mutex{}
|
|
|
|
wg := sizedwaitgroup.New(15)
|
|
for _, pCmd := range cmds {
|
|
pCmd := pCmd
|
|
var execute func()
|
|
wg.Add()
|
|
|
|
execute = func() {
|
|
defer wg.Done()
|
|
res := runnerFunc(pCmd)
|
|
mux.Lock()
|
|
results = append(results, res)
|
|
mux.Unlock()
|
|
}
|
|
|
|
go execute()
|
|
}
|
|
|
|
wg.Wait()
|
|
return CommandResult{ProjectResults: results}
|
|
}
|
|
|
|
func runProjectCmds(
|
|
cmds []models.ProjectCommandContext,
|
|
runnerFunc prjCmdRunnerFunc,
|
|
) CommandResult {
|
|
var results []models.ProjectResult
|
|
for _, pCmd := range cmds {
|
|
res := runnerFunc(pCmd)
|
|
|
|
results = append(results, res)
|
|
}
|
|
return CommandResult{ProjectResults: results}
|
|
}
|