Skip to content

Commit

Permalink
added /v1alpha2/container/{containerId} (#609)
Browse files Browse the repository at this point in the history
Signed-off-by: munishchouhan <[email protected]>
  • Loading branch information
munishchouhan authored and pditommaso committed Aug 23, 2024
1 parent 9e15b45 commit 5221b5a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -470,4 +470,12 @@ class ContainerController {
.header(WWW_AUTHENTICATE, "Basic realm=Wave Authentication")
}

@Get('/v1alpha2/container/{containerId}')
HttpResponse<WaveContainerRecord> getContainerDetails(String containerId) {
final data = persistenceService.loadContainerRequest(containerId)
if( !data )
return HttpResponse.notFound()
return HttpResponse.ok(data)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import io.seqera.wave.service.inspect.ContainerInspectServiceImpl
import io.seqera.wave.service.pairing.PairingService
import io.seqera.wave.service.pairing.socket.PairingChannel
import io.seqera.wave.service.persistence.PersistenceService
import io.seqera.wave.service.persistence.WaveContainerRecord
import io.seqera.wave.service.token.ContainerTokenService
import io.seqera.wave.service.token.TokenData
import io.seqera.wave.service.validation.ValidationServiceImpl
Expand Down Expand Up @@ -611,4 +612,27 @@ class ContainerControllerTest extends Specification {
then:
noExceptionThrown()
}
def '/v1alpha2/container/{containerId} should return a container record' () {
given:
def body = new SubmitContainerTokenRequest(containerImage: 'hello-world')
def req1 = HttpRequest.POST("/container-token", body)
def resp1 = client.toBlocking().exchange(req1, SubmitContainerTokenResponse)
and:
resp1.status() == HttpStatus.OK
and:
def containerId = resp1.body().containerToken
when:
def req2 = HttpRequest.GET("/v1alpha2/container/${containerId}")
def resp2 = client.toBlocking().exchange(req2, WaveContainerRecord)
then:
resp2.status() == HttpStatus.OK
and:
def result = resp2.body()
and:
result.containerImage == 'hello-world'
result.sourceImage == 'docker.io/library/hello-world:latest'
result.waveImage == resp1.body().targetImage
}
}

0 comments on commit 5221b5a

Please sign in to comment.