Skip to content

Commit

Permalink
Merge pull request #48 from tchiotludo/dev
Browse files Browse the repository at this point in the history
Release 0.5.3
  • Loading branch information
tchiotludo authored Apr 16, 2019
2 parents 3455cde + 71a03fb commit a185d0c
Show file tree
Hide file tree
Showing 20 changed files with 197 additions and 62 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ cache:

script:
- set -e
# Docker Login
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# Gradle
- ./gradlew --console=plain test
- ./gradlew --console=plain shadowJar
Expand All @@ -32,14 +30,17 @@ script:
- docker build . -t $TRAVIS_COMMIT
# Docker Tag
- if [ ! -z "$TRAVIS_TAG" ]; then
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin;
docker tag $TRAVIS_COMMIT tchiotludo/kafkahq:$TRAVIS_TAG;
docker push tchiotludo/kafkahq:$TRAVIS_TAG;
fi
# Docker Branch
- if [ "$TRAVIS_BRANCH" == "master" ]; then
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin;
docker tag $TRAVIS_COMMIT tchiotludo/kafkahq:latest;
docker push tchiotludo/kafkahq:latest;
elif [ "$TRAVIS_BRANCH" == "develop" ]; then
elif [ "$TRAVIS_BRANCH" == "dev" ]; then
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin;
docker tag $TRAVIS_COMMIT tchiotludo/kafkahq:$TRAVIS_BRANCH;
docker push tchiotludo/kafkahq:$TRAVIS_BRANCH;
fi
Expand Down
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
FROM openjdk:8-jre-alpine

