Skip to content

Commit

Permalink
Handle application.path configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Nov 23, 2018
1 parent fc7268d commit f88273e
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 218 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ First you need a [configuration files](#configuration) in order to configure Kaf
```sh
docker run -d \
-p 8080:8080 \
-e KAFKAHQ_CONFIGURATION_FILE=/app/application.conf
-v application.conf:/app/application.conf
tchiotludo/kafkahq
```
Expand Down Expand Up @@ -86,8 +85,7 @@ Configuration file is a [HOCON configuration](https://github.com/lightbend/confi
* `key`: must be an url friendly string the identify your cluster
* `value`: all the configurations found on [Kafka consumer documentation](https://kafka.apache.org/documentation/#consumerconfigs). Most important is `bootstrap.servers` that is a list of host:port of your Kafka brokers.

KafkaHQ docker image support 2 environment variables to handle configuraiton :
* `KAFKAHQ_CONFIGURATION_FILE`: a path on the container with the configuration file that can be mounted with a volume (`-v`) or secrets.
KafkaHQ docker image support 1 environment variables to handle configuraiton :
* `KAFKAHQ_CONFIGURATION`: a string that contains the full configuration that will be written on /app/configuration.conf on container.


Expand Down
4 changes: 0 additions & 4 deletions docker/usr/local/bin/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@ if [ "${KAFKAHQ_CONFIGURATION}" ]; then
echo ${KAFKAHQ_CONFIGURATION} > /app/application.conf
fi

if [ "${KAFKAHQ_CONFIGURATION_FILE}" ]; then
ln -s ${KAFKAHQ_CONFIGURATION_FILE} /app/application.conf
fi

exec "$@"
3 changes: 2 additions & 1 deletion public/blocks/group/topic.ftl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<#-- @ftlvariable name="clusterId" type="java.lang.String" -->
<#-- @ftlvariable name="group" type="org.kafkahq.models.ConsumerGroup" -->
<#-- @ftlvariable name="basePath" type="java.lang.String" -->

<div class="table-responsive">
<table class="table table-bordered table-striped table-hover mb-0">
Expand All @@ -24,7 +25,7 @@
</#if>
<#list group.getOffsets() as offset>
<tr>
<td><a href="/${clusterId}/topic/${offset.getTopic()}">${offset.getTopic()}</a></td>
<td><a href="${basePath}/${clusterId}/topic/${offset.getTopic()}">${offset.getTopic()}</a></td>
<td>${offset.getPartition()}</td>
<td>
<#if offset.getMember().isPresent()>
Expand Down
7 changes: 4 additions & 3 deletions public/blocks/topic/data.ftl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<#-- @ftlvariable name="datas" type="java.util.List<org.apache.kafka.clients.consumer.ConsumerRecord<java.lang.String, java.lang.String>>" -->
<#-- @ftlvariable name="datas" type="java.util.List<org.kafkahq.models.Record<java.lang.String, java.lang.String>>" -->
<#-- @ftlvariable name="navbar" type="java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.lang.Object>>" -->
<#-- @ftlvariable name="basePath" type="java.lang.String" -->

<nav class="navbar navbar-expand-lg navbar-light bg-light mr-auto data-filter">
<button class="navbar-toggler"
Expand Down Expand Up @@ -29,7 +30,7 @@
</a>
<div class="dropdown-menu">
<#list navbar["sort"]['values'] as k, v >
<a class="dropdown-item" href="${k}">
<a class="dropdown-item" href="${basePath}${k}">
<i class="fa fa-fw fa-sort-numeric-desc" aria-hidden="true"></i> ${v?lower_case?cap_first}
</a>
</#list>
Expand All @@ -47,7 +48,7 @@
</a>
<div class="dropdown-menu">
<#list navbar["partition"]['values'] as k, v >
<a class="dropdown-item" href="${k}">${v}</a>
<a class="dropdown-item" href="${basePath}${k}">${v}</a>
</#list>
</div>
</li>
Expand Down
5 changes: 3 additions & 2 deletions public/blocks/topic/pagination.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<#-- @ftlvariable name="pagination" type="java.util.Map<java.lang.String, java.lang.String>" -->
<#-- @ftlvariable name="basePath" type="java.lang.String" -->

<#assign size = pagination["size"] >
<#assign before = pagination["before"] >
Expand All @@ -7,7 +8,7 @@
<ul class="pagination mb-0 ml-sm-2">
<!--
<li class="page-item ${(before == "")?then('disabled', '')}">
<a class="page-link" aria-label="Previous" ${(before != "")?then(' href="'?no_esc + before + '"'?no_esc, '')}>
<a class="page-link" aria-label="Previous" ${(before != "")?then(' href="'?no_esc + basePath + before + '"'?no_esc, '')}>
<span aria-hidden="true">&laquo;</span>
<span class="sr-only">Previous</span>
</a>
Expand All @@ -17,7 +18,7 @@
<a class="page-link">≈ ${size}</a>
</li>
<li class="page-item ${(after == "")?then('disabled', '')}">
<a class="page-link" aria-label="Next" ${(after != "")?then(' href="'?no_esc + after + '"'?no_esc, '')}>
<a class="page-link" aria-label="Next" ${(after != "")?then(' href="'?no_esc + basePath + after + '"'?no_esc, '')}>
<span aria-hidden="true">&raquo;</span>
<span class="sr-only">Next</span>
</a>
Expand Down
3 changes: 2 additions & 1 deletion public/blocks/topic/partitions.ftl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<#-- @ftlvariable name="clusterId" type="java.lang.String" -->
<#-- @ftlvariable name="topic" type="org.kafkahq.models.Topic" -->
<#-- @ftlvariable name="basePath" type="java.lang.String" -->

<#import "/includes/node.ftl" as nodeTemplate>
<#import "/includes/functions.ftl" as functions>
Expand Down Expand Up @@ -36,7 +37,7 @@
${functions.filesize(partition.getLogDir().getSize())}
</td>
<td class="row-action main-row-action">
<a href="/${clusterId}/topic/${topic.getName()}/partitions/${partition.getId()}" >
<a href="${basePath}/${clusterId}/topic/${topic.getName()}/partitions/${partition.getId()}" >
<i class="fa fa-search"></i></a>
</td>
</tr>
Expand Down
5 changes: 3 additions & 2 deletions public/group.ftl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<#-- @ftlvariable name="clusterId" type="java.lang.String" -->
<#-- @ftlvariable name="group" type="org.kafkahq.models.ConsumerGroup" -->
<#-- @ftlvariable name="tab" type="java.lang.String" -->
<#-- @ftlvariable name="basePath" type="java.lang.String" -->

<#import "/includes/template.ftl" as template>

Expand All @@ -10,12 +11,12 @@
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link ${(tab == "topics")?then("active", "")}"
href="/${clusterId}/group/${group.getId()}/topics"
href="${basePath}/${clusterId}/group/${group.getId()}/topics"
role="tab">Topics</a>
</li>
<li class="nav-item">
<a class="nav-link ${(tab == "members")?then("active", "")}"
href="/${clusterId}/group/${group.getId()}/members"
href="${basePath}/${clusterId}/group/${group.getId()}/members"
role="tab">Members</a>
</li>
</ul>
Expand Down
7 changes: 4 additions & 3 deletions public/includes/group.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<#-- @ftlvariable name="clusterId" type="java.lang.String" -->
<#-- @ftlvariable name="basePath" type="java.lang.String" -->

<#import "node.ftl" as nodeTemplate>

Expand Down Expand Up @@ -35,18 +36,18 @@
<td>${group.getMembers()?size}</td>
<td>
<#list group.getTopics() as topic>
<a href="/${clusterId}/topic/${topic}" class="btn btn-dark btn-sm mb-1">
<a href="${basePath}/${clusterId}/topic/${topic}" class="btn btn-dark btn-sm mb-1">
${topic}
<span class="badge badge-light">Lag: ${group.getOffsetLag(topic)}</span>
</a>
</#list>
</td>
<td class="row-action main-row-action">
<a href="/${clusterId}/group/${group.getId()}" ><i class="fa fa-search"></i></a>
<a href="${basePath}/${clusterId}/group/${group.getId()}" ><i class="fa fa-search"></i></a>
</td>
<td class="row-action">
<a
href="/${clusterId}/group/${group.getId()}/delete"
href="${basePath}/${clusterId}/group/${group.getId()}/delete"
data-confirm="Do you want to delete consumer group <br /><strong>${group.getId()}</strong><br /><br /> ?"
><i class="fa fa-trash"></i></a>
</td>
Expand Down
15 changes: 8 additions & 7 deletions public/includes/template.ftl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<#-- @ftlvariable name="tab" type="java.lang.String" -->
<#-- @ftlvariable name="clusters" type="java.util.List<java.lang.String>" -->
<#-- @ftlvariable name="clusterId" type="java.lang.String" -->
<#-- @ftlvariable name="basePath" type="java.lang.String" -->

<#macro header title tab>
<!DOCTYPE html>
Expand All @@ -10,10 +11,10 @@
<meta name="turbolinks-cache-control" content="no-cache" />
<link rel="shortcut icon"
type="image/png"
href="/public/static/img/icon.png" />
href="${basePath}/static/img/icon.png" />
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700|Open+Sans:400,700" />
<#if myOptionalVar??>
<#if liveReload?? >
${liveReload?no_esc}
</#if>
${vendor_styles?no_esc}
Expand All @@ -26,7 +27,7 @@
<div class="wrapper">
<nav id="sidebar">
<div class="sidebar-header">
<h3><img src="/static/img/logo.svg"/><sup><strong>HQ</strong></sup></h3>
<h3><img src="${basePath}/static/img/logo.svg"/><sup><strong>HQ</strong></sup></h3>
</div>

<ul class="list-unstyled components">
Expand All @@ -40,19 +41,19 @@
<ul class="collapse list-unstyled" id="clusters">
<#list clusters as cluster>
<li>
<a href="/${cluster}" class="${(cluster == clusterId)?then("active", "")}">${cluster}</a>
<a href="${basePath}/${cluster}" class="${(cluster == clusterId)?then("active", "")}">${cluster}</a>
</li>
</#list>
</ul>
</li>
<li class="${(tab == "node")?then("active", "")}">
<a href="/${clusterId}/node"><i class="fa fa-fw fa-laptop" aria-hidden="true"></i> Nodes</a>
<a href="${basePath}/${clusterId}/node"><i class="fa fa-fw fa-laptop" aria-hidden="true"></i> Nodes</a>
</li>
<li class="${(tab == "topic")?then("active", "")}">
<a href="/${clusterId}/topic"><i class="fa fa-fw fa-list" aria-hidden="true"></i> Topics</a>
<a href="${basePath}/${clusterId}/topic"><i class="fa fa-fw fa-list" aria-hidden="true"></i> Topics</a>
</li>
<li class="${(tab == "group")?then("active", "")}">
<a href="/${clusterId}/group"><i class="fa fa-fw fa-object-group" aria-hidden="true"></i> Consumer Groups</a>
<a href="${basePath}/${clusterId}/group"><i class="fa fa-fw fa-object-group" aria-hidden="true"></i> Consumer Groups</a>
</li>
</ul>
</nav>
Expand Down
3 changes: 2 additions & 1 deletion public/node.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<#-- @ftlvariable name="node" type="org.kafkahq.models.Node" -->
<#-- @ftlvariable name="configs" type="java.util.ArrayList<org.kafkahq.models.Config>" -->
<#-- @ftlvariable name="tab" type="java.lang.String" -->
<#-- @ftlvariable name="basePath" type="java.lang.String" -->

<#import "/includes/template.ftl" as template>
<#import "/includes/group.ftl" as groupTemplate>
Expand All @@ -12,7 +13,7 @@
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link ${(tab == "configs")?then("active", "")}"
href="/${clusterId}/node/${node.getId()?c}/configs"
href="${basePath}/${clusterId}/node/${node.getId()?c}/configs"
role="tab">Configs</a>
</li>
</ul>
Expand Down
3 changes: 2 additions & 1 deletion public/nodeList.ftl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<#-- @ftlvariable name="clusterId" type="java.lang.String" -->
<#-- @ftlvariable name="cluster" type="org.kafkahq.models.Cluster" -->
<#-- @ftlvariable name="basePath" type="java.lang.String" -->

<#import "/includes/template.ftl" as template>
<#import "/includes/node.ftl" as nodeTemplate>
Expand Down Expand Up @@ -32,7 +33,7 @@
<td>${node.getHost()}:${node.getPort()?c}</td>
<td>${node.getRack()!}</td>
<td class="row-action main-row-action">
<a href="/${clusterId}/node/${node.getId()?c}" ><i class="fa fa-search"></i></a>
<a href="${basePath}/${clusterId}/node/${node.getId()?c}" ><i class="fa fa-search"></i></a>
</td>
</tr>
</#list>
Expand Down
Binary file removed public/static/img/icon.png
Binary file not shown.
93 changes: 0 additions & 93 deletions public/static/img/icon.svg

This file was deleted.

Loading

0 comments on commit f88273e

Please sign in to comment.