Skip to content

Commit

Permalink
Fix Include cached only with build
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso committed Oct 14, 2024
1 parent 900c1e4 commit 0a16554
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/main/groovy/io/seqera/wave/util/ContainerHelper.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,11 @@ class ContainerHelper {
static SubmitContainerTokenResponse makeResponseV2(ContainerRequest data, TokenData token, String waveImage) {
final target = data.durable() ? data.containerImage : waveImage
final build = data.buildId
final Boolean cached = !data.buildNew
// cached only applied when there's a buildId (which includes mirror)
final Boolean cached = data.buildId ? !data.buildNew : null
final expiration = !data.durable() ? token.expiration : null
final tokenId = !data.durable() ? token.value : null
// when a scan is requested, succeed is not determined (because it depends on the scan result), therefore return null
final Boolean succeeded = !data.scanId ? data.succeeded : null
return new SubmitContainerTokenResponse(data.requestId, tokenId, target, expiration, data.containerImage, build, cached, data.freeze, data.mirror, data.scanId, succeeded)
}
Expand Down
23 changes: 13 additions & 10 deletions src/test/groovy/io/seqera/wave/util/ContainerHelperTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class ContainerHelperTest extends Specification {
given:
def data = ContainerRequest.of(
containerImage: 'docker.io/some/container',
buildId: "build-123",
buildId: BUILD_ID,
buildNew: NEW_BUILD,
freeze: IS_FREEZE,
type: TYPE,
Expand All @@ -266,7 +266,6 @@ class ContainerHelperTest extends Specification {
def target = 'wave.com/this/that'
and:
def EXPECTED_IMAGE = 'docker.io/some/container'
def EXPECTED_BUILD = 'build-123'
def EXPECTED_SCAN = 'scan-123'

when:
Expand All @@ -276,23 +275,27 @@ class ContainerHelperTest extends Specification {
containerToken == EXPECT_TOKEN
containerImage == EXPECTED_IMAGE
targetImage == EXPECT_TARGET
buildId == EXPECTED_BUILD
buildId == BUILD_ID
cached == EXPECT_CACHE
freeze == IS_FREEZE
mirror == EXPECT_MIRROR
scanId == EXPECTED_SCAN
}

where:
TYPE | NEW_BUILD | IS_FREEZE | EXPECT_MIRROR | EXPECT_TOKEN | EXPECT_TARGET | EXPECT_CACHE
Type.Build | false | false | false | '123abc' | 'wave.com/this/that' | true
Type.Build | true | false | false | '123abc' | 'wave.com/this/that' | false
TYPE | BUILD_ID | NEW_BUILD | IS_FREEZE | EXPECT_MIRROR | EXPECT_TOKEN | EXPECT_TARGET | EXPECT_CACHE
Type.Build | 'build-123' | false | false | false | '123abc' | 'wave.com/this/that' | true
Type.Build | 'build-123' | true | false | false | '123abc' | 'wave.com/this/that' | false
Type.Build | 'build-123' | false | true | false | null | 'docker.io/some/container' | true
and:
Type.Build | false | true | false | null | 'docker.io/some/container'| true
Type.Build | true | true | false | null | 'docker.io/some/container'| false
Type.Build | 'build-123' | true | true | false | null | 'docker.io/some/container' | false
and:
Type.Mirror | false | false | true | null | 'docker.io/some/container'| true
Type.Mirror | true | false | true | null | 'docker.io/some/container'| false
Type.Mirror | 'mr-123' | false | false | true | null | 'docker.io/some/container' | true
Type.Mirror | 'mr-123' | true | false | true | null | 'docker.io/some/container' | false
and:
Type.Container | null | true | false | false | '123abc' | 'wave.com/this/that' | null
Type.Container | 'bd-123' | true | false | false | '123abc' | 'wave.com/this/that' | false
Type.Container | 'bd-123' | true | true | false | null | 'docker.io/some/container' | false
}

def 'should check if is a conda lock file' () {
Expand Down

0 comments on commit 0a16554

Please sign in to comment.