add syspec-ide-config.yaml and syspec-office-config.yaml

merge-requests/1/merge
az 2 years ago
parent 0659a98532
commit ce122ac13a

@ -4,7 +4,6 @@ import org.domaindrivenarchitecture.provs.configuration.domain.ConfigFileName
import org.domaindrivenarchitecture.provs.framework.core.readFromFile
import org.domaindrivenarchitecture.provs.framework.core.toYaml
import org.domaindrivenarchitecture.provs.framework.core.yamlToType
import org.domaindrivenarchitecture.provs.syspec.domain.CommandSpec
import org.domaindrivenarchitecture.provs.syspec.domain.SyspecConfig
import java.io.File
import java.io.FileWriter
@ -15,10 +14,10 @@ private const val DEFAULT_CONFIG_FILE = "syspec-config.yaml"
internal fun findSpecConfigFromFile(file: ConfigFileName? = null): Result<SyspecConfig> = runCatching {
val filePath = file?.fileName ?: DEFAULT_CONFIG_FILE
if ((filePath == DEFAULT_CONFIG_FILE) && !File(filePath).exists()) {
// provide default config
writeSpecConfigToFile(filePath, SyspecConfig(listOf(CommandSpec("echo just_for_demo", "just_for_demo"))))
// use default ide config
findSpecConfigFromResource("syspec/syspec-ide-config.yaml")
}
readFromFile(filePath).yamlToType<SyspecConfig>()
readFromFile(filePath).yamlToType()
}
@ -30,5 +29,6 @@ internal fun findSpecConfigFromResource(resourcePath: String): Result<SyspecConf
// --------------------------------- write ----------------------------------
@Suppress("unused")
internal fun writeSpecConfigToFile(fileName: String = DEFAULT_CONFIG_FILE, config: SyspecConfig) =
FileWriter(fileName).use { it.write(config.toYaml()) }

@ -0,0 +1,14 @@
package:
- name: "firefox"
- name: "thunderbird"
- name: "ssh"
- name: "git"
- name: "leiningen"
command:
# terraform, python, etc
- command: "tfenv -h"
- command: "python3 --version"
- command: "pip3 --version"
- command: "terraform --version"
out: "1.0.8"

@ -0,0 +1,5 @@
package:
- name: "firefox"
- name: "thunderbird"
- name: "ssh"
- name: "git"

@ -21,7 +21,7 @@ internal class SyspecConfigRepoKtTest {
@Test
fun findSpecConfigFromResource_success() {
// when
val res =findSpecConfigFromResource("syspec-config.yaml")
val res = findSpecConfigFromResource("syspec-config.yaml")
// then
assertEquals(listOf(CommandSpec("echo just_for_test", "just_for_test")), res.getOrNull()?.command)

Loading…
Cancel
Save