-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add model and property file for parameters
- Loading branch information
1 parent
efcc760
commit 168cea9
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
test-common/src/main/kotlin/org/octopusden/octopus/vcsfacade/Configuration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.octopusden.octopus.vcsfacade | ||
|
||
import org.yaml.snakeyaml.Yaml | ||
|
||
private const val PROPERTY_FILE = "test-properties.yaml" | ||
const val TEST_PROFILE = "test.profile" | ||
const val GITLAB = "gitlab" | ||
const val GITEA = "gitea" | ||
const val BITBUCKET = "bitbucket" | ||
|
||
object Configuration { | ||
val model: ConfigModel by lazy { | ||
val yaml = Yaml() | ||
val inputStream = ConfigModel::class.java.getClassLoader().getResourceAsStream(PROPERTY_FILE) | ||
requireNotNull(inputStream) { "$PROPERTY_FILE not found" } | ||
overrideWithPropVariables(yaml.loadAs(inputStream, ConfigModel::class.java)) | ||
} | ||
|
||
private fun overrideWithPropVariables(configModel: ConfigModel): ConfigModel { | ||
configModel.bitbucket.host = System.getProperty("bitbucketHost", configModel.bitbucket.host) | ||
configModel.bitbucket.url = System.getProperty("bitbucketUrl", configModel.bitbucket.url) | ||
configModel.gitea.host = System.getProperty("giteaHost", configModel.gitea.host) | ||
configModel.gitea.url = System.getProperty("giteaUrl", configModel.gitea.url) | ||
configModel.gitlab.host = System.getProperty("gitlabHost", configModel.gitlab.host) | ||
configModel.gitlab.url = System.getProperty("gitlabUrl", configModel.gitlab.url) | ||
return configModel | ||
} | ||
} | ||
|
||
/** | ||
* Configuration model representing the structure of the test-properties.yaml file. | ||
*/ | ||
data class ConfigModel( | ||
var bitbucket: VcsModel = VcsModel("admin", "admin", "bitbucket:7990", "http://localhost:7990"), | ||
var gitlab: VcsModel = VcsModel("root", "VomkaEa6PD1OIgY7dQVbPUuO8wi9RMCaZw/i9yPXcI0=", "gitlab:8990", "http://localhost:8990"), | ||
var gitea: VcsModel = VcsModel("test-admin", "test-admin", "gitea:3000", "http://localhost:3000"), | ||
|
||
var project: String = "test-project", | ||
var repository: String = "test-repository", | ||
var repository2: String = "test-repository-2", | ||
var mainBranch: String = "master", | ||
var featureBranch: String = "feature/FEATURE-1", | ||
var messageInit: String = "initial commit", | ||
var message1: String = "TEST-1 First commit", | ||
var message2: String = "TEST-1 Second commit", | ||
var message3: String = "TEST-2 Third commit", | ||
var featureMessage: String = "FEATURE-1 First commit", | ||
var tag1: String = "commit-1-tag", | ||
var tag2: String = "commit-2-tag", | ||
var tag3: String = "commit-3-tag", | ||
var defaultId: String = "0123456789abcde", | ||
) | ||
|
||
/** | ||
* Configuration model representing the structure of the VCS properties. | ||
*/ | ||
data class VcsModel( | ||
var user: String = "", | ||
var password: String = "", | ||
var host: String = "", | ||
var url: String = "", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
bitbucket: | ||
host: "bitbucket:7990" | ||
user: "admin" | ||
password: "admin" | ||
url: "http://bitbucket:7990" | ||
|
||
gitlab: | ||
host: "gitlab:8990" | ||
user: "root" | ||
password: "VomkaEa6PD1OIgY7dQVbPUuO8wi9RMCaZw/i9yPXcI0=" | ||
|
||
gitea: | ||
host: "gitea:3000" | ||
user: "test-admin" | ||
password: "test-admin" | ||
|
||
vcsFacadeUrl: "http://vcs-facade:8080" | ||
|