RUN apk add --update \
libc6-compat \
java-snappy-native \
&& rm -rf /var/cache/apk/*

WORKDIR /app
COPY docker /
ENV MICRONAUT_CONFIG_FILES=/app/application.yml
Expand Down
10 changes: 10 additions & 0 deletions Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM gradle:5.3.1-jdk-alpine

USER root

RUN apk add --update \
libc6-compat \
java-snappy-native \
&& rm -rf /var/cache/apk/*

USER gradle
17 changes: 10 additions & 7 deletions application.example.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
kafkahq:
server:
base-path: "" # if behind a reverse proxy, path to kafkahq with trailing slash (optionnal)
access-log: # Access log configuration (optionnal)
base-path: "" # if behind a reverse proxy, path to kafkahq with trailing slash (optional). Example: kafkahq is
# behind a reverse proxy with url http://my-server/kafkahq, set base-path: "/kafkahq/".
# Not needed if you're behind a reverse proxy with subdomain http://kafkahq.my-server/
access-log: # Access log configuration (optional)
enabled: true # true by default
name: org.kafkahq.log.access # Logger name
format: "[Date: {}] [Duration: {} ms] [Url: {} {} {}] [Status: {}] [Ip: {}] [Length: {}] [Port: {}]" # Logger format

# default kafka properties for each clients, available for admin / producer / consumer (optionnal)
# default kafka properties for each clients, available for admin / producer / consumer (optional)
clients-defaults:
consumer:
properties:
Expand All @@ -15,9 +17,9 @@ kafkahq:
# list of kafka cluster available for kafkahq
connections:
my-cluster-1: # url friendly name for the cluster
properties: # standard kafka properties (optionnal)
properties: # standard kafka properties (optional)
bootstrap.servers: "kafka:9092"
schema-registry: "http://schema-registry:8085" # schema registry url (optionnal)
schema-registry: "http://schema-registry:8085" # schema registry url (optional)

my-cluster-2:
properties:
Expand All @@ -41,12 +43,13 @@ kafkahq:
ssl.keystore.password: password
ssl.key.password: password

# Topic display data options (optionnal)
# Topic display data options (optional)
topic-data:
sort: OLDEST # default sort order (OLDEST, NEWEST) (default: OLDEST)
size: 50 # max record per page (default: 50)
poll-timeout: 1000 # The time, in milliseconds, spent waiting in poll if data is not available in the buffer.

# Auth & Roles (optionnal)
# Auth & Roles (optional)
security:
default-roles: # Roles available for all the user even unlogged user
- topic/read
Expand Down
15 changes: 15 additions & 0 deletions assets/modules/templates/sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
font-size: $font-size-lg;
border-right: 1px solid $nav-tabs-border-color;
z-index: 2;
display: flex;
flex-direction: column;

.sidebar-header {
padding: 5px 10px;
Expand All @@ -21,6 +23,7 @@
}

ul {
flex-grow: 2;
p {
color: #fff;
padding: 10px;
Expand Down Expand Up @@ -79,6 +82,18 @@
background: $tertiary;
}

.sidebar-log {
padding: 5px 10px;
background: $tertiary;
border-top: 1px solid $yellow;
a {
color: white;
&:hover {
text-decoration: none;
}
}
}

@include media-breakpoint-down(sm) {
& {
margin-left: -$menu-width;
Expand Down
8 changes: 6 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
micronautVersion = "1.1.+"
micronautVersion = "1.1.0"
confluentVersion = "5.1.+"
kafkaVersion = "2.2.+"
}
Expand Down Expand Up @@ -83,7 +83,11 @@ configurations {

run.classpath += configurations.developmentOnly
test.classpath += configurations.developmentOnly
run.jvmArgs('-noverify', '-XX:TieredStopAtLevel=1', '-Dmicronaut.environments=dev')
run.jvmArgs('-noverify',
'-XX:TieredStopAtLevel=1',
'-Dmicronaut.environments=dev',
'-Dorg.xerial.snappy.use.systemlib=true'
)

tasks.withType(JavaCompile){
options.encoding = "UTF-8"
Expand Down
4 changes: 3 additions & 1 deletion docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ volumes:

services:
kafkahq:
image: gradle:5.3.1-jdk-alpine
build:
context: .
dockerfile: Dockerfile-dev
command: "gradle run --continuous"
working_dir: /app
volumes:
Expand Down
50 changes: 50 additions & 0 deletions docker/app/jvm.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
###########################################################################
# jvm.options #
# #
# - all flags defined here will be used to startup the JVM #
# - one flag should be specified per line #
# - lines that do not start with '-' will be ignored #
# - only static flags are accepted (no variables or parameters) #
# - dynamic flags will be appended to these on cassandra-env #
###########################################################################

# Server Hotspot JVM
-server

# ensure UTF-8 encoding by default (e.g. filenames)
-Dfile.encoding=UTF-8

# set to headless, just in case
-Djava.awt.headless=true

# generate a heap dump when an allocation from the Java heap fails
# heap dumps are created in the working directory of the JVM
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/tmp/heapdump.log

# GC logs
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+PrintTenuringDistribution
-XX:+PrintGCApplicationStoppedTime
-Xloggc:/tmp/gc.log
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=32
-XX:GCLogFileSize=64m

# Docker aware cpu/memory otions
-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap

# Do not rely on the system configuration
-Dfile.encoding=UTF-8
-Duser.timezone=UTC

# tells the Java library to use the preinstalled native library
-Dorg.xerial.snappy.use.systemlib=true

# Jmx Remote
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8686
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
7 changes: 7 additions & 0 deletions docker/app/kafkahq
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#!/usr/bin/env sh

# Read user-defined JVM options from jvm.options file
JVM_OPTS_FILE=${JVM_OPTS_FILE:-/app/jvm.options}
for JVM_OPT in `grep "^-" ${JVM_OPTS_FILE}`
do
JAVA_OPTS="${JAVA_OPTS} ${JVM_OPT}"
done

/usr/bin/java ${JAVA_OPTS} -jar /app/kafkahq.jar
15 changes: 0 additions & 15 deletions src/main/java/org/kafkahq/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,6 @@
import io.micronaut.runtime.Micronaut;

public class App {
// route
{
/*
use(new Whoops());
use("*", new RequestLogger()
.latency()
.extended()
);
assets("/favicon.ico");
});
*/
}

