mirror of
https://github.com/VinylDNS/vinyldns
synced 2025-08-22 02:02:14 +00:00
Adding version to login (#372)
* Adding version to login * Allow override of version * Have default version based on build * Adding version to local dev
This commit is contained in:
parent
2d875d014b
commit
469e49e6f6
14
build.sbt
14
build.sbt
@ -88,7 +88,10 @@ lazy val apiSettings = Seq(
|
||||
name := "api",
|
||||
libraryDependencies ++= apiDependencies ++ apiTestDependencies.map(_ % "test, it"),
|
||||
mainClass := Some("vinyldns.api.Boot"),
|
||||
javaOptions in reStart += "-Dlogback.configurationFile=test/logback.xml",
|
||||
javaOptions in reStart ++= Seq(
|
||||
"-Dlogback.configurationFile=test/logback.xml",
|
||||
s"""-Dvinyldns.base-version=${(version in ThisBuild).value}"""
|
||||
),
|
||||
coverageExcludedPackages := ".*Boot.*"
|
||||
)
|
||||
|
||||
@ -123,6 +126,9 @@ lazy val apiDockerSettings = Seq(
|
||||
// adds config file to mount
|
||||
bashScriptExtraDefines += """addJava "-Dconfig.file=${app_home}/../conf/application.conf"""",
|
||||
bashScriptExtraDefines += """addJava "-Dlogback.configurationFile=${app_home}/../conf/logback.xml"""", // adds logback
|
||||
|
||||
// this is the default version, can be overridden
|
||||
bashScriptExtraDefines += s"""addJava "-Dvinyldns.base-version=${(version in ThisBuild).value}"""",
|
||||
bashScriptExtraDefines += "(cd ${app_home} && ./wait-for-dependencies.sh && cd -)",
|
||||
credentials in Docker := Seq(Credentials(Path.userHome / ".ivy2" / ".dockerCredentials")),
|
||||
dockerCommands ++= Seq(
|
||||
@ -148,6 +154,9 @@ lazy val portalDockerSettings = Seq(
|
||||
// adds config file to mount
|
||||
bashScriptExtraDefines += """addJava "-Dconfig.file=/opt/docker/conf/application.conf"""",
|
||||
bashScriptExtraDefines += """addJava "-Dlogback.configurationFile=/opt/docker/conf/logback.xml"""",
|
||||
|
||||
// this is the default version, can be overridden
|
||||
bashScriptExtraDefines += s"""addJava "-Dvinyldns.base-version=${(version in ThisBuild).value}"""",
|
||||
credentials in Docker := Seq(Credentials(Path.userHome / ".ivy2" / ".dockerCredentials"))
|
||||
)
|
||||
|
||||
@ -333,6 +342,9 @@ lazy val portal = (project in file("modules/portal")).enablePlugins(PlayScala, A
|
||||
coverageExcludedPackages := "<empty>;views.html.*;router.*",
|
||||
javaOptions in Test += "-Dconfig.file=conf/application-test.conf",
|
||||
|
||||
// ads the version when working locally with sbt run
|
||||
PlayKeys.devSettings += "vinyldns.base-version" -> (version in ThisBuild).value,
|
||||
|
||||
// adds an extra classpath to the portal loading so we can externalize jars, make sure to create the lib_extra
|
||||
// directory and lay down any dependencies that are required when deploying
|
||||
scriptClasspath in bashScriptDefines ~= (cp => cp :+ "lib_extra/*"),
|
||||
|
@ -40,7 +40,8 @@ vinyldns {
|
||||
color = "green"
|
||||
|
||||
# version of vinyldns
|
||||
version = "unknown"
|
||||
base-version = "unset"
|
||||
version = ${vinyldns.base-version}
|
||||
|
||||
# time users have to wait to resync a zone
|
||||
sync-delay = 600000
|
||||
|
@ -50,7 +50,7 @@ class StatusRoutingSpec
|
||||
resultStatus.processingDisabled shouldBe false
|
||||
resultStatus.color shouldBe "blue"
|
||||
resultStatus.keyName shouldBe "vinyldns."
|
||||
resultStatus.version shouldBe "unknown"
|
||||
resultStatus.version shouldBe "unset"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,11 @@
|
||||
# own settings
|
||||
vinyldns {
|
||||
|
||||
# Should be provided in the start up script via an environment
|
||||
base-version = "unset"
|
||||
version = ${vinyldns.base-version} # default to the base version if not overridden
|
||||
version = ${?VINYLDNS_VERSION} # override the base version via env var
|
||||
|
||||
queue.settings.service-endpoint = "http://vinyldns-elasticmq:9324/"
|
||||
|
||||
# host and port the server binds to. This should not be changed
|
||||
|
@ -18,7 +18,7 @@ package controllers
|
||||
|
||||
import actions.FrontendAction
|
||||
import javax.inject.{Inject, Singleton}
|
||||
import models.CustomLinks
|
||||
import models.{CustomLinks, Meta}
|
||||
import org.slf4j.LoggerFactory
|
||||
import play.api.Logger
|
||||
import play.api.mvc._
|
||||
@ -40,6 +40,7 @@ class FrontendController @Inject()(
|
||||
private val userAction = Action.andThen(new FrontendAction(userAccountAccessor.get))
|
||||
|
||||
implicit lazy val customLinks: CustomLinks = CustomLinks(configuration)
|
||||
implicit lazy val meta: Meta = Meta(configuration)
|
||||
private val logger = LoggerFactory.getLogger(classOf[FrontendController])
|
||||
|
||||
def loginPage(): Action[AnyContent] = Action { implicit request =>
|
||||
|
24
modules/portal/app/models/Meta.scala
Normal file
24
modules/portal/app/models/Meta.scala
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2018 Comcast Cable Communications Management, LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package models
|
||||
import play.api.Configuration
|
||||
|
||||
case class Meta(version: String)
|
||||
object Meta {
|
||||
def apply(config: Configuration): Meta =
|
||||
Meta(config.getOptional[String]("vinyldns.version").getOrElse("unknown"))
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
@import helper.CSRF
|
||||
@(alertMessage: Option[String] = None)(implicit requestHeader: RequestHeader, customLinks: models.CustomLinks)
|
||||
@(alertMessage: Option[String] = None)(implicit requestHeader: RequestHeader, customLinks: models.CustomLinks, meta: models.Meta)
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="body-full-height">
|
||||
<head>
|
||||
@ -42,7 +42,7 @@
|
||||
</div>
|
||||
<div class="vinyldns-login-footer">
|
||||
<div class="pull-left">
|
||||
VinylDNS, for all your DNS needs.
|
||||
VinylDNS (version @{meta.version})
|
||||
<ul class="login-links">
|
||||
@*****************************************
|
||||
* Custom links from application config *
|
||||
|
@ -1,2 +0,0 @@
|
||||
# set custom trustStore
|
||||
#-Djavax.net.ssl.trustStore=...
|
@ -154,5 +154,10 @@ links = [
|
||||
|
||||
play.modules.enabled += "modules.VinylDNSModule"
|
||||
|
||||
# base version this image is built on
|
||||
vinyldns.base-version = "unset"
|
||||
vinyldns.version = ${vinyldns.base-version} # default to the base version if not overridden
|
||||
vinyldns.version = ${?VINYLDNS_VERSION} # can override via an environment varaible
|
||||
|
||||
// Local.conf has files specific to your environment, for example your own LDAP settings
|
||||
include "local.conf"
|
||||
|
29
modules/portal/test/models/MetaSpec.scala
Normal file
29
modules/portal/test/models/MetaSpec.scala
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2018 Comcast Cable Communications Management, LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package models
|
||||
import org.specs2.mock.Mockito
|
||||
import org.specs2.mutable.Specification
|
||||
import play.api.Configuration
|
||||
|
||||
class MetaSpec extends Specification with Mockito {
|
||||
"Meta" should {
|
||||
"load from config" in {
|
||||
val config = Map("vinyldns.version" -> "foo-bar")
|
||||
Meta(Configuration.from(config)).version must beEqualTo("foo-bar")
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user