Skip to content

Commit

Permalink
Fix webhooks for air gapped servers (#1148)
Browse files Browse the repository at this point in the history
* Fix webhook issue with air gapped server
  • Loading branch information
alfespa17 authored Aug 2, 2024
1 parent a9ecd20 commit 0fdc0ef
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
import lombok.extern.slf4j.Slf4j;
import org.terrakube.api.plugin.softdelete.SoftDeleteService;
import org.terrakube.api.plugin.vcs.WebhookService;
import org.terrakube.api.repository.GlobalVarRepository;
import org.terrakube.api.repository.WebhookRepository;
import org.terrakube.api.rs.globalvar.Globalvar;
import org.terrakube.api.rs.webhook.Webhook;
import org.terrakube.api.rs.workspace.Workspace;
import org.terrakube.api.rs.workspace.parameters.Category;

import java.util.Optional;

Expand All @@ -22,6 +25,7 @@ public class WorkspaceManageHook implements LifeCycleHook<Workspace> {
SoftDeleteService softDeleteService;
WebhookService webhookService;
WebhookRepository webhookRepository;
GlobalVarRepository globalVarRepository;

@Override
public void execute(LifeCycleHookBinding.Operation operation,
Expand Down Expand Up @@ -55,7 +59,12 @@ public void execute(LifeCycleHookBinding.Operation operation,
break;

case POSTCOMMIT:
webhookService.createWorkspaceWebhook(workspace);
if(globalVarRepository.getGlobalvarByOrganizationAndCategoryAndKey(workspace.getOrganization(), Category.ENV, "TERRAKUBE_DISABLE_WEBHOOK") == null) {
log.info("Webhook support is enabled");
webhookService.createWorkspaceWebhook(workspace);
} else {
log.warn("Webhook support is disabled");
}
break;

default:
Expand Down

0 comments on commit 0fdc0ef

Please sign in to comment.