Token filtering for gvm and vertx versions in server script. Rework config.

This commit is contained in:
Marco Vermeulen
2012-12-03 10:41:22 +00:00
parent d17e4a0f3d
commit 390df8097a
3 changed files with 10 additions and 27 deletions

View File

@@ -46,7 +46,7 @@ task prepareServer(type: Copy){
from 'src/main/resources'
into 'build/server'
include 'server.groovy'
filter(ReplaceTokens, tokens: [GVM_VERSION:config.gvmVersion])
filter(ReplaceTokens, tokens: [GVM_VERSION:config.gvmVersion, VERTX_VERSION:config.vertxVersion])
}
task prepareScripts(type: Copy) {

View File

@@ -1,14 +1,13 @@
vertxVersion = '1.3.0.final'
gvmVersion = '0.8.3'
environments {
dev {
gvmVersion = '0.8.3'
gvmService = 'http://localhost:8080'
}
test {
gvmVersion = '0.8.3'
gvmService = 'http://test.gvmtool.net'
}
prod {
gvmVersion = '0.8.3'
gvmService = 'http://get.gvmtool.net'
}
}

View File

@@ -3,6 +3,8 @@ import java.util.zip.*
import org.vertx.groovy.core.http.RouteMatcher
import org.vertx.java.core.json.JsonObject
final GVM_VERSION = '@GVM_VERSION@'
final VERTX_VERSION = '@VERTX_VERSION@'
//
// datasource configuration
@@ -42,12 +44,7 @@ rm.get("/alive") { req ->
}
rm.get("/res") { req ->
def cmd = [action:"find", collection:"application", matcher:[_id:1]]
vertx.eventBus.send("mongo-persistor", cmd){ msg ->
addPlainTextHeader req
def gvmVersion = msg.body.results[0].gvmVersion
log 'initialise', 'gvm', gvmVersion, req
}
log 'initialise', 'gvm', GVM_VERSION, req
def zipFile = new File('build/distributions/gvm-scripts.zip')
req.response.putHeader("Content-Type", "application/zip")
@@ -136,34 +133,21 @@ rm.get("/download/:candidate/:version") { req ->
}
rm.get("/app/version") { req ->
def cmd = [action:"find", collection:"application", matcher:[_id:1]]
vertx.eventBus.send("mongo-persistor", cmd){ msg ->
addPlainTextHeader req
def gvmVersion = "${msg.body.results[0].gvmVersion}"
req.response.end gvmVersion
}
req.response.end GVM_VERSION
}
rm.get("/broadcast/:version") { req ->
def gvmVersion, vertxVersion
def cmd1 = [action:"find", collection:"application", matcher:[_id:1]]
vertx.eventBus.send("mongo-persistor", cmd1){ msg ->
addPlainTextHeader req
gvmVersion = "${msg.body.results[0].gvmVersion}"
vertxVersion = "${msg.body.results[0].vertxVersion}"
}
def cmd2 = [action:"find", collection:"broadcast", matcher:[:]]
vertx.eventBus.send("mongo-persistor", cmd2){ msg ->
def broadcasts = msg.body.results
def version = req.params['version']
def gtpFile, binding
if(gvmVersion == version){
if(GVM_VERSION == version){
gtplFile = new File('build/templates/broadcast.gtpl')
binding = [gvmVersion:gvmVersion, vertxVersion:vertxVersion, broadcasts:broadcasts]
binding = [gvmVersion:GVM_VERSION, vertxVersion:VERTX_VERSION, broadcasts:broadcasts]
} else {
gtplFile = new File('build/templates/upgrade.gtpl')
binding = [version:version, gvmVersion:gvmVersion]
binding = [version:version, gvmVersion:GVM_VERSION]
}
def templateText = templateEngine.createTemplate(gtplFile).make(binding).toString()