add version support in env

This commit is contained in:
yhua 2016-09-05 15:40:49 +08:00
parent 1853d636a5
commit 11687b2789
2 changed files with 12 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import string
import os
import sys
import argparse
import commands
from io import open
if sys.version_info[:3][0] == 2:
@ -57,6 +58,14 @@ token_expiration = rcp.get("configuration", "token_expiration")
verify_remote_cert = rcp.get("configuration", "verify_remote_cert")
########
#Read version form .git
status, output = commands.getstatusoutput('git describe --tags')
if status == 0:
version = output
else:
version = 'UNKNOWN'
#######
ui_secret = ''.join(random.choice(string.ascii_letters+string.digits) for i in range(16))
base_dir = os.path.dirname(__file__)
@ -108,7 +117,8 @@ render(os.path.join(templates_dir, "ui", "env"),
use_compressed_js=use_compressed_js,
ui_secret=ui_secret,
verify_remote_cert=verify_remote_cert,
token_expiration=token_expiration)
token_expiration=token_expiration,
version=version)
render(os.path.join(templates_dir, "ui", "app.conf"),
ui_conf,

View File

@ -20,3 +20,4 @@ EXT_ENDPOINT=$ui_url
TOKEN_URL=http://ui
VERIFY_REMOTE_CERT=$verify_remote_cert
TOKEN_EXPIRATION=$token_expiration
VERSION=$version