-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flux source integration #324
Conversation
Signed-off-by: Michael Bridgen <[email protected]>
Signed-off-by: Michael Bridgen <[email protected]>
This adds FluxSource as an alternative to the (inline) GitSource. Signed-off-by: Michael Bridgen <[email protected]>
b8e5b55
to
f72adf4
Compare
Further test cases:
EDIT: I am going to bump "When the source has a new version, the stack is rerun". This is true, as a consequence of stacks being rescheduled, so it will work the same as a git source. It would be nice to keep a watch on sources and be more responsive than git sources (which poll the git repo for new commits on each run), but it can be done in a follow up PR, I think. |
d5ae2f3
to
3681dae
Compare
(I will square away the design doc -- aside from anything else, the fields in the proposed API change need to be renamed) |
This adds handling of Flux sources into the controller, while trying to disturb the present behaviour as little as possible. Broadly this means branching in a couple of places to do source-specific things: in particular, - setting up the automation API workspace (SetupWorkdirFrom*) is mostly different up to the point you have fetched the source code, which in the GitSource case is done _by_ setting up the workspace; so, all the things you have to do _after_ you have an auto.Workspace go into another helper, which is called from each Setup func. The func signatures are brought into line so the return values can have a uniform treatment. - requeue handling is quite idiosyncratic (e.g,. why does ContinueResyncOnCommitMatch only matter if you are tracking a branch?). I have left the current behaviour for git sources intact, since it may be relied upon in deployments, and branched to analogous logic for Flux sources. This means some near-duplicated code, for the sake of playing it safe. Signed-off-by: Michael Bridgen <[email protected]>
A missing source is something that could just "come right"; record it in .status.lastUpdate as a failure, and in .status.conditions as "in progress (retrying)". Signed-off-by: Michael Bridgen <[email protected]>
Signed-off-by: Michael Bridgen <[email protected]>
Signed-off-by: Michael Bridgen <[email protected]>
Signed-off-by: Michael Bridgen <[email protected]>
Signed-off-by: Michael Bridgen <[email protected]>
Many of the tests wait for a particular value of `.status.lastUpdate.State`, then check the values of conditions are as expected. However, between these two things, they fetch the object from the API server again (`refetch`), since the waitForStack* uses a temporary variable rather than mutating the stack given to it. That that admits the possibility that the status might have been updated again, by the controller reconciling it again. Instead, let waitForStack* write to the object it's given, and don't `refetch` -- then, the status observed will be the status at the point the wait succeeded. Signed-off-by: Michael Bridgen <[email protected]>
This standardises how the .status.artifact.X fields are accessed, so that (for the sake of a few extra lines) there's less repeated code, and errors are consistent. Signed-off-by: Michael Bridgen <[email protected]>
Previously, an if-then-else checked for the presence of source specifications (GitSource and FluxSource), and this made it possible to supply a stack object with both kinds of source (though only the first checked -- GitSource -- would be used). This commit makes that bit of code enforce the mutual exclusion of sources. Signed-off-by: Michael Bridgen <[email protected]>
531fe1c
to
fc4f6fc
Compare
// Check which kind of source we have. | ||
gitSource, fluxSource := stack.GitSource, stack.FluxSource | ||
switch { | ||
case gitSource != nil && fluxSource == nil: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is fine, but an alternative would be validating the mutually-exclusive condition ahead of the switch, and then keeping the simpler non-nil selection logic that you had previously. It probably doesn't matter for this PR, but it might be a little cleaner once the inline YAML case is added as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am ever hopeful that a switch
will help make the code look more like a pattern match. One day it'll be true.
Addresses #158.