Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dbp-relay-base-person-connector-ldap-bundle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Relay API Gateway
dbp-relay-base-person-connector-ldap-bundle
Commits
b300c757
Commit
b300c757
authored
3 years ago
by
Reiter, Christoph
Browse files
Options
Downloads
Patches
Plain Diff
Add a simple health check
Check if the LDAP connections works
parent
727be76d
No related branches found
No related tags found
No related merge requests found
Pipeline
#86190
passed
3 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Service/HealthCheck.php
+47
-0
47 additions, 0 deletions
src/Service/HealthCheck.php
src/Service/LDAPApi.php
+7
-0
7 additions, 0 deletions
src/Service/LDAPApi.php
with
54 additions
and
0 deletions
src/Service/HealthCheck.php
0 → 100644
+
47
−
0
View file @
b300c757
<?php
declare
(
strict_types
=
1
);
namespace
Dbp\Relay\BasePersonConnectorLdapBundle\Service
;
use
Dbp\Relay\CoreBundle\HealthCheck\CheckInterface
;
use
Dbp\Relay\CoreBundle\HealthCheck\CheckOptions
;
use
Dbp\Relay\CoreBundle\HealthCheck\CheckResult
;
class
HealthCheck
implements
CheckInterface
{
private
$ldap
;
public
function
__construct
(
LDAPApi
$ldap
)
{
$this
->
ldap
=
$ldap
;
}
public
function
getName
():
string
{
return
'base-person-connector-ldap'
;
}
private
function
checkMethod
(
string
$description
,
callable
$func
):
CheckResult
{
$result
=
new
CheckResult
(
$description
);
try
{
$func
();
}
catch
(
\Throwable
$e
)
{
$result
->
set
(
CheckResult
::
STATUS_FAILURE
,
$e
->
getMessage
(),
[
'exception'
=>
$e
]);
return
$result
;
}
$result
->
set
(
CheckResult
::
STATUS_SUCCESS
);
return
$result
;
}
public
function
check
(
CheckOptions
$options
):
array
{
$results
=
[];
$results
[]
=
$this
->
checkMethod
(
'Check if we can connect to the LDAP server'
,
[
$this
->
ldap
,
'checkConnection'
]);
return
$results
;
}
}
This diff is collapsed.
Click to expand it.
src/Service/LDAPApi.php
+
7
−
0
View file @
b300c757
...
@@ -106,6 +106,13 @@ class LDAPApi implements LoggerAwareInterface, ServiceSubscriberInterface
...
@@ -106,6 +106,13 @@ class LDAPApi implements LoggerAwareInterface, ServiceSubscriberInterface
$this
->
providerConfig
[
'port'
]
=
(
$encryption
===
'start_tls'
)
?
389
:
636
;
$this
->
providerConfig
[
'port'
]
=
(
$encryption
===
'start_tls'
)
?
389
:
636
;
}
}
public
function
checkConnection
()
{
$provider
=
$this
->
getProvider
();
$builder
=
$this
->
getCachedBuilder
(
$provider
);
$builder
->
first
();
}
public
function
setDeploymentEnvironment
(
string
$env
)
public
function
setDeploymentEnvironment
(
string
$env
)
{
{
$this
->
deploymentEnv
=
$env
;
$this
->
deploymentEnv
=
$env
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment