mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-31 09:18:47 +00:00
* feat: atlantis import * feat: atlantis import * regenerate mock comment builder * remove duplicate err check * instrumented import command runner/builder * atlantis import subcommand accept args before hyphen * fix link checker * docs: review feedback * fix atlantis import options order * Update runatlantis.io/docs/using-atlantis.md Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update runatlantis.io/docs/using-atlantis.md Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update runatlantis.io/docs/using-atlantis.md Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update runatlantis.io/docs/using-atlantis.md Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update runatlantis.io/docs/using-atlantis.md Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update runatlantis.io/docs/command-requirements.md Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update runatlantis.io/docs/command-requirements.md Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update runatlantis.io/docs/command-requirements.md Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update server/events/comment_parser.go Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update server/events/comment_parser.go Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update runatlantis.io/docs/command-requirements.md Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update runatlantis.io/docs/command-requirements.md Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update runatlantis.io/docs/command-requirements.md Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update runatlantis.io/docs/server-side-repo-config.md Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update runatlantis.io/docs/command-requirements.md Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update runatlantis.io/docs/command-requirements.md Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update runatlantis.io/docs/command-requirements.md Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update runatlantis.io/docs/command-requirements.md Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update runatlantis.io/docs/command-requirements.md Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update server/events/command_requirement_handler.go Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * Update server/events/command_requirement_handler_test.go Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com> * fix test import usage * fix e2e expected txt * fix doc link * docs: workflow import stage/step * docs fixup Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
73 lines
2.1 KiB
Go
73 lines
2.1 KiB
Go
package events
|
|
|
|
import (
|
|
"github.com/runatlantis/atlantis/server/events/command"
|
|
"github.com/runatlantis/atlantis/server/logging"
|
|
"github.com/runatlantis/atlantis/server/metrics"
|
|
"github.com/uber-go/tally"
|
|
)
|
|
|
|
type InstrumentedProjectCommandBuilder struct {
|
|
ProjectCommandBuilder
|
|
Logger logging.SimpleLogging
|
|
scope tally.Scope
|
|
}
|
|
|
|
func (b *InstrumentedProjectCommandBuilder) BuildApplyCommands(ctx *command.Context, comment *CommentCommand) ([]command.ProjectContext, error) {
|
|
return b.buildAndEmitStats(
|
|
"apply",
|
|
func() ([]command.ProjectContext, error) {
|
|
return b.ProjectCommandBuilder.BuildApplyCommands(ctx, comment)
|
|
},
|
|
)
|
|
}
|
|
|
|
func (b *InstrumentedProjectCommandBuilder) BuildAutoplanCommands(ctx *command.Context) ([]command.ProjectContext, error) {
|
|
return b.buildAndEmitStats(
|
|
"auto plan",
|
|
func() ([]command.ProjectContext, error) {
|
|
return b.ProjectCommandBuilder.BuildAutoplanCommands(ctx)
|
|
},
|
|
)
|
|
}
|
|
|
|
func (b *InstrumentedProjectCommandBuilder) BuildPlanCommands(ctx *command.Context, comment *CommentCommand) ([]command.ProjectContext, error) {
|
|
return b.buildAndEmitStats(
|
|
"plan",
|
|
func() ([]command.ProjectContext, error) {
|
|
return b.ProjectCommandBuilder.BuildPlanCommands(ctx, comment)
|
|
},
|
|
)
|
|
}
|
|
|
|
func (b *InstrumentedProjectCommandBuilder) BuildVersionCommands(ctx *command.Context, comment *CommentCommand) ([]command.ProjectContext, error) {
|
|
return b.buildAndEmitStats(
|
|
"import",
|
|
func() ([]command.ProjectContext, error) {
|
|
return b.ProjectCommandBuilder.BuildImportCommands(ctx, comment)
|
|
},
|
|
)
|
|
}
|
|
|
|
func (b *InstrumentedProjectCommandBuilder) buildAndEmitStats(
|
|
command string,
|
|
execute func() ([]command.ProjectContext, error),
|
|
) ([]command.ProjectContext, error) {
|
|
timer := b.scope.Timer(metrics.ExecutionTimeMetric).Start()
|
|
defer timer.Stop()
|
|
|
|
executionSuccess := b.scope.Counter(metrics.ExecutionSuccessMetric)
|
|
executionError := b.scope.Counter(metrics.ExecutionErrorMetric)
|
|
|
|
projectCmds, err := execute()
|
|
|
|
if err != nil {
|
|
executionError.Inc(1)
|
|
b.Logger.Err("Error building %s commands: %s", command, err)
|
|
} else {
|
|
executionSuccess.Inc(1)
|
|
}
|
|
|
|
return projectCmds, err
|
|
}
|