Skip to content

Commit

Permalink
Add variants.isNotEmpty check in OciImageInput
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtSilvio committed Jul 11, 2024
1 parent a7965a0 commit 7f6b6b9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/kotlin/io/github/sgtsilvio/gradle/oci/OciImagesInput.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ import java.io.Serializable
*/
data class OciImageInput(
@get:Input val platform: Platform,
@get:Nested val variants: List<OciVariantInput>, // TODO document must not be empty
@get:Nested val variants: List<OciVariantInput>,
@get:Input val referenceSpecs: Set<OciImageReferenceSpec>,
)
) {
init {
require(variants.isNotEmpty()) { "variants must not be empty" }
}
}

data class OciVariantInput(
@get:InputFile @get:PathSensitive(PathSensitivity.NONE) val metadataFile: File,
Expand Down Expand Up @@ -86,7 +90,8 @@ abstract class OciImagesInputTask : DefaultTask() {
val variants = imageInput.variants.map { variantInput ->
variantInputToVariant.getOrPut(variantInput) { variantInput.toVariant() }
}
val config = createConfig(imageInput.platform, variants)
val platform = imageInput.platform
val config = createConfig(platform, variants)
val manifest = createManifest(config, variants)
val image = OciImage(manifest, config, variants)
images += image
Expand All @@ -96,7 +101,6 @@ abstract class OciImagesInputTask : DefaultTask() {
val imageReferences = imageInput.referenceSpecs.mapTo(LinkedHashSet()) {
OciImageReference(it.name ?: defaultImageReference.name, it.tag ?: defaultImageReference.tag)
}.ifEmpty { setOf(defaultImageReference) }
val platform = imageInput.platform
for (imageReference in imageReferences) {
// platformToImage map is linked to preserve the platform order
val platformToImage = referenceToPlatformToImage.getOrPut(imageReference) { LinkedHashMap() }
Expand Down

0 comments on commit 7f6b6b9

Please sign in to comment.