Skip to content

Commit a957816

Browse files
authored
Add build_args also to ct_s2i_build_as_df function. (#368)
* Add build_args also to `ct_s2i_build_as_df` function. We have to functions to build image. This one and `ct_test_app_dockerfile` In case of --ulimit is defined in s2i_args variable we will add this parameter to docker/podman command line. An example: $ s2i_args="pull-policy=never --incremental -e DEV_MODE=true -v /var/lib/psql --ulimit nofile=4096:4096" $ echo "$s2i_args" | grep -q '\--ulimit' && build_args=$(echo "$s2i_args" | grep -o -e '\--ulimit[[:space:]]\S*\w=*') $ echo $build_args --ulimit nofile=4096:4096 The second example: $ s2i_args="pull-policy=never --incremental -e DEV_MODE=true -v /var/lib/psql --ulimit nofile=4096:4096 -v /etc" $ echo "$s2i_args" | grep -q '\--ulimit' && build_args=$(echo "$s2i_args" | grep -o -e '\--ulimit[[:space:]]\S*\w=*') $ echo $build_args --ulimit nofile=4096:4096 * Add wrapper for building images by podman with arguments Signed-off-by: Petr "Stone" Hracek <[email protected]>
1 parent 1f774c8 commit a957816

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

test-lib.sh

+25-2
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ ct_get_public_image_name() {
813813
elif [ "$os" == "rhel9" ]; then
814814
public_image_name=$registry/rhel9/$base_image_name-${version//./}
815815
elif [ "$os" == "centos7" ]; then
816-
public_image_name=$registry/centos7/$base_image_name-${version//./}-centos7
816+
public_image_name=$registry/centos7/$base_image_name-${version//./}-centos7:centos7
817817
elif [ "$os" == "c8s" ]; then
818818
public_image_name=$registry/sclorg/$base_image_name-${version//./}-c8s
819819
elif [ "$os" == "c9s" ]; then
@@ -883,6 +883,9 @@ ct_s2i_usage()
883883
# ct_s2i_build_as_df APP_PATH SRC_IMAGE DST_IMAGE [S2I_ARGS]
884884
# ----------------------------
885885
# Create a new s2i app image from local sources in a similar way as source-to-image would have used.
886+
# This function is wrapper for ct_s2i_build_as_df_build_args in case user do not want to add build args
887+
# This function is used in all https://github.com/sclorg/*-container test cases and we do not
888+
# want to break functionality
886889
# Argument: APP_PATH - local path to the app sources to be used in the test
887890
# Argument: SRC_IMAGE - image to be used as a base for the s2i build
888891
# Argument: DST_IMAGE - image name to be used during the tagging of the s2i build result
@@ -894,6 +897,26 @@ ct_s2i_build_as_df()
894897
local src_image=$1; shift
895898
local dst_image=$1; shift
896899
local s2i_args="$*";
900+
901+
ct_s2i_build_as_df_build_args "$app_path" "$src_image" "$dst_image" "" "$s2i_args"
902+
}
903+
904+
# ct_s2i_build_as_df_build_args APP_PATH SRC_IMAGE DST_IMAGE BUILD_ARGS [S2I_ARGS]
905+
# ----------------------------
906+
# Create a new s2i app image from local sources in a similar way as source-to-image would have used.
907+
# Argument: APP_PATH - local path to the app sources to be used in the test
908+
# Argument: SRC_IMAGE - image to be used as a base for the s2i build
909+
# Argument: DST_IMAGE - image name to be used during the tagging of the s2i build result
910+
# Argument: BUILD_ARGS - Build arguments to be used in the s2i build
911+
# Argument: S2I_ARGS - Additional list of source-to-image arguments.
912+
# Only used to check for pull-policy=never and environment variable definitions.
913+
ct_s2i_build_as_df_build_args()
914+
{
915+
local app_path=$1; shift
916+
local src_image=$1; shift
917+
local dst_image=$1; shift
918+
local build_args=$1; shift
919+
local s2i_args="$*";
897920
local local_app=upload/src/
898921
local local_scripts=upload/scripts/
899922
local user_id=
@@ -989,7 +1012,7 @@ EOF
9891012
read -ra mount_options <<< "$(echo "$s2i_args" | grep -o -e '\(-v\)[[:space:]]\.*\S*' || true)"
9901013

9911014
# Run the build and tag the result
992-
ct_build_image_and_parse_id "$df_name" "${mount_options[*]+${mount_options[*]}} -t $dst_image ."
1015+
ct_build_image_and_parse_id "$df_name" "${mount_options[*]+${mount_options[*]}} -t $dst_image . $build_args"
9931016
#shellcheck disable=SC2181
9941017
if [ "$?" -ne 0 ]; then
9951018
echo " ERROR: Failed to to build $df_name" >&2

tests/failures/check/v0/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
FROM quay.io/centos7/s2i-core-centos7
1+
FROM quay.io/centos7/s2i-core-centos7:centos7
22
LABEL name=test-image

tests/test-lib/image_availability

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,25 @@ set -e
55
. test-lib.sh
66

77
# This should succeed
8-
if ! ct_pull_image quay.io/centos7/ruby-27-centos7; then
8+
if ! ct_pull_image quay.io/centos7/ruby-27-centos7:centos7; then
99
echo "image_availability test failed"
1010
false
1111
fi
1212

1313
# This should fail
14-
if ct_pull_image quay.io/centos7/ruby-24-centos7 false 1; then
14+
if ct_pull_image quay.io/centos7/ruby-24-centos7:centos7 false 1; then
1515
echo "image_availability test failed"
1616
false
1717
fi
1818

1919
# This should succeed
20-
if ! ct_check_image_availability quay.io/centos7/ruby-27-centos7; then
20+
if ! ct_check_image_availability quay.io/centos7/ruby-27-centos7:centos7; then
2121
echo "check_image_availability test failed"
2222
false
2323
fi
2424

2525
# This should fail
26-
if ct_check_image_availability quay.io/centos7/ruby-24-centos7; then
26+
if ct_check_image_availability quay.io/centos7/ruby-24-centos7:centos7; then
2727
echo "check_image_availability test failed"
2828
false
2929
fi

tests/test-lib/public_image_name

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -e
55
. test-lib.sh
66

77
combinations="rhel7:registry.redhat.io/rhscl/postgresql-10-rhel7
8-
centos7:quay.io/centos7/postgresql-10-centos7
8+
centos7:quay.io/centos7/postgresql-10-centos7:centos7
99
rhel8:registry.redhat.io/rhel8/postgresql-10
1010
"
1111

0 commit comments

Comments
 (0)