add version
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
FROM alpine:3.5
|
||||
MAINTAINER Henning Jacobs <henning@jacobs1.de>
|
||||
|
||||
ARG VERSION=latest
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
RUN apk add --no-cache python3 python3-dev gcc musl-dev zlib-dev libffi-dev openssl-dev ca-certificates && \
|
||||
@@ -16,6 +18,7 @@ COPY requirements.txt /
|
||||
RUN pip3 install -r /requirements.txt
|
||||
|
||||
COPY kube_ops_view /kube_ops_view
|
||||
RUN sed -i "s/__version__ = .*/__version__ = '${VERSION}'/" /kube_ops_view/__init__.py
|
||||
|
||||
WORKDIR /
|
||||
ENTRYPOINT ["/usr/bin/python3", "-m", "kube_ops_view"]
|
||||
|
||||
5
Makefile
5
Makefile
@@ -1,7 +1,8 @@
|
||||
.PHONY: clean test appjs docker push mock
|
||||
|
||||
IMAGE ?= hjacobs/kube-ops-view
|
||||
TAG ?= latest
|
||||
VERSION ?= 2017.0.dev1-$(shell git describe --tags --always --dirty)
|
||||
TAG ?= $(VERSION)
|
||||
GITHEAD = $(shell git rev-parse --short HEAD)
|
||||
GITURL = $(shell git config --get remote.origin.url)
|
||||
GITSTATU = $(shell git status --porcelain || echo "no changes")
|
||||
@@ -19,7 +20,7 @@ appjs:
|
||||
docker run -it -u $$(id -u) -v $$(pwd):/workdir -w /workdir/app node:7.4-alpine npm run build
|
||||
|
||||
docker: appjs scm-source.json
|
||||
docker build -t "$(IMAGE):$(TAG)" .
|
||||
docker build --build-arg "VERSION=$(VERSION)" -t "$(IMAGE):$(TAG)" .
|
||||
|
||||
push: docker
|
||||
docker push "$(IMAGE):$(TAG)"
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
# This version is replaced during release process.
|
||||
__version__ = '2017.0.dev1'
|
||||
|
||||
@@ -15,6 +15,7 @@ import logging
|
||||
import os
|
||||
import signal
|
||||
import time
|
||||
import kube_ops_view
|
||||
from pathlib import Path
|
||||
|
||||
from flask import Flask, redirect
|
||||
@@ -80,7 +81,7 @@ def index():
|
||||
else:
|
||||
logger.error('Could not find JavaScript application bundle app*.js in {}'.format(static_build_path))
|
||||
flask.abort(503, 'JavaScript application bundle not found (missing build)')
|
||||
return flask.render_template('index.html', app_js=app_js)
|
||||
return flask.render_template('index.html', app_js=app_js, version=kube_ops_view.__version__)
|
||||
|
||||
|
||||
def event(cluster_ids: set):
|
||||
@@ -198,7 +199,16 @@ def exit_gracefully(signum, frame):
|
||||
gevent.spawn(shutdown)
|
||||
|
||||
|
||||
def print_version(ctx, param, value):
|
||||
if not value or ctx.resilient_parsing:
|
||||
return
|
||||
click.echo('Kubernetes Operational View {}'.format(kube_ops_view.__version__))
|
||||
ctx.exit()
|
||||
|
||||
|
||||
@click.command(context_settings={'help_option_names': ['-h', '--help']})
|
||||
@click.option('-V', '--version', is_flag=True, callback=print_version, expose_value=False, is_eager=True,
|
||||
help='Print the current version number and exit.')
|
||||
@click.option('-p', '--port', type=int, help='HTTP port to listen on (default: 8080)', envvar='SERVER_PORT', default=8080)
|
||||
@click.option('-d', '--debug', is_flag=True, help='Run in debugging mode', envvar='DEBUG')
|
||||
@click.option('-m', '--mock', is_flag=True, help='Mock Kubernetes clusters', envvar='MOCK')
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Kubernetes Operational View</title>
|
||||
<title>Kubernetes Operational View {{ version }}</title>
|
||||
<link rel="shortcut icon" href="static/favicon.ico">
|
||||
<style>* {padding: 0; margin: 0} body { color: #aaaaff; background: #000; }</style>
|
||||
<style>
|
||||
|
||||
14
setup.py
14
setup.py
@@ -3,6 +3,18 @@ import sys
|
||||
from setuptools import find_packages, setup
|
||||
from setuptools.command.test import test as TestCommand
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def read_version(package):
|
||||
with (Path(package) / '__init__.py').open() as fd:
|
||||
for line in fd:
|
||||
if line.startswith('__version__ = '):
|
||||
return line.split()[-1].strip().strip("'")
|
||||
|
||||
|
||||
version = read_version('kube_ops_view')
|
||||
|
||||
|
||||
class PyTest(TestCommand):
|
||||
|
||||
@@ -39,7 +51,7 @@ tests_require = [
|
||||
setup(
|
||||
name='kube-ops-view',
|
||||
packages=find_packages(),
|
||||
version='0.1',
|
||||
version=version,
|
||||
description='Kubernetes Operational View - read-only system dashboard for multiple K8s clusters',
|
||||
long_description=readme(),
|
||||
author='Henning Jacobs',
|
||||
|
||||
Reference in New Issue
Block a user