Skip to content
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

Fix for DelegateReader swallowing exceptions #147

Merged
merged 3 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions helm-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ dependencies {
implementation("org.yaml:snakeyaml:1.27")
implementation("org.json:json:20200518")

implementation("org.unbroken-dome.gradle-plugin-utils:gradle-plugin-utils:0.2.1")
implementation("org.unbroken-dome.gradle-plugin-utils:gradle-plugin-utils:0.4.0")

testImplementation("com.jayway.jsonpath:json-path:2.4.0")
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.11.2")
testImplementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.11.2")

testImplementation("com.squareup.okhttp3:mockwebserver:4.9.0")

testImplementation("org.unbroken-dome.gradle-plugin-utils:gradle-plugin-test-utils:0.2.1")
testImplementation("org.unbroken-dome.gradle-plugin-utils:gradle-plugin-test-utils:0.4.0")
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ interface HelmChart : Named, Buildable {
fun renderings(action: Action<NamedDomainObjectContainer<HelmRendering>>) {
action.execute(renderings)
}


/**
* If `true`, override the `name` and `version` fields in the Chart.yaml file with the
* values of [chartName] and [chartVersion], respectively. This step is performed after
* any filtering (as configured by the `filtering` block).
*
* Defaults to `true`.
*/
val overrideChartInfo: Property<Boolean>
}


Expand Down Expand Up @@ -272,7 +282,7 @@ private open class DefaultHelmChart
)


override val renderings: NamedDomainObjectContainer<HelmRendering> =
final override val renderings: NamedDomainObjectContainer<HelmRendering> =
objects.domainObjectContainer(HelmRendering::class.java) { name ->
objects.createHelmRendering(name, this.name)
.apply {
Expand All @@ -281,6 +291,11 @@ private open class DefaultHelmChart
}.also { container ->
container.addRule(DefaultRenderingRule(container))
}


final override val overrideChartInfo: Property<Boolean> =
project.objects.property<Boolean>()
.convention(true)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ internal class FilterChartSourcesTaskRule(
chartVersion.set(chart.chartVersion)
sourceDir.set(chart.sourceDir)
targetDir.set((chart as HelmChartInternal).filteredSourcesDir)
overrideChartInfo.set(chart.overrideChartInfo)

filtering.setParent(chart.filtering)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ open class HelmFilterSources : DefaultTask() {
val result = project.sync { spec ->
spec.from(sourceDir)
spec.into(targetDir)
spec.applyChartInfoOverrides()
spec.applyFiltering()
spec.applyChartInfoOverrides()
}
didWork = result.didWork
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@ import org.unbrokendome.gradle.pluginutils.io.DelegateReader
import org.yaml.snakeyaml.Yaml
import org.yaml.snakeyaml.error.Mark
import org.yaml.snakeyaml.error.YAMLException
import org.yaml.snakeyaml.events.DocumentStartEvent
import org.yaml.snakeyaml.events.Event
import org.yaml.snakeyaml.events.MappingEndEvent
import org.yaml.snakeyaml.events.MappingStartEvent
import org.yaml.snakeyaml.events.ScalarEvent
import org.yaml.snakeyaml.events.SequenceEndEvent
import org.yaml.snakeyaml.events.SequenceStartEvent
import org.yaml.snakeyaml.events.StreamEndEvent
import org.yaml.snakeyaml.events.StreamStartEvent
import org.yaml.snakeyaml.events.*
import java.io.Reader
import java.io.StringReader
import java.io.StringWriter
Expand Down Expand Up @@ -67,9 +59,8 @@ internal abstract class AbstractYamlTransformingReader(
protected open fun addToMapping(path: YamlPath): Map<String, String> = emptyMap()


override val delegate: Reader by lazy(LazyThreadSafetyMode.NONE) {

val events = Yaml().parse(`in`)
override fun createDelegateReader(input: Reader): Reader {
val events = Yaml().parse(input)
var currentMark: Mark? = null
var state: ParseState = Initial()
val output = StringWriter()
Expand All @@ -83,7 +74,7 @@ internal abstract class AbstractYamlTransformingReader(
currentMark = event.endMark
}

StringReader(output.toString())
return StringReader(output.toString())
}


Expand Down
4 changes: 2 additions & 2 deletions helm-publish-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ dependencies {
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-common")
}

implementation("org.unbroken-dome.gradle-plugin-utils:gradle-plugin-utils:0.2.1")
implementation("org.unbroken-dome.gradle-plugin-utils:gradle-plugin-utils:0.4.0")

testImplementation("org.unbroken-dome.gradle-plugin-utils:gradle-plugin-test-utils:0.2.1")
testImplementation("org.unbroken-dome.gradle-plugin-utils:gradle-plugin-test-utils:0.4.0")
}


Expand Down
4 changes: 2 additions & 2 deletions helm-releases-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ dependencies {

implementation(project(":helm-plugin"))

implementation("org.unbroken-dome.gradle-plugin-utils:gradle-plugin-utils:0.2.1")
testImplementation("org.unbroken-dome.gradle-plugin-utils:gradle-plugin-test-utils:0.2.1")
implementation("org.unbroken-dome.gradle-plugin-utils:gradle-plugin-utils:0.4.0")
testImplementation("org.unbroken-dome.gradle-plugin-utils:gradle-plugin-test-utils:0.4.0")
}


Expand Down