Skip to content
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

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Crontab-Docker #37

wants to merge 19 commits into from

Conversation

IamTaoChen
Copy link

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.

Adambean
Adambean previously approved these changes May 1, 2023
Copy link
Owner

@Adambean Adambean left a 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.)

@Adambean Adambean dismissed their stale review May 1, 2023 18:23

This shouldn't have approved the whole thing. Just one file.

Copy link
Owner

@Adambean Adambean left a 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.");
Copy link
Owner

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);
Copy link
Owner

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;

Copy link
Owner

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.

Comment on lines -1660 to +1661

!$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]);
}
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants