diff --git a/src/main/kotlin/net/leanix/githubagent/config/AgentSetupValidation.kt b/src/main/kotlin/net/leanix/githubagent/config/AgentSetupValidation.kt index 2906db9..d0624bf 100644 --- a/src/main/kotlin/net/leanix/githubagent/config/AgentSetupValidation.kt +++ b/src/main/kotlin/net/leanix/githubagent/config/AgentSetupValidation.kt @@ -1,16 +1,19 @@ package net.leanix.githubagent.config -import jakarta.annotation.PostConstruct import net.leanix.githubagent.exceptions.GitHubEnterpriseConfigurationMissingException +import org.springframework.context.event.ContextRefreshedEvent +import org.springframework.context.event.EventListener import org.springframework.stereotype.Component @Component class AgentSetupValidation( - private val gitHubEnterpriseProperties: GitHubEnterpriseProperties + private val gitHubEnterpriseProperties: GitHubEnterpriseProperties, + private val leanIXProperties: LeanIXProperties ) { - @PostConstruct - fun validateConfiguration() { + @EventListener + @SuppressWarnings("UnusedParameter") + fun onApplicationEvent(event: ContextRefreshedEvent) { val missingProperties = mutableListOf() if (gitHubEnterpriseProperties.baseUrl.isBlank()) { @@ -23,6 +26,14 @@ class AgentSetupValidation( missingProperties.add("GITHUB_ENTERPRISE_PEM_FILE") } + if (leanIXProperties.wsBaseUrl.isBlank()) { + missingProperties.add("LEANIX_WS_BASE_URL") + } + + if (leanIXProperties.auth.accessTokenUri.isBlank()) { + missingProperties.add("LEANIX_AUTH_ACCESS_TOKEN_URI") + } + if (missingProperties.isNotEmpty()) { throw GitHubEnterpriseConfigurationMissingException(missingProperties.joinToString(", ")) }