-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathInstallController.scala
61 lines (54 loc) · 1.88 KB
/
InstallController.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package controllers
import domain.Platform
import play.api.Configuration
import play.api.mvc.{AbstractController, ControllerComponents}
import repo.ApplicationRepo
import javax.inject.Inject
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
class InstallController @Inject() (
cc: ControllerComponents,
appRepo: ApplicationRepo,
config: Configuration
) extends AbstractController(cc) {
private val stableBaseUrlO = configUrl("service.stableBaseUrl")
private val betaBaseUrlO = configUrl("service.betaBaseUrl")
def install(beta: Boolean, rcUpdate: Option[Boolean], ci: Option[Boolean]) = Action.async { _ =>
appRepo.findApplication().map { maybeApp =>
val response = for {
stableBaseUrl <- stableBaseUrlO
betaBaseUrl <- betaBaseUrlO
app <- maybeApp
stableVersion = app.stableCliVersion
betaVersion = app.betaCliVersion
stableNativeVersion = app.stableNativeCliVersion
betaNativeVersion = app.betaNativeCliVersion
} yield
if (beta) {
Ok(
views.txt.install_beta(
cliVersion = betaVersion,
cliNativeVersion = betaNativeVersion,
baseUrl = betaBaseUrl,
rcUpdate = rcUpdate.getOrElse(true),
beta = true,
ci = ci.getOrElse(false)
)
)
} else {
Ok(
views.txt.install_stable(
cliVersion = stableVersion,
cliNativeVersion = stableNativeVersion,
baseUrl = stableBaseUrl,
rcUpdate = rcUpdate.getOrElse(true),
beta = false,
ci = ci.getOrElse(false)
)
)
}
response getOrElse ServiceUnavailable
}
}
private def configUrl(url: String): Option[String] = config.getOptional[String](url)
}