Skip to content

Commit aac964e

Browse files
committed
override configs
1 parent cf34bb0 commit aac964e

File tree

10 files changed

+172
-140
lines changed

10 files changed

+172
-140
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,19 @@ integrations:
112112
# whether to use ssh or https to clone
113113
clone_with: https
114114
# HTTPS URL format, Full name will be something like Clivern/Rabbit
115-
https_format: https://github.com/{$full_name}.git
115+
https_format: https://github.com/[.RepoFullName].git
116116
# SSH URL format, Full name will be something like Clivern/Rabbit
117-
ssh_format: [email protected]:{$full_name}.git
117+
ssh_format: [email protected]:[.RepoFullName].git
118118
# Bitbucket Configs
119119
bitbucket:
120120
# Webhook URI (Full URL will be app.domain + webhook_uri)
121121
webhook_uri: /webhook/bitbucket
122122
# whether to use ssh or https to clone
123123
clone_with: https
124124
# HTTPS URL format, Full name will be something like Clivern/Rabbit
125-
https_format: https://bitbucket.org/{$full_name}.git
125+
https_format: https://bitbucket.org/[.RepoFullName].git
126126
# SSH URL format, Full name will be something like Clivern/Rabbit
127-
ssh_format: [email protected]:{$full_name}.git
127+
ssh_format: [email protected]:[.RepoFullName].git
128128
```
129129
130130
And then run the application.

config.dist.yml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,88 @@
11
# General App Configs
22
app:
33
# Env mode (dev or prod)
4-
mode: dev
4+
mode: ${RABBIT_APP_MODE:-dev}
55
# HTTP port
6-
port: 8080
6+
port: ${RABBIT_APP_PORT:-8080}
77
# App URL
8-
domain: http://127.0.0.1:8080
8+
domain: ${RABBIT_APP_DOMAIN:-http://127.0.0.1:8080}
99
# TLS configs
1010
tls:
11-
status: off
12-
pemPath: cert/server.pem
13-
keyPath: cert/server.key
11+
status: ${RABBIT_APP_TLS_STATUS:-off}
12+
pemPath: ${RABBIT_APP_TLS_PEMPATH:-cert/server.pem}
13+
keyPath: ${RABBIT_APP_TLS_KEYPATH:-cert/server.key}
1414

1515
# Redis Configs
1616
redis:
17-
addr: localhost:6379
18-
password:
19-
db: 0
17+
addr: ${RABBIT_REDIS_ADDR:-localhost:6379}
18+
password: ${RABBIT_REDIS_PASSWORD:- }
19+
db: ${RABBIT_REDIS_DB:-0}
2020

2121
# Message Broker Configs
2222
broker:
2323
# Broker driver (native or redis)
24-
driver: native
24+
driver: ${RABBIT_BROKER_DRIVER:-native}
2525
# Native driver configs
2626
native:
2727
# Queue max capacity
28-
capacity: 50
28+
capacity: ${RABBIT_BROKER_NATIVE_CAPACITY:-50}
2929
# Number of concurrent workers
30-
workers: 1
30+
workers: ${RABBIT_BROKER_NATIVE_WORKERS:-1}
3131
# Redis configs
3232
redis:
33-
channel: rabbit
33+
channel: ${RABBIT_BROKER_REDIS_CHANNEL:-rabbit}
3434

3535
# Log configs
3636
log:
3737
# Log level, it can be debug, info, warn, error, panic, fatal
38-
level: debug
39-
# output can be stdout or abs path to log file /var/logs/rabbit.log
40-
output: stdout
41-
# Format can be json or text
42-
format: json
38+
level: ${RABBIT_LOG_LEVEL:-warn}
39+
# output can be stdout or abs path to log file /var/logs/beagle.log
40+
output: ${RABBIT_LOG_OUTPUT:-stdout}
41+
# Format can be json
42+
format: ${RABBIT_LOG_FORMAT:-json}
4343

4444
# Release configs
4545
releases:
4646
# Releases absolute path
47-
path: /app/var/releases
48-
name: "[.Tag]"
47+
path: ${RABBIT_RELEASES_PATH:-/app/var/releases}
48+
name: ${RABBIT_RELEASES_NAME:-[.Tag]}
4949

5050
# Build configs
5151
build:
5252
# Build absolute path
53-
path: /app/var/build
53+
path: ${RABBIT_BUILD_PATH:-/app/var/build}
5454
# Number of parallel builds
55-
parallelism: 1
55+
parallelism: ${RABBIT_BUILD_PARALLELISM:-1}
5656

5757
# Application Database
5858
database:
5959
# Database driver (redis)
60-
driver: redis
60+
driver: ${RABBIT_DATABASE_DRIVER:-redis}
6161
# Redis
6262
redis:
63-
hash_prefix: rabbit_
63+
hash_prefix: ${RABBIT_DATABASE_REDIS_HASH_PREFIX:-rabbit_}
6464

6565
# Third Party API Integration
6666
integrations:
6767
# Github Configs
6868
github:
6969
# Webhook URI (Full URL will be app.domain + webhook_uri)
70-
webhook_uri: /webhook/github
70+
webhook_uri: ${RABBIT_INTEGRATION_GITHUB_WEBHOOK_URI:-/webhook/github}
7171
# Webhook Secret (From Repo settings page > Webhooks)
72-
webhook_secret: Pz2ufk7r5BTjnkOo
72+
webhook_secret: ${RABBIT_INTEGRATION_GITHUB_WEBHOOK_SECRET:- }
7373
# whether to use ssh or https to clone
74-
clone_with: https
74+
clone_with: ${RABBIT_INTEGRATION_GITHUB_CLONE_WITH:-https}
7575
# HTTPS URL format, Full name will be something like Clivern/Rabbit
76-
https_format: https://github.com/{$full_name}.git
76+
https_format: ${RABBIT_INTEGRATION_GITHUB_HTTPS_FORMAT:-https://github.com/[.RepoFullName].git}
7777
# SSH URL format, Full name will be something like Clivern/Rabbit
78-
ssh_format: [email protected]:{$full_name}.git
78+
ssh_format: ${RABBIT_INTEGRATION_GITHUB_SSH_FORMAT:-[email protected]:[.RepoFullName].git}
7979
# Bitbucket Configs
8080
bitbucket:
8181
# Webhook URI (Full URL will be app.domain + webhook_uri)
82-
webhook_uri: /webhook/bitbucket
82+
webhook_uri: ${RABBIT_INTEGRATION_BITBUCKET_WEBHOOK_URI:-/webhook/bitbucket}
8383
# whether to use ssh or https to clone
84-
clone_with: https
84+
clone_with: ${RABBIT_INTEGRATION_BITBUCKET_CLONE_WITH:-https}
8585
# HTTPS URL format, Full name will be something like Clivern/Rabbit
86-
https_format: https://bitbucket.org/{$full_name}.git
86+
https_format: ${RABBIT_INTEGRATION_BITBUCKET_HTTPS_FORMAT:-https://bitbucket.org/[.RepoFullName].git}
8787
# SSH URL format, Full name will be something like Clivern/Rabbit
88-
ssh_format: [email protected]:{$full_name}.git
88+
ssh_format: ${RABBIT_INTEGRATION_BITBUCKET_SSH_FORMAT:-[email protected]:[.RepoFullName].git}

docker/Dockerfile

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
FROM golang:1.12.5 as builder
2-
3-
WORKDIR /app
4-
COPY ./ /app
5-
6-
RUN GO111MODULE=on go build -o rabbit rabbit.go
7-
81
FROM golang:1.12.5
92

103
ARG GORELEASER_VERSION=0.110.0
4+
ARG RABBIT_VERSION=0.1.2
115

126
ENV GO111MODULE=on
137

@@ -22,17 +16,21 @@ RUN mkdir -p /app/configs \
2216
&& apt-get install -y git \
2317
&& rm -rf /var/lib/apt/lists/*
2418

25-
COPY docker/config.docker.yml /app/configs/config.yml
26-
COPY --from=builder /app/rabbit /app/rabbit
27-
COPY --from=builder /app/LICENSE /app/LICENSE
28-
2919
WORKDIR /app
3020

31-
EXPOSE 8080
21+
RUN curl -sL https://github.com/Clivern/Rabbit/releases/download/${RABBIT_VERSION}/Rabbit_${RABBIT_VERSION}_Linux_x86_64.tar.gz | tar xz
22+
RUN rm LICENSE
23+
RUN rm README.md
24+
RUN mv Rabbit rabbit
25+
26+
COPY ./config.docker.yml /app/configs/
3227

33-
CMD ["./rabbit", "--config", "/app/configs/config.yml"]
28+
EXPOSE 8080
3429

35-
VOLUME /app/var/releases
30+
VOLUME /app/configs
31+
VOLUME /app/var
3632

3733
HEALTHCHECK --interval=5s --timeout=2s --retries=5 --start-period=2s \
38-
CMD ./rabbit --config /app/configs/config.yml --exec health
34+
CMD ./rabbit --config /app/configs/config.docker.yml --exec health
35+
36+
CMD ["./rabbit", "--config", "/app/configs/config.docker.yml"]

docker/config.docker.yml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,88 @@
11
# General App Configs
22
app:
33
# Env mode (dev or prod)
4-
mode: prod
4+
mode: ${RABBIT_APP_MODE:-dev}
55
# HTTP port
6-
port: ${RABBIT_LISTEN_PORT:-8080}
6+
port: ${RABBIT_APP_PORT:-8080}
77
# App URL
8-
domain: ${RABBIT_DOMAIN:-http://localhost:8080}
8+
domain: ${RABBIT_APP_DOMAIN:-http://127.0.0.1:8080}
99
# TLS configs
1010
tls:
11-
status: ${RABBIT_TLS_STATUS:-off}
12-
pemPath: ${RABBIT_TLS_CERT:-cert/server.pem}
13-
keyPath: ${RABBIT_TLS_CERTKEY:-cert/server.key}
11+
status: ${RABBIT_APP_TLS_STATUS:-off}
12+
pemPath: ${RABBIT_APP_TLS_PEMPATH:-cert/server.pem}
13+
keyPath: ${RABBIT_APP_TLS_KEYPATH:-cert/server.key}
1414

1515
# Redis Configs
1616
redis:
1717
addr: ${RABBIT_REDIS_ADDR:-redis:6379}
18-
password: ${RABBIT_REDIS_PASSWORD}
18+
password: ${RABBIT_REDIS_PASSWORD:- }
1919
db: ${RABBIT_REDIS_DB:-0}
2020

2121
# Message Broker Configs
2222
broker:
2323
# Broker driver (native or redis)
24-
driver: native
24+
driver: ${RABBIT_BROKER_DRIVER:-native}
2525
# Native driver configs
2626
native:
2727
# Queue max capacity
28-
capacity: 50
28+
capacity: ${RABBIT_BROKER_NATIVE_CAPACITY:-50}
2929
# Number of concurrent workers
30-
workers: 1
31-
# Redis Driver Configs
30+
workers: ${RABBIT_BROKER_NATIVE_WORKERS:-1}
31+
# Redis configs
3232
redis:
33-
channel: rabbit
33+
channel: ${RABBIT_BROKER_REDIS_CHANNEL:-rabbit}
3434

3535
# Log configs
3636
log:
3737
# Log level, it can be debug, info, warn, error, panic, fatal
38-
level: ${RABBIT_LOG_LEVEL:-warn}
39-
# output can be stdout or abs path to log file /var/logs/rabbit.log
40-
output: ${RABBIT_LOG_OUTPUT:-stdout}
41-
# Format can be json or text
42-
format: json
38+
level: ${RABBIT_LOG_LEVEL:-warn}
39+
# output can be stdout or abs path to log file /var/logs/beagle.log
40+
output: ${RABBIT_LOG_OUTPUT:-stdout}
41+
# Format can be json
42+
format: ${RABBIT_LOG_FORMAT:-json}
4343

4444
# Release configs
4545
releases:
4646
# Releases absolute path
4747
path: ${RABBIT_RELEASES_PATH:-/app/var/releases}
48-
name: "[.Tag]"
48+
name: ${RABBIT_RELEASES_NAME:-[.Tag]}
4949

5050
# Build configs
5151
build:
5252
# Build absolute path
5353
path: ${RABBIT_BUILD_PATH:-/app/var/build}
5454
# Number of parallel builds
55-
parallelism: 1
55+
parallelism: ${RABBIT_BUILD_PARALLELISM:-1}
5656

5757
# Application Database
5858
database:
5959
# Database driver (redis)
60-
driver: redis
61-
# Redis Driver Configs
60+
driver: ${RABBIT_DATABASE_DRIVER:-redis}
61+
# Redis
6262
redis:
63-
hash_prefix: rabbit_
63+
hash_prefix: ${RABBIT_DATABASE_REDIS_HASH_PREFIX:-rabbit_}
6464

6565
# Third Party API Integration
6666
integrations:
6767
# Github Configs
6868
github:
6969
# Webhook URI (Full URL will be app.domain + webhook_uri)
70-
webhook_uri: /webhook/github
70+
webhook_uri: ${RABBIT_INTEGRATION_GITHUB_WEBHOOK_URI:-/webhook/github}
7171
# Webhook Secret (From Repo settings page > Webhooks)
72-
webhook_secret: ${RABBIT_INTEGRATION_GITHUB_WEBHOOK_SECRET}
72+
webhook_secret: ${RABBIT_INTEGRATION_GITHUB_WEBHOOK_SECRET:- }
7373
# whether to use ssh or https to clone
7474
clone_with: ${RABBIT_INTEGRATION_GITHUB_CLONE_WITH:-https}
7575
# HTTPS URL format, Full name will be something like Clivern/Rabbit
76-
https_format: https://github.com/{$full_name}.git
76+
https_format: ${RABBIT_INTEGRATION_GITHUB_HTTPS_FORMAT:-https://github.com/[.RepoFullName].git}
7777
# SSH URL format, Full name will be something like Clivern/Rabbit
78-
ssh_format: [email protected]:{$full_name}.git
78+
ssh_format: ${RABBIT_INTEGRATION_GITHUB_SSH_FORMAT:-[email protected]:[.RepoFullName].git}
7979
# Bitbucket Configs
8080
bitbucket:
8181
# Webhook URI (Full URL will be app.domain + webhook_uri)
82-
webhook_uri: /webhook/bitbucket
82+
webhook_uri: ${RABBIT_INTEGRATION_BITBUCKET_WEBHOOK_URI:-/webhook/bitbucket}
8383
# whether to use ssh or https to clone
8484
clone_with: ${RABBIT_INTEGRATION_BITBUCKET_CLONE_WITH:-https}
8585
# HTTPS URL format, Full name will be something like Clivern/Rabbit
86-
https_format: https://bitbucket.org/{$full_name}.git
86+
https_format: ${RABBIT_INTEGRATION_BITBUCKET_HTTPS_FORMAT:-https://bitbucket.org/[.RepoFullName].git}
8787
# SSH URL format, Full name will be something like Clivern/Rabbit
88-
ssh_format: [email protected]:{$full_name}.git
88+
ssh_format: ${RABBIT_INTEGRATION_BITBUCKET_SSH_FORMAT:-[email protected]:[.RepoFullName].git}

docker/docker-compose.example.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

docker/docker-compose.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: '3'
2+
services:
3+
redis:
4+
image: 'redis:5.0.5-alpine'
5+
volumes:
6+
- 'rabbit_redis:/data'
7+
restart: unless-stopped
8+
rabbit:
9+
image: 'rabbit:1.0.0'
10+
build: .
11+
ports:
12+
- "8080:8080"
13+
depends_on:
14+
- redis
15+
volumes:
16+
- '~/.ssh:/root/.ssh'
17+
- 'rabbit_configs:/app/configs'
18+
- 'rabbit_var:/app/var'
19+
restart: unless-stopped
20+
21+
volumes:
22+
rabbit_redis: null
23+
rabbit_configs: null
24+
rabbit_var: null

internal/app/controller/bitbucket_listener.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ func BitbucketListener(c *gin.Context, messages chan<- string) {
6262
// Push event received
6363
href := strings.ReplaceAll(
6464
viper.GetString("integrations.bitbucket.https_format"),
65-
"{$full_name}",
65+
"[.RepoFullName]",
6666
pushEvent.Repository.FullName,
6767
)
6868

6969
if viper.GetString("integrations.bitbucket.clone_with") == "ssh" {
7070
href = strings.ReplaceAll(
7171
viper.GetString("integrations.bitbucket.ssh_format"),
72-
"{$full_name}",
72+
"[.RepoFullName]",
7373
pushEvent.Repository.FullName,
7474
)
7575
}

internal/app/controller/github_listener.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ func GithubListener(c *gin.Context, messages chan<- string) {
9494

9595
href := strings.ReplaceAll(
9696
viper.GetString("integrations.github.https_format"),
97-
"{$full_name}",
97+
"[.RepoFullName]",
9898
createEvent.Repository.FullName,
9999
)
100100

101101
if viper.GetString("integrations.github.clone_with") == "ssh" {
102102
href = strings.ReplaceAll(
103103
viper.GetString("integrations.github.ssh_format"),
104-
"{$full_name}",
104+
"[.RepoFullName]",
105105
createEvent.Repository.FullName,
106106
)
107107
}

0 commit comments

Comments
 (0)