Skip to content

Commit

Permalink
Add wave mirror vs module bundles conflicst warning
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
  • Loading branch information
pditommaso committed Oct 20, 2024
1 parent a69407d commit b37a8a5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import nextflow.util.CacheHelper
*/
@Canonical
@CompileStatic
@ToString(includePackage = false, includeNames = true)
@ToString(includePackage = false, includeNames = true, ignoreNulls = true)
class ContainerConfig {

List<String> entrypoint
Expand Down Expand Up @@ -108,4 +108,16 @@ class ContainerConfig {
}
return CacheHelper.hasher(allMeta).hash().toString()
}

boolean asBoolean() {
return !empty()
}

boolean empty() {
return !entrypoint &&
!cmd &&
!env &&
!workingDir &&
!layers
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class WaveClient {
}

SubmitContainerTokenRequest makeRequest(WaveAssets assets) {
final containerConfig = assets.containerConfig ?: new ContainerConfig()
ContainerConfig containerConfig = assets.containerConfig ?: new ContainerConfig()
// prepend the bundle layer
if( assets.moduleResources!=null && assets.moduleResources.hasEntries() ) {
containerConfig.prependLayer(makeLayer(assets.moduleResources))
Expand Down Expand Up @@ -202,6 +202,11 @@ class WaveClient {
if( config.mirrorMode() && !assets.containerImage )
throw new IllegalArgumentException("Invalid container mirror operation - missing source container")

if( config.mirrorMode() && containerConfig ) {
log.warn1("Wave configuration setting 'wave.mirror' conflicts with the use of module bundles - ignoring custom config for container: $assets.containerImage")
containerConfig = null
}

return new SubmitContainerTokenRequest(
containerImage: assets.containerImage,
containerPlatform: assets.containerPlatform,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,20 @@ class ContainerConfigTest extends Specification {
fusion1.fingerprint() != fusion2.fingerprint()
config1.fingerprint() == config2.fingerprint()
}

def 'should validate empty' () {
expect:
new ContainerConfig().empty()
new ContainerConfig([], null, null, null, null).empty()
new ContainerConfig(null, [], null, null, null).empty()
new ContainerConfig(null, null, [], null, null).empty()
new ContainerConfig(null, null, null, '', null).empty()
new ContainerConfig(null, null, null, null, []).empty()
and:
!new ContainerConfig(['x'], null, null, null, null).empty()
!new ContainerConfig(null, ['x'], null, null, null).empty()
!new ContainerConfig(null, null, ['x'], null, null).empty()
!new ContainerConfig(null, null, null, 'x', null).empty()
!new ContainerConfig(null, null, null, null, [new ContainerLayer()]).empty()
}
}

0 comments on commit b37a8a5

Please sign in to comment.