diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/OciImagesInput.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/OciImagesInput.kt index f0b8289a..98168704 100644 --- a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/OciImagesInput.kt +++ b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/OciImagesInput.kt @@ -1,7 +1,5 @@ package io.github.sgtsilvio.gradle.oci -import io.github.sgtsilvio.gradle.oci.component.OciMetadata -import io.github.sgtsilvio.gradle.oci.component.decodeAsJsonToOciMetadata import io.github.sgtsilvio.gradle.oci.dsl.ResolvableOciImageDependencies import io.github.sgtsilvio.gradle.oci.metadata.* import io.github.sgtsilvio.gradle.oci.platform.Platform diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/component/OciMetadata.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/component/OciMetadata.kt deleted file mode 100644 index eb65b1ff..00000000 --- a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/component/OciMetadata.kt +++ /dev/null @@ -1,49 +0,0 @@ -package io.github.sgtsilvio.gradle.oci.component - -import io.github.sgtsilvio.gradle.oci.metadata.OciDescriptor -import io.github.sgtsilvio.gradle.oci.metadata.OciDigest -import io.github.sgtsilvio.gradle.oci.metadata.OciImageReference -import java.io.Serializable -import java.time.Instant -import java.util.* - -/** - * @author Silvio Giebl - */ -data class OciMetadata( - val imageReference: OciImageReference, - val creationTime: Instant?, - val author: String?, - val user: String?, - val ports: SortedSet, - val environment: SortedMap, - val entryPoint: List?, // empty (no args) is different from null (not set, inherit) - val arguments: List?, // empty (no args) is different from null (not set, inherit) - val volumes: SortedSet, - val workingDirectory: String?, - val stopSignal: String?, - val configAnnotations: SortedMap, - val configDescriptorAnnotations: SortedMap, - val manifestAnnotations: SortedMap, - val manifestDescriptorAnnotations: SortedMap, - val indexAnnotations: SortedMap, - val layers: List, -) : Serializable { - - data class Layer( - val descriptor: Descriptor?, - val creationTime: Instant?, - val author: String?, - val createdBy: String?, - val comment: String?, - ) : Serializable { - - data class Descriptor( - override val mediaType: String, - override val digest: OciDigest, - override val size: Long, - val diffId: OciDigest, - override val annotations: SortedMap, - ) : OciDescriptor, Serializable - } -} \ No newline at end of file diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciImageDefinitionImpl.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciImageDefinitionImpl.kt index 54b39a7b..c33d90a4 100644 --- a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciImageDefinitionImpl.kt +++ b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/dsl/OciImageDefinitionImpl.kt @@ -10,7 +10,7 @@ import io.github.sgtsilvio.gradle.oci.dsl.OciImageDefinition import io.github.sgtsilvio.gradle.oci.internal.* import io.github.sgtsilvio.gradle.oci.internal.gradle.* import io.github.sgtsilvio.gradle.oci.mapping.defaultMappedImageNamespace -import io.github.sgtsilvio.gradle.oci.metadata.OciImageReference +import io.github.sgtsilvio.gradle.oci.metadata.* import io.github.sgtsilvio.gradle.oci.platform.AllPlatformFilter import io.github.sgtsilvio.gradle.oci.platform.Platform import io.github.sgtsilvio.gradle.oci.platform.PlatformFilter diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/registry/OciMetadataRegistry.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/registry/OciMetadataRegistry.kt index 0884e474..c3f76ea1 100644 --- a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/registry/OciMetadataRegistry.kt +++ b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/registry/OciMetadataRegistry.kt @@ -1,6 +1,5 @@ package io.github.sgtsilvio.gradle.oci.internal.registry -import io.github.sgtsilvio.gradle.oci.component.OciMetadata import io.github.sgtsilvio.gradle.oci.internal.json.* import io.github.sgtsilvio.gradle.oci.metadata.* import io.github.sgtsilvio.gradle.oci.platform.Platform diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/registry/OciRepositoryHandler.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/registry/OciRepositoryHandler.kt index af2642d5..c3a07ca9 100644 --- a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/registry/OciRepositoryHandler.kt +++ b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/internal/registry/OciRepositoryHandler.kt @@ -4,7 +4,6 @@ import com.github.benmanes.caffeine.cache.AsyncCache import com.github.benmanes.caffeine.cache.Caffeine import io.github.sgtsilvio.gradle.oci.attributes.* import io.github.sgtsilvio.gradle.oci.component.VersionedCoordinates -import io.github.sgtsilvio.gradle.oci.component.encodeToJsonString import io.github.sgtsilvio.gradle.oci.internal.* import io.github.sgtsilvio.gradle.oci.internal.cache.getMono import io.github.sgtsilvio.gradle.oci.internal.json.addArray diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/metadata/OciMediaTypes.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/metadata/OciMediaTypes.kt new file mode 100644 index 00000000..f5d9af3b --- /dev/null +++ b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/metadata/OciMediaTypes.kt @@ -0,0 +1,9 @@ +package io.github.sgtsilvio.gradle.oci.metadata + +internal const val INDEX_MEDIA_TYPE = "application/vnd.oci.image.index.v1+json" +internal const val MANIFEST_MEDIA_TYPE = "application/vnd.oci.image.manifest.v1+json" +internal const val CONFIG_MEDIA_TYPE = "application/vnd.oci.image.config.v1+json" +internal const val LAYER_MEDIA_TYPE_PREFIX = "application/vnd.oci.image.layer.v1" +internal const val UNCOMPRESSED_LAYER_MEDIA_TYPE = "$LAYER_MEDIA_TYPE_PREFIX.tar" +internal const val GZIP_COMPRESSED_LAYER_MEDIA_TYPE = "$LAYER_MEDIA_TYPE_PREFIX.tar+gzip" +//internal const val ZSTD_COMPRESSED_LAYER_MEDIA_TYPE = "$LAYER_MEDIA_TYPE_PREFIX.tar+zstd" diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/metadata/OciMetadata.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/metadata/OciMetadata.kt index ac86b8bc..f378b331 100644 --- a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/metadata/OciMetadata.kt +++ b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/metadata/OciMetadata.kt @@ -4,14 +4,50 @@ import io.github.sgtsilvio.gradle.oci.OciImage import io.github.sgtsilvio.gradle.oci.OciVariant import io.github.sgtsilvio.gradle.oci.internal.json.* import io.github.sgtsilvio.gradle.oci.platform.Platform +import java.io.Serializable +import java.time.Instant import java.util.* -internal const val INDEX_MEDIA_TYPE = "application/vnd.oci.image.index.v1+json" -internal const val MANIFEST_MEDIA_TYPE = "application/vnd.oci.image.manifest.v1+json" -internal const val CONFIG_MEDIA_TYPE = "application/vnd.oci.image.config.v1+json" -internal const val LAYER_MEDIA_TYPE_PREFIX = "application/vnd.oci.image.layer.v1" -internal const val UNCOMPRESSED_LAYER_MEDIA_TYPE = "$LAYER_MEDIA_TYPE_PREFIX.tar" -internal const val GZIP_COMPRESSED_LAYER_MEDIA_TYPE = "$LAYER_MEDIA_TYPE_PREFIX.tar+gzip" +/** + * @author Silvio Giebl + */ +data class OciMetadata( + val imageReference: OciImageReference, + val creationTime: Instant?, + val author: String?, + val user: String?, + val ports: SortedSet, + val environment: SortedMap, + val entryPoint: List?, // empty (no args) is different from null (not set, inherit) + val arguments: List?, // empty (no args) is different from null (not set, inherit) + val volumes: SortedSet, + val workingDirectory: String?, + val stopSignal: String?, + val configAnnotations: SortedMap, + val configDescriptorAnnotations: SortedMap, + val manifestAnnotations: SortedMap, + val manifestDescriptorAnnotations: SortedMap, + val indexAnnotations: SortedMap, + val layers: List, +) : Serializable { + + data class Layer( + val descriptor: Descriptor?, + val creationTime: Instant?, + val author: String?, + val createdBy: String?, + val comment: String?, + ) : Serializable { + + data class Descriptor( + override val mediaType: String, + override val digest: OciDigest, + override val size: Long, + val diffId: OciDigest, + override val annotations: SortedMap, + ) : OciDescriptor, Serializable + } +} internal fun createConfig(platform: Platform, variants: List): OciDataDescriptor { var user: String? = null diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/component/OciMetadataBuilder.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/metadata/OciMetadataBuilder.kt similarity index 96% rename from src/main/kotlin/io/github/sgtsilvio/gradle/oci/component/OciMetadataBuilder.kt rename to src/main/kotlin/io/github/sgtsilvio/gradle/oci/metadata/OciMetadataBuilder.kt index e3228235..0a457118 100644 --- a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/component/OciMetadataBuilder.kt +++ b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/metadata/OciMetadataBuilder.kt @@ -1,7 +1,5 @@ -package io.github.sgtsilvio.gradle.oci.component +package io.github.sgtsilvio.gradle.oci.metadata -import io.github.sgtsilvio.gradle.oci.metadata.OciDigest -import io.github.sgtsilvio.gradle.oci.metadata.OciImageReference import java.io.Serializable import java.time.Instant diff --git a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/component/OciMetadataJsonCodec.kt b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/metadata/OciMetadataJsonCodec.kt similarity index 93% rename from src/main/kotlin/io/github/sgtsilvio/gradle/oci/component/OciMetadataJsonCodec.kt rename to src/main/kotlin/io/github/sgtsilvio/gradle/oci/metadata/OciMetadataJsonCodec.kt index 5b4a0c10..e04c0b02 100644 --- a/src/main/kotlin/io/github/sgtsilvio/gradle/oci/component/OciMetadataJsonCodec.kt +++ b/src/main/kotlin/io/github/sgtsilvio/gradle/oci/metadata/OciMetadataJsonCodec.kt @@ -1,9 +1,6 @@ -package io.github.sgtsilvio.gradle.oci.component +package io.github.sgtsilvio.gradle.oci.metadata import io.github.sgtsilvio.gradle.oci.internal.json.* -import io.github.sgtsilvio.gradle.oci.metadata.GZIP_COMPRESSED_LAYER_MEDIA_TYPE -import io.github.sgtsilvio.gradle.oci.metadata.getOciDigest -import io.github.sgtsilvio.gradle.oci.metadata.toOciImageReference internal fun OciMetadata.encodeToJsonString() = jsonObject { encodeOciMetadata(this@encodeToJsonString) }