Skip to content

Commit

Permalink
Cleanup OciImageDefinitionImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtSilvio committed Jul 10, 2024
1 parent fea403e commit 2f6d366
Showing 1 changed file with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,29 +281,14 @@ internal abstract class OciImageDefinitionImpl @Inject constructor(
.map { it.build() }

private fun createMetadataLayers(providerFactory: ProviderFactory): Provider<List<OciMetadata.Layer>> =
providerFactory.provider {
providerFactory.provider { layers.list }.flatMap { layers ->
var listProvider = providerFactory.provider { listOf<OciMetadata.Layer>() }
for (layer in layers.list) {
for (layer in layers) {
layer as Layer
listProvider = listProvider.zip(layer.createMetadataLayer(providerFactory)) { list, e -> list + e }
}
listProvider
}.flatMap { it }

private fun TaskContainer.createMetadataTask(
imageDefName: String,
platform: Platform?,
metadata: Provider<OciMetadata>,
projectLayout: ProjectLayout,
) = register<OciMetadataTask>(
createOciMetadataClassifier(imageDefName).camelCase() + createPlatformPostfix(platform)
) {
group = TASK_GROUP_NAME
description = "Assembles the metadata json file of the '$imageDefName' OCI image" + if (platform == null) "." else " for the platform $platform"
encodedMetadata.set(metadata.map { it.encodeToJsonString() })
destinationDirectory.set(projectLayout.buildDirectory.dir("oci/images/$imageDefName"))
classifier.set(createOciMetadataClassifier(imageDefName) + createPlatformPostfix(platform))
}
}

final override fun parentImages(configuration: Action<in OciImageDefinition.Bundle.ParentImages>) =
configuration.execute(parentImages)
Expand Down Expand Up @@ -611,6 +596,19 @@ internal abstract class OciImageDefinitionImpl @Inject constructor(
}
}

private fun TaskContainer.createMetadataTask(
imageDefName: String,
platform: Platform?,
metadata: Provider<OciMetadata>,
projectLayout: ProjectLayout,
) = register<OciMetadataTask>(createOciMetadataClassifier(imageDefName).camelCase() + createPlatformPostfix(platform)) {
group = TASK_GROUP_NAME
description = "Assembles the metadata json file of the '$imageDefName' OCI image" + if (platform == null) "." else " for the platform $platform"
encodedMetadata.set(metadata.map { it.encodeToJsonString() })
destinationDirectory.set(projectLayout.buildDirectory.dir("oci/images/$imageDefName"))
classifier.set(createOciMetadataClassifier(imageDefName) + createPlatformPostfix(platform))
}

private fun TaskContainer.createLayerTask(
imageDefName: String,
layerName: String,
Expand Down

0 comments on commit 2f6d366

Please sign in to comment.