Skip to content

Commit

Permalink
Add OciExtension.copySpec() and OciExtension.copySpec(Action)
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtSilvio committed May 26, 2024
1 parent 9910ef7 commit 683ebc6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.*
import org.gradle.kotlin.dsl.newInstance
import org.gradle.kotlin.dsl.property
import java.io.FileInputStream
import java.io.FileOutputStream
Expand All @@ -25,7 +24,7 @@ import java.util.zip.GZIPOutputStream
*/
abstract class OciLayerTask : DefaultTask() {

private val _contents = project.objects.newInstance<OciCopySpecImpl>()
private val _contents = project.objects.newOciCopySpec()

@get:Nested
protected val copySpecInput = _contents.asInput(project.providers)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.sgtsilvio.gradle.oci.dsl

import io.github.sgtsilvio.gradle.oci.OciCopySpec
import io.github.sgtsilvio.gradle.oci.OciLayerTask
import io.github.sgtsilvio.gradle.oci.OciPushTask
import io.github.sgtsilvio.gradle.oci.OciRegistryDataTask
Expand Down Expand Up @@ -45,4 +46,8 @@ interface OciExtension {
val variants: SetProperty<String>
val osVersions: SetProperty<String>
}

fun copySpec(): OciCopySpec

fun copySpec(configuration: Action<in OciCopySpec>): OciCopySpec
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,5 @@ abstract class OciCopySpecImpl @Inject constructor(private val objectFactory: Ob
return providerFactory.provider { lazy.value }
}
}

internal fun ObjectFactory.newOciCopySpec() = newInstance<OciCopySpecImpl>()
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package io.github.sgtsilvio.gradle.oci.internal.dsl

import io.github.sgtsilvio.gradle.oci.OciCopySpec
import io.github.sgtsilvio.gradle.oci.dsl.OciExtension
import io.github.sgtsilvio.gradle.oci.dsl.OciImageDefinition
import io.github.sgtsilvio.gradle.oci.dsl.OciRegistries
import io.github.sgtsilvio.gradle.oci.dsl.ResolvableOciImageDependencies
import io.github.sgtsilvio.gradle.oci.internal.copyspec.OciCopySpecImpl
import io.github.sgtsilvio.gradle.oci.internal.copyspec.newOciCopySpec
import io.github.sgtsilvio.gradle.oci.mapping.OciImageMapping
import io.github.sgtsilvio.gradle.oci.mapping.OciImageMappingImpl
import io.github.sgtsilvio.gradle.oci.platform.Platform
Expand Down Expand Up @@ -65,4 +68,12 @@ internal abstract class OciExtensionImpl @Inject constructor(private val objectF

final override fun PlatformFilter.or(configuration: Action<in OciExtension.PlatformFilterBuilder>) =
or(platformFilter(configuration))

final override fun copySpec() = objectFactory.newOciCopySpec()

final override fun copySpec(configuration: Action<in OciCopySpec>): OciCopySpecImpl {
val copySpec = copySpec()
configuration.execute(copySpec)
return copySpec
}
}

0 comments on commit 683ebc6

Please sign in to comment.