-
Notifications
You must be signed in to change notification settings - Fork 23
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
Crontab-Docker #37
base: master
Are you sure you want to change the base?
Crontab-Docker #37
Conversation
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 have no idea how Docker works.)
This shouldn't have approved the whole thing. Just one file.
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.
There are a few things in "src/LdapSyncCommand.php" that should really be a separate PR, and some itty bitty cosmetic tweaks for some reason. I'll amend this shortly.
@@ -75,8 +75,7 @@ public function configure(): void | |||
->setDescription("Sync LDAP users and groups with a Gitlab CE/EE self-hosted installation.") | |||
->addOption("dryrun", "d", InputOption::VALUE_NONE, "Dry run: Do not persist any changes.") | |||
->addOption("continueOnFail", null, InputOption::VALUE_NONE, "Do not abort on certain errors. (Continue running if possible.)") | |||
->addArgument("instance", InputArgument::OPTIONAL, "Sync with a specific instance, or leave unspecified to work with all.") | |||
; | |||
->addArgument("instance", InputArgument::OPTIONAL, "Sync with a specific instance, or leave unspecified to work with all."); |
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.
That shouldn't have been slipped in.
@@ -1103,8 +1101,7 @@ private function deployGitlabUsersAndGroups(array $config, string $gitlabInstanc | |||
|
|||
$this->logger->debug("Gitlab: Connecting"); | |||
$gitlab = \Gitlab\Client::create($gitlabConfig["url"]) | |||
->authenticate($gitlabConfig["token"], \Gitlab\Client::AUTH_HTTP_TOKEN) | |||
; | |||
->authenticate($gitlabConfig["token"], \Gitlab\Client::AUTH_HTTP_TOKEN); |
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.
That shouldn't have been slipped in.
@@ -308,7 +307,6 @@ private function validateConfig(array &$config, array &$problems = null): bool | |||
|
|||
$this->logger->$type(sprintf("Configuration: %s", $message)); | |||
$problems[$type][] = $message; | |||
|
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.
Anonymous function: The empty line here should have been kept.
|
||
!$this->dryRun ? ($gitlabGroupMember = $gitlab->api("groups")->addMember($gitlabGroupId, $gitlabUserId, $config["gitlab"]["options"]["newMemberAccessLevel"])) : $this->logger->warning("Operation skipped due to dry run."); | ||
|
||
try { | ||
!$this->dryRun ? ($gitlabGroupMember = $gitlab->api("groups")->addMember($gitlabGroupId, $gitlabUserId, $config["gitlab"]["options"]["newMemberAccessLevel"])) : $this->logger->warning("Operation skipped due to dry run."); | ||
} catch (\Exception $e) { | ||
$this->logger->error(sprintf("Gitlab failure: %s", $e->getMessage()), ["error" => $e]); | ||
} |
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.
Perhaps somewhat dangerous, would be better as a "--continue-on-errors" option.
I rebuilt the Dockerfile, and the new Docker can run independently and periodically execute the gitlab-ldap-sync task. In addition, I added a try...catch... block to line 1657 of LdapSyncCommand.php, so that even if there is an error, the program will continue to synchronize the remaining users.