Skip to content

Commit

Permalink
Cleanup OciImageReferenceSpec.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtSilvio committed Jul 18, 2024
1 parent d7ee630 commit 432a53f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import io.github.sgtsilvio.gradle.oci.attributes.MULTI_PLATFORM_ATTRIBUTE_VALUE
import io.github.sgtsilvio.gradle.oci.attributes.OCI_IMAGE_REFERENCE_ATTRIBUTE
import io.github.sgtsilvio.gradle.oci.attributes.PLATFORM_ATTRIBUTE
import io.github.sgtsilvio.gradle.oci.attributes.UNIVERSAL_PLATFORM_ATTRIBUTE_VALUE
import io.github.sgtsilvio.gradle.oci.metadata.DEFAULT_OCI_REFERENCE_SPEC
import io.github.sgtsilvio.gradle.oci.metadata.DEFAULT_OCI_IMAGE_REFERENCE_SPEC
import io.github.sgtsilvio.gradle.oci.metadata.OciImageReferenceSpec
import io.github.sgtsilvio.gradle.oci.metadata.toOciImageReferenceSpec
import io.github.sgtsilvio.gradle.oci.platform.Platform
Expand Down Expand Up @@ -40,7 +40,7 @@ private fun resolveOciVariantGraph(
val referenceSpecs = dependencyResult.requested.attributes.getAttribute(OCI_IMAGE_REFERENCE_ATTRIBUTE)
?.split(',')
?.map { it.toOciImageReferenceSpec() }
?: listOf(DEFAULT_OCI_REFERENCE_SPEC)
?: listOf(DEFAULT_OCI_IMAGE_REFERENCE_SPEC)
val node = resolveOciVariantNode(dependencyResult.selected, dependencyResult.resolvedVariant, nodes)
rootNodesToReferenceSpecs.getOrPut(node) { HashSet() }.addAll(referenceSpecs)
}
Expand Down Expand Up @@ -189,4 +189,4 @@ private fun OciVariantNode.collectVariantResultsForPlatform(
}

private fun Set<OciImageReferenceSpec>.normalize(): Set<OciImageReferenceSpec> =
if ((size == 1) && contains(DEFAULT_OCI_REFERENCE_SPEC)) emptySet() else this
if ((size == 1) && contains(DEFAULT_OCI_IMAGE_REFERENCE_SPEC)) emptySet() else this
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ data class OciImageReferenceSpec(val name: String?, val tag: String?) : Serializ
override fun toString() = (name ?: "") + ":" + (tag ?: "")
}

// TODO factory method for OciImageReferenceSpec that returns DEFAULT_OCI_REFERENCE_SPEC if both are null
internal val DEFAULT_OCI_REFERENCE_SPEC = OciImageReferenceSpec(null, null)
internal val DEFAULT_OCI_IMAGE_REFERENCE_SPEC = OciImageReferenceSpec(null, null)

internal fun OciImageReferenceSpec.materialize(default: OciImageReference) =
OciImageReference(name ?: default.name, tag ?: default.tag)
Expand Down

0 comments on commit 432a53f

Please sign in to comment.