Skip to content

Commit

Permalink
Move OciMetadata(Builder/JsonCodec) to metadata package
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtSilvio committed Jul 9, 2024
1 parent 894c8c1 commit 4587b97
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
val environment: SortedMap<String, String>,
val entryPoint: List<String>?, // empty (no args) is different from null (not set, inherit)
val arguments: List<String>?, // empty (no args) is different from null (not set, inherit)
val volumes: SortedSet<String>,
val workingDirectory: String?,
val stopSignal: String?,
val configAnnotations: SortedMap<String, String>,
val configDescriptorAnnotations: SortedMap<String, String>,
val manifestAnnotations: SortedMap<String, String>,
val manifestDescriptorAnnotations: SortedMap<String, String>,
val indexAnnotations: SortedMap<String, String>,
val layers: List<Layer>,
) : 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<String, String>,
) : OciDescriptor, Serializable
}
}

internal fun createConfig(platform: Platform, variants: List<OciVariant>): OciDataDescriptor {
var user: String? = null
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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) }

Expand Down

0 comments on commit 4587b97

Please sign in to comment.