Merge pull request #39 from stefanprodan/ui-logo

Make UI logo URL configurable
This commit is contained in:
Stefan Prodan
2019-10-12 18:10:40 +03:00
committed by GitHub
15 changed files with 41 additions and 20 deletions

View File

@@ -24,7 +24,7 @@ jobs:
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: true
docker_layer_caching: false
- run: make build-container
- run: |
if [ -z "$CIRCLE_TAG" ]; then

View File

@@ -10,7 +10,9 @@ GIT_COMMIT:=$(shell git describe --dirty --always)
VERSION:=$(shell grep 'VERSION' pkg/version/version.go | awk '{ print $$4 }' | tr -d '"')
run:
GO111MODULE=on go run -ldflags "-s -w -X github.com/stefanprodan/podinfo/pkg/version.REVISION=$(GIT_COMMIT)" cmd/podinfo/* --level=debug --grpc-port=9999 --backend-url=https://httpbin.org/status/401 --backend-url=https://httpbin.org/status/500
GO111MODULE=on go run -ldflags "-s -w -X github.com/stefanprodan/podinfo/pkg/version.REVISION=$(GIT_COMMIT)" cmd/podinfo/* \
--level=debug --grpc-port=9999 --backend-url=https://httpbin.org/status/401 --backend-url=https://httpbin.org/status/500 \
--ui-logo=https://media.giphy.com/media/l0ExbNdlJFGRphMR2/giphy.gif
test:
GO111MODULE=on go test -v -race ./...

View File

@@ -1,6 +1,6 @@
apiVersion: v1
version: 3.1.1
appVersion: 3.1.1
version: 3.1.2
appVersion: 3.1.2
name: podinfo
engine: gotpl
description: Podinfo Helm chart for Kubernetes

View File

@@ -55,9 +55,17 @@ spec:
- --random-delay={{ .Values.faults.delay }}
- --random-error={{ .Values.faults.error }}
env:
{{- if .Values.message }}
{{- if .Values.ui.message }}
- name: PODINFO_UI_MESSAGE
value: {{ .Values.message }}
value: {{ .Values.ui.message }}
{{- end }}
{{- if .Values.ui.logo }}
- name: PODINFO_UI_LOGO
value: {{ .Values.ui.logo }}
{{- end }}
{{- if .Values.ui.color }}
- name: PODINFO_UI_COLOR
value: {{ .Values.ui.color }}
{{- end }}
{{- if .Values.backend }}
- name: PODINFO_BACKEND_URL

View File

@@ -17,5 +17,5 @@ spec:
- name: grpc-health-probe
image: stefanprodan/grpc_health_probe:v0.3.0
command: ['grpc_health_probe']
args: ['-addr={{ template "podinfo.fullname" . }}:{{ .Values.service.grpcPort }}']
args: ['-addr={{ template "podinfo.fullname" . }}.{{ .Release.Namespace }}:{{ .Values.service.grpcPort }}']
restartPolicy: Never

View File

@@ -21,9 +21,9 @@ spec:
- -c
- |
TOKEN=$(curl -sd 'test' ${PODINFO_SVC}/token | jq -r .token) &&
curl -H "Authorization: Bearer ${TOKEN}" ${PODINFO_SVC}/token/validate | grep test
curl -sH "Authorization: Bearer ${TOKEN}" ${PODINFO_SVC}/token/validate | grep test
env:
- name: PODINFO_SVC
value: {{ template "podinfo.fullname" . }}:{{ .Values.service.externalPort }}
value: {{ template "podinfo.fullname" . }}.{{ .Release.Namespace }}:{{ .Values.service.externalPort }}
restartPolicy: Never

View File

@@ -20,9 +20,8 @@ spec:
- sh
- -c
- |
TOKEN=$(curl -sd 'test' ${PODINFO_SVC}/token | jq -r .token) &&
curl -H "Authorization: Bearer ${TOKEN}" ${PODINFO_SVC}/token/validate | grep test
curl -s ${PODINFO_SVC}/api/info | grep version
env:
- name: PODINFO_SVC
value: {{ template "podinfo.fullname" . }}:{{ .Values.service.externalPort }}
value: {{ template "podinfo.fullname" . }}.{{ .Release.Namespace }}:{{ .Values.service.externalPort }}
restartPolicy: Never

View File

@@ -4,7 +4,11 @@ replicaCount: 1
logLevel: info
backend: #http://backend-podinfo:9898/echo
backends: []
message: #UI greetings
ui:
color: "cyan"
message: ""
logo: ""
faults:
delay: false
@@ -12,7 +16,7 @@ faults:
image:
repository: stefanprodan/podinfo
tag: 3.1.1
tag: 3.1.2
pullPolicy: IfNotPresent
service:

View File

@@ -36,7 +36,8 @@ func main() {
fs.String("config-path", "", "config dir path")
fs.String("config", "config.yaml", "config file name")
fs.String("ui-path", "./ui", "UI local path")
fs.String("ui-color", "blue", "UI color")
fs.String("ui-logo", "", "UI logo")
fs.String("ui-color", "cyan", "UI color")
fs.String("ui-message", fmt.Sprintf("greetings from podinfo v%v", version.VERSION), "UI message")
fs.Bool("random-delay", false, "between 0 and 5 seconds random delay")
fs.Bool("random-error", false, "1/3 chances of a random response error")
@@ -64,6 +65,7 @@ func main() {
viper.RegisterAlias("backendUrl", "backend-url")
hostname, _ := os.Hostname()
viper.SetDefault("jwt-secret", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9")
viper.SetDefault("ui-logo", "https://d33wubrfki0l68.cloudfront.net/33a12d8be0bc50be4738443101616e968c7afb8f/cba76/images/scalable.png")
viper.Set("hostname", hostname)
viper.Set("version", version.VERSION)
viper.Set("revision", version.REVISION)

View File

@@ -25,7 +25,7 @@ spec:
spec:
containers:
- name: podinfod
image: stefanprodan/podinfo:3.1.1
image: stefanprodan/podinfo:3.1.2
imagePullPolicy: IfNotPresent
ports:
- name: http
@@ -48,7 +48,7 @@ spec:
- --random-error=false
env:
- name: PODINFO_UI_COLOR
value: blue
value: cyan
livenessProbe:
exec:
command:

View File

@@ -23,8 +23,10 @@ func (s *Server) indexHandler(w http.ResponseWriter, r *http.Request) {
data := struct {
Title string
Logo string
}{
Title: s.config.Hostname,
Logo: s.config.UILogo,
}
if err := tmpl.Execute(w, data); err != nil {

View File

@@ -22,6 +22,7 @@ func (s *Server) infoHandler(w http.ResponseWriter, r *http.Request) {
Hostname: s.config.Hostname,
Version: version.VERSION,
Revision: version.REVISION,
Logo: s.config.UILogo,
Color: s.config.UIColor,
Message: s.config.UIMessage,
GOOS: runtime.GOOS,
@@ -39,6 +40,7 @@ type RuntimeResponse struct {
Version string `json:"version"`
Revision string `json:"revision"`
Color string `json:"color"`
Logo string `json:"logo"`
Message string `json:"message"`
GOOS string `json:"goos"`
GOARCH string `json:"goarch"`

View File

@@ -50,6 +50,7 @@ type Config struct {
HttpServerTimeout time.Duration `mapstructure:"http-server-timeout"`
HttpServerShutdownTimeout time.Duration `mapstructure:"http-server-shutdown-timeout"`
BackendURL []string `mapstructure:"backend-url"`
UILogo string `mapstructure:"ui-logo"`
UIMessage string `mapstructure:"ui-message"`
UIColor string `mapstructure:"ui-color"`
UIPath string `mapstructure:"ui-path"`

View File

@@ -1,4 +1,4 @@
package version
var VERSION = "3.1.1"
var VERSION = "3.1.2"
var REVISION = "unknown"

View File

@@ -26,7 +26,7 @@
justify-center
class="white--text"
>
<img src="https://d33wubrfki0l68.cloudfront.net/33a12d8be0bc50be4738443101616e968c7afb8f/cba76/images/scalable.png" alt="kubernetes" height="200">
<img :src="info.logo" alt="kubernetes" height="200">
<h1 class="white--text mb-2 display-1 text-xs-center">${ info.message }</h1>
<div class="subheading mb-3 text-xs-center">Served by <b>${ info.hostname }</b></div>
<v-btn
@@ -108,7 +108,8 @@
}
}
self.info = data
self.info.color = 'cyan'
self.info.color = data.color
self.info.logo = data.logo
document.title = data.hostname
let verColor = (parseInt(data.version.split('.').reverse()[0], 10) % 2 === 0)
? 'blue'