forked from bokysan/docker-postfix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Larger refactoring of the codebase + DKIM_SELECTOR
Summary ^^^^^^^ This commit refactors the code base to be more manageble and prepares the groundwork for tests. Refactoring ^^^^^^^^^^^ Files are now moved to subdirectories, all for the sole purpose of easier management. Tests live in their own folders, as well as configs and other files. Test framework ^^^^^^^^^^^^^^ Two new important scripts/directories are available: - `unit-tests.sh` / `/unit-test` which executes unit tests across shell scripts, and - `integration-test.sh` / `integration-tests`, which spins up the container and tries to send the email. Both tests use the [BATS](https://github.com/sstephenson/bats) framework for testing. To create a new test, simply drop a `.bats` file into a corresponding directory. Functions have been extracted into `common-run.sh`, to be able to test them independently. DKIM_SELECTOR ^^^^^^^^^^^^^ It is now possible to specify a DKIM selector to use (instead of the default "mail"). See `README.md` for more details. JSON logging ^^^^^^^^^^^^ WIP: rsyslog will now output JSON logs. This is especially important if you plan on deploying the image into Kubernetes, as [Prometheus](https://prometheus.io/) can handle logs in JSON much easier. TODO: Make this an optional feature, to not confuse existing users.
- Loading branch information
Showing
26 changed files
with
638 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# http://editorconfig.org | ||
root = true | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
end_of_line = lf | ||
max_line_length = 120 | ||
|
||
# Indent shell scripts with tabs | ||
[**.sh,**.bats] | ||
indent_style = tab | ||
|
||
# Indent YAML files with spaces | ||
[**.yaml,**.yml] | ||
indent_style = space | ||
|
||
# The JSON files contain newlines inconsistently | ||
[*.json] | ||
insert_final_newline = ignore | ||
|
||
# Minified JavaScript files shouldn't be changed | ||
[**.min.js] | ||
indent_style = ignore | ||
insert_final_newline = ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
$ModLoad immark.so # provides --MARK-- message capability | ||
$ModLoad imuxsock.so # provides support for local system logging (e.g. via logger command) | ||
|
||
# default permissions for all log files. | ||
$FileOwner root | ||
$FileGroup adm | ||
$FileCreateMode 0640 | ||
$DirCreateMode 0755 | ||
$Umask 0022 | ||
|
||
template (name="devicelog" type="string" string="/dev/stdout") | ||
|
||
template(name="json_syslog" | ||
type="list") { | ||
constant(value="{") | ||
constant(value="\"@timestamp\":\"") property(name="timereported" dateFormat="rfc3339") | ||
constant(value="\",\"type\":\"syslog_json") | ||
constant(value="\",\"tag\":\"") property(name="syslogtag" format="json") | ||
constant(value="\",\"relayhost\":\"") property(name="fromhost") | ||
constant(value="\",\"relayip\":\"") property(name="fromhost-ip") | ||
constant(value="\",\"logsource\":\"") property(name="source") | ||
constant(value="\",\"hostname\":\"") property(name="hostname" caseconversion="lower") | ||
constant(value="\",\"program\":\"") property(name="programname") | ||
constant(value="\",\"priority\":\"") property(name="pri") | ||
constant(value="\",\"severity\":\"") property(name="syslogseverity") | ||
constant(value="\",\"facility\":\"") property(name="syslogfacility") | ||
constant(value="\",\"severity_label\":\"") property(name="syslogseverity-text") | ||
constant(value="\",\"facility_label\":\"") property(name="syslogfacility-text") | ||
constant(value="\",\"message\":\"") property(name="rawmsg" format="json") | ||
constant(value="\",\"end_msg\":\"") | ||
constant(value="\"}\n") | ||
} | ||
|
||
|
||
if $syslogseverity <= '6' then { | ||
# matching logs will be saved | ||
action(type="omfile" DynaFile="devicelog" template="json_syslog" DirCreateMode="0755" FileCreateMode="0644") | ||
# enable below to stop processing further this log | ||
stop | ||
} | ||
|
||
stop |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
cd integration-tests | ||
docker-compose up --build --abort-on-container-exit --exit-code-from tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# ---- MAILSEND ---- | ||
FROM boky/alpine-bootstrap AS mailsend | ||
COPY install_mailsend.sh /tmp/ | ||
RUN chmod +x /tmp/install_mailsend.sh && /tmp/install_mailsend.sh | ||
|
||
# ---- TEST ---- | ||
FROM boky/alpine-bootstrap | ||
|
||
RUN apk add --no-cache bash bats | ||
COPY --from=mailsend /tmp/mailsend-go-dir/mailsend-go /usr/local/bin/mailsend | ||
|
||
WORKDIR /code | ||
ENTRYPOINT ["/usr/bin/bats"] | ||
|
||
CMD ["-v"] |
Oops, something went wrong.