-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move OciImageReferenceSpec and related functions to own file
- Loading branch information
Showing
4 changed files
with
28 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/ResolvableOciImageDependenciesImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/io/github/sgtsilvio/gradle/oci/metadata/OciImageReferenceSpec.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.github.sgtsilvio.gradle.oci.metadata | ||
|
||
import java.io.Serializable | ||
|
||
/** | ||
* @author Silvio Giebl | ||
*/ | ||
data class OciImageReferenceSpec(val name: String?, val tag: String?) : Serializable { | ||
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 fun OciImageReferenceSpec.materialize(default: OciImageReference) = | ||
OciImageReference(name ?: default.name, tag ?: default.tag) | ||
|
||
internal fun String.toOciImageReferenceSpec(): OciImageReferenceSpec { | ||
val parts = split(':') | ||
require(parts.size == 2) { "'$this' must contain exactly one ':' character" } | ||
return OciImageReferenceSpec(parts[0].takeIf { it.isNotEmpty() }, parts[1].takeIf { it.isNotEmpty() }) | ||
} |