-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for configuration #27
Conversation
95eccb3
to
da18eef
Compare
.bazel-steward.conf
Outdated
@@ -0,0 +1,16 @@ | |||
maven: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am guessing that this is some example file?
Shouldn't we just put it in some test resources and validate if it is used correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot about the tests so I will create them
@@ -1,5 +1,6 @@ | |||
package org.virtuslab.bazelsteward.app | |||
|
|||
import config.src.main.kotlin.org.virtuslab.bazelsteward.config.BazelStewardConfiguration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something bad happened in terms of imports
|
||
private val configFilePath = repoRoot.resolve(".bazel-steward.conf") | ||
|
||
suspend fun get(): Configuration? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is nullable. Is there any point for getting null from here?
If there is no file, return empty configuration and if there are errors, throw.
import java.nio.file.Path | ||
|
||
data class Configuration( | ||
val maven: MavenConfig? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd avoid nullability in most places if there is a natural way to have something empty, i.e. just have
val maven: MavenConfig = MavenConfig()
val ruledDependencies: List<MavenDependency> = emptyList()
It will be easier to use it in code later
runCatching { | ||
Files.newBufferedReader(configFilePath).use { bufferedReader -> | ||
val configContent = | ||
bufferedReader.use { br -> br.readLines().filterNot { it.startsWith("#") }.joinToString("\n") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't yaml support comments natively?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately not, commented lines are loaded
|
||
class BazelStewardConfiguration(repoRoot: Path) { | ||
|
||
private val configFilePath = repoRoot.resolve(".bazel-steward.conf") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that later we will have a number of places where we look for it, we might also have various extensions, but now maybe let's look for .bazel-steward.yaml
for clarity? .conf may be associated with different formats.
b01b3c5
to
5d30768
Compare
suspend fun get(): Configuration { | ||
|
||
return withContext(Dispatchers.IO) { | ||
val schemaContent = javaClass.classLoader.getResource("bazel-steward-schema.json")?.readText() ?: return@withContext Configuration() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is rather a serious error in our deployment if we cannot access our schema to validate the config. I'd rather throw here.
1c72d30
to
12b1b03
Compare
No description provided.