-
Notifications
You must be signed in to change notification settings - Fork 6
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
Gitlab Target Reconciliation #44
Conversation
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
1300 lines added. It's all tests and some repetitive and hopefully easy to read code :) |
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
LGTM, as discussed I'm going to ignore the hardcoded values, since config and docs will be added in a separate pr |
- feat: marking sparrow as registered after found own URL in targets - fix: encoding of File's Content field for API - chore: codebase cleanup, logs & linting
Did manual E2E testing. The instance can register and update itself: The sparrow is also sucessfully grabing the global targets (it-self included) from Gitlab:
|
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
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.
Just a few notes here and there, but LGTM overall. Great job!
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.
First review
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
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.
Well done @puffitos. Readability is on point
@@ -64,6 +65,10 @@ func New(cfg *config.Config) *Sparrow { | |||
router: chi.NewRouter(), | |||
} | |||
|
|||
// Set the target manager | |||
gm := targets.NewGitlabManager("sparrow-with-cfg-file", cfg.TargetManager) |
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.
The name (domain name) needs to be configurable 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.
Will resolve in separate Issue
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
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.
LGTM as discussed
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Signed-off-by: Bruno Bressi <bruno.bressi@telekom.de>
Motivation
Addresses #30.
Changes
This PR introduces two new Interfaces:
TargetManager
: this serves as a handler for theGlobalTargets
struct. It is responsible for updating the localglobalTargets
state of the Sparrow, by periodically getting the new targets and also registering the Sparrow as aGlobalTarget
in the configured remote backend. The TargetManager should also be able to return the current state (AKA the list ofGlobalTargets
).Gitlab
: this is an Interface to handle the interaction with the Gitlab API (mostly theFiles
API of Gitlab). Its responsiblities are to get the currentglobalTargets
from a remote gitlab repository and update the file containing the registration of theSparrow
itself. The next step is implementing aDeleteFile
function to handle de-registration.The implementation of those interfaces handle the interaction of the
Sparrow
with the remote Gitlab repository holding all the targets.Tests done
Concerns
We still need to handle where the config for the TargetManager should be parsed. Currently, we need the base gitlab URL, the project ID (could be merged into one variable) and the gitlab token to access the repo. Also, some durations:
The
PutFile
,PostFile
andFetchFiles
functions are similar, which introduce some code duplication. As those functions won't need to be updated significantly for the foreseeable future, we can just refactor them some time down the line to reduce the codebase and simplify testing and usage of theGitlab
interface. A solution would be to use a builder Pattern (`Gitlab().Files().List(), Gitlab().Files().Get("filename") and so on), a la k8s go-client.TODO