mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-29 01:28:44 +00:00
* feat: state rm * review feedback * fix conflict for pegomock generation code * adopt state command into allow-commands * fix conflicts * fix: state rm works on workspace * notify import/state rm discard plan file * fix lint * use repeat instead warning for re-plan * perl -pi -e 's!\* 🔁 plan file was discarded. to!🚮 A plan file was discarded. Re-plan would be required before applying.\n\n\* 🔁 To!g' server/**/* * follow main branch
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package events
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/runatlantis/atlantis/server/events/command"
|
|
)
|
|
|
|
func NewStateCommandRunner(
|
|
pullUpdater *PullUpdater,
|
|
prjCmdBuilder ProjectStateCommandBuilder,
|
|
prjCmdRunner ProjectStateCommandRunner,
|
|
) *StateCommandRunner {
|
|
return &StateCommandRunner{
|
|
pullUpdater: pullUpdater,
|
|
prjCmdBuilder: prjCmdBuilder,
|
|
prjCmdRunner: prjCmdRunner,
|
|
}
|
|
}
|
|
|
|
type StateCommandRunner struct {
|
|
pullUpdater *PullUpdater
|
|
prjCmdBuilder ProjectStateCommandBuilder
|
|
prjCmdRunner ProjectStateCommandRunner
|
|
}
|
|
|
|
func (v *StateCommandRunner) Run(ctx *command.Context, cmd *CommentCommand) {
|
|
var result command.Result
|
|
switch cmd.SubName {
|
|
case "rm":
|
|
result = v.runRm(ctx, cmd)
|
|
default:
|
|
result = command.Result{
|
|
Failure: fmt.Sprintf("unknown state subcommand %s", cmd.SubName),
|
|
}
|
|
}
|
|
v.pullUpdater.updatePull(ctx, cmd, result)
|
|
}
|
|
|
|
func (v *StateCommandRunner) runRm(ctx *command.Context, cmd *CommentCommand) command.Result {
|
|
projectCmds, err := v.prjCmdBuilder.BuildStateRmCommands(ctx, cmd)
|
|
if err != nil {
|
|
ctx.Log.Warn("Error %s", err)
|
|
}
|
|
return runProjectCmds(projectCmds, v.prjCmdRunner.StateRm)
|
|
}
|