@@ -133,11 +133,15 @@ function build_image_override_file() {
133133 " $( docker_compose_config_version) " " $@ "
134134}
135135
136- # Checks that a specific version of docker-compose supports cache_from
136+ # Checks that a specific version of docker-compose supports cache_from and cache_to
137137function docker_compose_supports_cache() {
138138 local version=" $1 "
139139 if [[ " $version " == 1* || " $version " =~ ^(2| 3)(\. [01])? $ ]] ; then
140- return 1
140+ echo " Unsupported Docker Compose config file version: $version "
141+ echo " The 'cache_from' option can only be used with Compose file versions 2.2 or 3.2 and above."
142+ echo " For more information on Docker Compose configuration file versions, see:"
143+ echo " https://docs.docker.com/compose/compose-file/compose-versioning/#versioning"
144+ exit 1
141145 fi
142146}
143147
@@ -216,13 +220,7 @@ function build_image_override_file_with_version() {
216220 fi
217221
218222 if [[ " $cache_from_amt " -gt 0 ]] ; then
219- if ! docker_compose_supports_cache " $version " ; then
220- echo " Unsupported Docker Compose config file version: $version "
221- echo " The 'cache_from' option can only be used with Compose file versions 2.2 or 3.2 and above."
222- echo " For more information on Docker Compose configuration file versions, see:"
223- echo " https://docs.docker.com/compose/compose-file/compose-versioning/#versioning"
224- exit 1
225- fi
223+ docker_compose_supports_cache " $version "
226224
227225 printf " cache_from:\\ n"
228226 for cache_from_i in " ${cache_from[@]} " ; do
@@ -231,13 +229,7 @@ function build_image_override_file_with_version() {
231229 fi
232230
233231 if [[ " $cache_to_amt " -gt 0 ]] ; then
234- if ! docker_compose_supports_cache " $version " ; then
235- echo " Unsupported Docker Compose config file version: $version "
236- echo " The 'cache_to' option can only be used with Compose file versions 2.2 or 3.2 and above."
237- echo " For more information on Docker Compose configuration file versions, see:"
238- echo " https://docs.docker.com/compose/compose-file/compose-versioning/#versioning"
239- exit 1
240- fi
232+ docker_compose_supports_cache " $version "
241233
242234 printf " cache_to:\\ n"
243235 for cache_to_i in " ${cache_to[@]} " ; do
0 commit comments