Skip to content

Commit 92adb3f

Browse files
Merge pull request #90 from kapishmalik/feature/add-support-for-wiremock-options-as-env-variable
#78 - Add support for WireMock CLI options as environment variable
2 parents 9ebe913 + 53e9d09 commit 92adb3f

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

alpine/docker-entrypoint.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ set -e
44

55
# Set `java` command if needed
66
if [ "$1" = "" -o "${1#-}" != "$1" ]; then
7-
set -- java $JAVA_OPTS -cp /var/wiremock/lib/*:/var/wiremock/extensions/* wiremock.Run "$@"
7+
set -- java $JAVA_OPTS -cp /var/wiremock/lib/*:/var/wiremock/extensions/* wiremock.Run "$@" $WIREMOCK_OPTIONS
88
fi
99

1010
# allow the container to be started with `-e uid=`
1111
if [ "$uid" != "" ]; then
1212
# Change the ownership of /home/wiremock to $uid
1313
chown -R $uid:$uid /home/wiremock
1414

15-
set -- su-exec $uid:$uid "$@"
15+
set -- su-exec $uid:$uid "$@" $WIREMOCK_OPTIONS
1616
fi
1717

18-
exec "$@"
18+
exec "$@" $WIREMOCK_OPTIONS

docker-entrypoint.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ set -e
44

55
# Set `java` command if needed
66
if [ "$1" = "" -o "${1:0:1}" = "-" ]; then
7-
set -- java $JAVA_OPTS -cp /var/wiremock/lib/*:/var/wiremock/extensions/* wiremock.Run "$@"
7+
set -- java $JAVA_OPTS -cp /var/wiremock/lib/*:/var/wiremock/extensions/* wiremock.Run "$@" $WIREMOCK_OPTIONS
88
fi
99

1010
# allow the container to be started with `-e uid=`
1111
if [ "$uid" != "" ]; then
1212
# Change the ownership of /home/wiremock to $uid
1313
chown -R $uid:$uid /home/wiremock
14-
15-
set -- gosu $uid:$uid "$@"
14+
set -- gosu $uid:$uid "$@" $WIREMOCK_OPTIONS
1615
fi
1716

18-
exec "$@"
17+
exec "$@" $WIREMOCK_OPTIONS
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (C) 2023 WireMock Inc, Oleg Nenashev and all project contributors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.wiremock.docker.it;
17+
18+
import org.junit.jupiter.api.Test;
19+
import org.testcontainers.junit.jupiter.Container;
20+
import org.testcontainers.junit.jupiter.Testcontainers;
21+
22+
import org.wiremock.integrations.testcontainers.WireMockContainer;
23+
import static org.junit.jupiter.api.Assertions.assertTrue;
24+
25+
@Testcontainers
26+
class WireMockOptionsTest {
27+
28+
@Container
29+
public WireMockContainer wiremockServer = new WireMockContainer(TestConfig.WIREMOCK_IMAGE)
30+
.withEnv("WIREMOCK_OPTIONS", "--verbose");
31+
32+
@Test
33+
public void checkVerboseEnablingLogLine() {
34+
assertTrue(wiremockServer.getLogs().contains("Verbose logging enabled"));
35+
}
36+
}

0 commit comments

Comments
 (0)