Commit Graph

9 Commits

Author SHA1 Message Date
Sunny e3be50e586 controllers/update_test.go: Update to use testenv
Signed-off-by: Sunny <darkowlzz@protonmail.com>
2021-09-28 18:28:36 +05:30
Stefan Prodan 30030bbaf0
Update go-yaml with changes to indentation style
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-06-09 10:54:51 +03:00
Michael Bridgen cd895637b5 Ignore broken symlinks in commit
There is a bug in go-git which leads to it reporting broken, absolute
symlinks as modified whether they are or not:

    https://github.com/go-git/go-git/issues/253

To date, the controller checks whether the repo it has run an update
on is Clean, and as a consequence will run into the bug above if a
broken symlink is in the repo. The result is that it makes and pushes
an empty commit every interval.

To work around the problem, this commit adds a more careful check of
the repo status. Each file reported as modified is validated by
checking specifically that it's not a broken symlink: if `os.Lstat`
says it's a symlink and `os.Stat` reports the (target) file is
missing, it can be ignored. (Why not just ignore any missing file?
Because a missing file might indicate some other problem, so better to
let it fail).

For convenience, I have moved a few procedures around so they can be
used more readily by go tests.

Signed-off-by: Michael Bridgen <michael@weave.works>
2021-04-05 11:43:15 +01:00
Stefan Prodan 7c5d7b81a6
Add update path test
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-03-16 15:31:34 +02:00
Michael Bridgen 4006b6d5c4 Use UpdateWithSetters in controller
(and update the test to suit)
2020-10-13 21:00:13 +01:00
Michael Bridgen 963ee35c23 Preserve line-end comments when replacing image
Previously: replace the YNode (yaml.Node) with a new one which is just
the replacement string.
Now: change the value of the YNode, and set it back in place.
2020-09-29 12:19:12 +01:00
Michael Bridgen 6dea89456b Use a specific git branch to sidestep assumptions
When I set my default branch for `git init` in ~/.gitconfig, tests
start failing. This is because go-git assumes a default of `master`
when e.g., pulling commits, but exec'ing git (as the test server does,
via gitkit) will get you a different branch.

The answer is to be explicit about the branch created in tests, and in
all operations like cloning. The natural end point is that the
automation object specifies a branch to use (or an empty value,
meaning let it default).
2020-08-03 13:34:14 +01:00
Michael Bridgen 7c6e87d06a Test the result of the automated commit
This factors out the function that checks directories for equivalence,
and uses it to check that the upstream repo has the expected update
when the controller has pushed its commit.
2020-07-23 18:20:35 +01:00
Michael Bridgen c7d5511f1e Start test scaffolding
- start a test git server (thanks Stefan and Hidde!)
 - initialise it from a fixture (directory with repo contents)

This is the basics to build on.
2020-07-23 18:20:35 +01:00