All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.octopusden.octopus.vcsfacade.config.VCSConfig.kt Maven / Gradle / Ivy

There is a newer version: 3.0.21
Show newest version
package org.octopusden.octopus.vcsfacade.config

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.ConstructorBinding
import org.springframework.context.annotation.Configuration

@Configuration
class VCSConfig {

    @ConfigurationProperties("gitlab")
    @ConstructorBinding
    @ConditionalOnProperty(prefix = "gitlab", name = ["enabled"], havingValue = "true", matchIfMissing = true)
    class GitLabProperties(
        host: String,
        token: String?,
        username: String?,
        password: String?,
        healthCheck: HealthCheck,
        enabled: Boolean?
    ) :
        VCSProperties(
            host,
            if (token?.isNotBlank() == true) token else null,
            if (token?.isNotBlank() == true) null else username,
            if (token?.isNotBlank() == true) null else password,
            healthCheck,
            enabled ?: true
        )

    @ConfigurationProperties("bitbucket")
    @ConstructorBinding
    @ConditionalOnProperty(prefix = "bitbucket", name = ["enabled"], havingValue = "true", matchIfMissing = true)
    class BitbucketProperties(
        host: String,
        token: String?,
        username: String?,
        password: String?,
        healthCheck: HealthCheck,
        enabled: Boolean?
    ) :
        VCSProperties(
            host,
            if (token?.isNotBlank() == true) token else null,
            if (token?.isNotBlank() == true) null else username,
            if (token?.isNotBlank() == true) null else password,
            healthCheck,
            enabled ?: true
        )

    abstract class VCSProperties(
        val host: String,
        val token: String?,
        val username: String?,
        val password: String?,
        val healthCheck: HealthCheck,
        val enabled: Boolean
    ) {

        @ConstructorBinding
        class HealthCheck(
            val repo: String,
            val rootCommit: String,
            val lastRelease: String,
            val expectedCommits: Set
        )
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy