Skip to content

Commit

Permalink
Add model and property file for parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonophore committed May 27, 2024
1 parent efcc760 commit 168cea9
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
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 = "",
)
18 changes: 18 additions & 0 deletions test-common/src/main/resources/test-properties.yaml
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"

0 comments on commit 168cea9

Please sign in to comment.