Files
atlantis/server/events/db_updater.go
Sarvar Muminov 90e92e3a13 chore: move CommandContext and CommandResult to models (#193) (#2093)
* Moved CommandContext and CommandResult to models (#193)

* Moved CommandContext and CommandResult to models

* move from models to command

rename CommandContext -> Context
rename CommandResult -> Result

* moved command related helpers into command package

* move ProjectCommandContext and ProjectResult to command/project package

* move project command context and project result

* revert unrelated code

* move tests

* fix left over

* fix linting

* fix tests

* remove unused import

* fix project context dependencies

* fix depenedecies

* fix typo
2022-03-21 10:36:13 -07:00

28 lines
982 B
Go

package events
import (
"github.com/runatlantis/atlantis/server/core/db"
"github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
)
type DBUpdater struct {
DB *db.BoltDB
}
func (c *DBUpdater) updateDB(ctx *command.Context, pull models.PullRequest, results []command.ProjectResult) (models.PullStatus, error) {
// Filter out results that errored due to the directory not existing. We
// don't store these in the database because they would never be "apply-able"
// and so the pull request would always have errors.
var filtered []command.ProjectResult
for _, r := range results {
if _, ok := r.Error.(DirNotExistErr); ok {
ctx.Log.Debug("ignoring error result from project at dir %q workspace %q because it is dir not exist error", r.RepoRelDir, r.Workspace)
continue
}
filtered = append(filtered, r)
}
ctx.Log.Debug("updating DB with pull results")
return c.DB.UpdatePullWithResults(pull, filtered)
}