public static void main(String[] args) {
Micronaut.run(App.class);
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/org/kafkahq/controllers/AbstractController.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import lombok.Builder;
import lombok.Getter;
import lombok.experimental.Wither;
import org.kafkahq.configs.BasicAuth;
import org.kafkahq.modules.KafkaModule;

import javax.inject.Inject;
Expand All @@ -39,6 +40,9 @@ abstract public class AbstractController {
@Value("${kafkahq.security.default-roles}")
List<String> defaultRoles;

@Inject
private List<BasicAuth> auths;

@SuppressWarnings("unchecked")
protected Map templateData(Optional<String> cluster, Object... values) {
Map datas = CollectionUtils.mapOf(values);
Expand All @@ -52,6 +56,17 @@ protected Map templateData(Optional<String> cluster, Object... values) {
datas.put("registryEnabled", this.kafkaModule.getRegistryRestClient(s) != null);
});

if (applicationContext.containsBean(SecurityService.class)) {
datas.put("loginEnabled", auths.size() > 0);

SecurityService securityService = applicationContext.getBean(SecurityService.class);
securityService
.getAuthentication()
.ifPresent(authentication -> datas.put("username", authentication.getName()));
} else {
datas.put("loginEnabled", false);
}

return datas;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kafkahq/controllers/LoginController.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@Requires(property = SecurityConfigurationProperties.PREFIX + ".enabled", value = StringUtils.TRUE)
@Controller
public class LoginController extends AbstractController {
@Get("/login{/failed:[a-zA-Z]+}")
@Get("${kafkahq.server.base-path:}/login{/failed:[a-zA-Z]+}")
@View("login")
public HttpResponse login(Optional<String> failed) {
return HttpResponse
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/kafkahq/controllers/SchemaController.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ public HttpResponse createSubmit(String cluster,
URI redirect;

if (toast.getType() != Toast.Type.error) {
redirect = new URI("/" + cluster + "/schema/" + subject);
redirect = this.uri("/" + cluster + "/schema/" + subject);
} else {
redirect = new URI("/" + cluster + "/schema/create");
redirect = this.uri("/" + cluster + "/schema/create");
}

return response.status(HttpStatus.MOVED_PERMANENTLY)
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/kafkahq/middlewares/KafkaWrapperFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public KafkaWrapperFilter(KafkaModule kafkaModule, RequestHelper requestHelper)

@Override
public Publisher<MutableHttpResponse<?>> doFilter(HttpRequest<?> request, ServerFilterChain chain) {
if (kafkaModule.getClustersList().size() == 0) {
throw new IllegalArgumentException(
"Couldn't find any clusters on your configuration file, " +
"please ensure that the configuration file is loaded correctly"
);
}

requestHelper
.getClusterId(request)
.ifPresent(s -> AbstractRepository.setWrapper(new KafkaWrapper(kafkaModule, s)));
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/kafkahq/models/LogDir.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import org.apache.kafka.common.TopicPartition;
import org.apache.kafka.common.requests.DescribeLogDirsResponse;

@ToString
Expand All @@ -17,7 +18,7 @@ public class LogDir {
private final long offsetLag;
private final boolean isFuture;

public LogDir(Integer brokerId, String path, org.apache.kafka.common.TopicPartition topicPartition, DescribeLogDirsResponse.ReplicaInfo replicaInfo) {
public LogDir(Integer brokerId, String path, TopicPartition topicPartition, DescribeLogDirsResponse.ReplicaInfo replicaInfo) {
this.brokerId = brokerId;
this.path = path;
this.topic = topicPartition.topic();
Expand Down
Loading

0 comments on commit a185d0c

Please sign in to comment.