Skip to content

Commit

Permalink
Make health token optional
Browse files Browse the repository at this point in the history
  • Loading branch information
TheZoker committed Jul 21, 2023
1 parent 8a139ad commit 9395e67
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.*;
import java.util.Optional;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -60,7 +61,7 @@ public class GitLabService extends AbstractVersionControlService {
private String ciToken;

@Value("${artemis.version-control.health-api-token}")
private String ciHealthToken;
private Optional<String> ciHealthToken;

private final UserRepository userRepository;

Expand Down Expand Up @@ -508,7 +509,10 @@ private void updateMemberPermissionInRepository(VcsRepositoryUrl repositoryUrl,
public ConnectorHealth health() {
try {
UriComponentsBuilder builder = Endpoints.HEALTH.buildEndpoint(gitlabServerUrl.toString());
URI uri = builder.queryParam("token", ciHealthToken).build().toUri();
if (ciHealthToken != null) {
builder.queryParam("token", ciHealthToken);
}
URI uri = builder.build().toUri();

final var healthResponse = shortTimeoutRestTemplate.getForObject(uri, JsonNode.class);
final var status = healthResponse.get("status").asText();
Expand Down

0 comments on commit 9395e67

Please sign in to comment.