2
0
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:
Paul Cleary 2018-12-05 15:29:22 -05:00 committed by GitHub
parent 2d875d014b
commit 469e49e6f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 83 additions and 8 deletions

View File

@ -88,7 +88,10 @@ lazy val apiSettings = Seq(
name := "api", name := "api",
libraryDependencies ++= apiDependencies ++ apiTestDependencies.map(_ % "test, it"), libraryDependencies ++= apiDependencies ++ apiTestDependencies.map(_ % "test, it"),
mainClass := Some("vinyldns.api.Boot"), 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.*" coverageExcludedPackages := ".*Boot.*"
) )
@ -123,6 +126,9 @@ lazy val apiDockerSettings = Seq(
// adds config file to mount // adds config file to mount
bashScriptExtraDefines += """addJava "-Dconfig.file=${app_home}/../conf/application.conf"""", bashScriptExtraDefines += """addJava "-Dconfig.file=${app_home}/../conf/application.conf"""",
bashScriptExtraDefines += """addJava "-Dlogback.configurationFile=${app_home}/../conf/logback.xml"""", // adds logback 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 -)", bashScriptExtraDefines += "(cd ${app_home} && ./wait-for-dependencies.sh && cd -)",
credentials in Docker := Seq(Credentials(Path.userHome / ".ivy2" / ".dockerCredentials")), credentials in Docker := Seq(Credentials(Path.userHome / ".ivy2" / ".dockerCredentials")),
dockerCommands ++= Seq( dockerCommands ++= Seq(
@ -148,6 +154,9 @@ lazy val portalDockerSettings = Seq(
// adds config file to mount // adds config file to mount
bashScriptExtraDefines += """addJava "-Dconfig.file=/opt/docker/conf/application.conf"""", bashScriptExtraDefines += """addJava "-Dconfig.file=/opt/docker/conf/application.conf"""",
bashScriptExtraDefines += """addJava "-Dlogback.configurationFile=/opt/docker/conf/logback.xml"""", 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")) credentials in Docker := Seq(Credentials(Path.userHome / ".ivy2" / ".dockerCredentials"))
) )
@ -332,6 +341,9 @@ lazy val portal = (project in file("modules/portal")).enablePlugins(PlayScala, A
routesGenerator := InjectedRoutesGenerator, routesGenerator := InjectedRoutesGenerator,
coverageExcludedPackages := "<empty>;views.html.*;router.*", coverageExcludedPackages := "<empty>;views.html.*;router.*",
javaOptions in Test += "-Dconfig.file=conf/application-test.conf", 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 // 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 // directory and lay down any dependencies that are required when deploying

View File

@ -40,7 +40,8 @@ vinyldns {
color = "green" color = "green"
# version of vinyldns # version of vinyldns
version = "unknown" base-version = "unset"
version = ${vinyldns.base-version}
# time users have to wait to resync a zone # time users have to wait to resync a zone
sync-delay = 600000 sync-delay = 600000

View File

@ -50,7 +50,7 @@ class StatusRoutingSpec
resultStatus.processingDisabled shouldBe false resultStatus.processingDisabled shouldBe false
resultStatus.color shouldBe "blue" resultStatus.color shouldBe "blue"
resultStatus.keyName shouldBe "vinyldns." resultStatus.keyName shouldBe "vinyldns."
resultStatus.version shouldBe "unknown" resultStatus.version shouldBe "unset"
} }
} }
} }

View File

@ -3,6 +3,11 @@
# own settings # own settings
vinyldns { 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/" queue.settings.service-endpoint = "http://vinyldns-elasticmq:9324/"
# host and port the server binds to. This should not be changed # host and port the server binds to. This should not be changed

View File

@ -18,7 +18,7 @@ package controllers
import actions.FrontendAction import actions.FrontendAction
import javax.inject.{Inject, Singleton} import javax.inject.{Inject, Singleton}
import models.CustomLinks import models.{CustomLinks, Meta}
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import play.api.Logger import play.api.Logger
import play.api.mvc._ import play.api.mvc._
@ -40,6 +40,7 @@ class FrontendController @Inject()(
private val userAction = Action.andThen(new FrontendAction(userAccountAccessor.get)) private val userAction = Action.andThen(new FrontendAction(userAccountAccessor.get))
implicit lazy val customLinks: CustomLinks = CustomLinks(configuration) implicit lazy val customLinks: CustomLinks = CustomLinks(configuration)
implicit lazy val meta: Meta = Meta(configuration)
private val logger = LoggerFactory.getLogger(classOf[FrontendController]) private val logger = LoggerFactory.getLogger(classOf[FrontendController])
def loginPage(): Action[AnyContent] = Action { implicit request => def loginPage(): Action[AnyContent] = Action { implicit request =>

View 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"))
}

View File

@ -1,5 +1,5 @@
@import helper.CSRF @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> <!DOCTYPE html>
<html lang="en" class="body-full-height"> <html lang="en" class="body-full-height">
<head> <head>
@ -42,7 +42,7 @@
</div> </div>
<div class="vinyldns-login-footer"> <div class="vinyldns-login-footer">
<div class="pull-left"> <div class="pull-left">
VinylDNS, for all your DNS needs. VinylDNS (version @{meta.version})
<ul class="login-links"> <ul class="login-links">
@***************************************** @*****************************************
* Custom links from application config * * Custom links from application config *

View File

@ -1,2 +0,0 @@
# set custom trustStore
#-Djavax.net.ssl.trustStore=...

View File

@ -154,5 +154,10 @@ links = [
play.modules.enabled += "modules.VinylDNSModule" 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 // Local.conf has files specific to your environment, for example your own LDAP settings
include "local.conf" include "local.conf"

View 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")
}
}
}