Add macOS support

This commit is contained in:
Tortue Torche 2021-09-15 17:08:24 +02:00
parent b287b7f16f
commit 8261c27949
3 changed files with 23 additions and 3 deletions

View File

@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- macOS support
### Changed
- Remove parallel requests improvement, because it's buggy in some situations...

View File

@ -55,6 +55,7 @@ You will need these dependencies installed:
- [jq](https://stedolan.github.io/jq/)<sup title="required">*</sup> <small>(>= 1.5.1)</small>
- [timeout](https://man7.org/linux/man-pages/man1/timeout.1.html)<sup title="required">*</sup> <small>For macOS run: `brew install coreutils`</small>
- [uuidgen](https://man7.org/linux/man-pages/man1/uuidgen.1.html) only for some <abbr title="Operating System">OS</abbr> <small>(Debian and Alpine work fine without it)</small>
- greadlink <small>Only for macOS run: `brew install coreutils`</small>
<sup>\*</sup> = required

22
psu
View File

@ -970,6 +970,17 @@ curl_wrapper() {
fi
}
# Readlink command wrapper
# useful to support macOS, run:
# brew install coreutils
readlink_wrapper() {
if [ -x "$(command -v greadlink)" ]; then
greadlink "$@"
else
readlink "$@"
fi
}
###################################################
############### actions section ###################
###################################################
@ -996,10 +1007,10 @@ deploy() {
if [ "$DOCKER_COMPOSE_LINT" == "true" ]; then
lint
fi
echo_debug "DOCKER_COMPOSE_FILE -> $DOCKER_COMPOSE_FILE"
# Read docker-compose file content
local docker_compose_file_content
docker_compose_file_content="$( jq -Rscjr '{StackFileContent: . }' $DOCKER_COMPOSE_FILE | tail -c +2 | head -c -1 )"
echo_debug "DOCKER_COMPOSE_FILE -> $DOCKER_COMPOSE_FILE"
docker_compose_file_content="$(jq -Rscjr '{StackFileContent: .}' "$DOCKER_COMPOSE_FILE" | sed -e 's/^{//' -e 's/}$//')"
echo_debug "docker_compose_file_content -> $docker_compose_file_content"
local json_temp_path
@ -1328,7 +1339,12 @@ lint() {
# JSON string #
###################################################
env_file_to_json() {
env -i sh -c "(unset \$(env | sed 's/=.*//'); set -a; . $(readlink -f $ENVIRONMENT_VARIABLES_FILE); set +a; jq -njc 'env | to_entries | map({name: .key, value: .value})')"
local jq_command
# For macOS compatibility
jq_command="$(which jq)"
env -i sh -c "(unset \$(env | sed 's/=.*//'); set -a; . $(readlink_wrapper -f $ENVIRONMENT_VARIABLES_FILE); set +a; \"$jq_command\" -njc 'env | to_entries | map({name: .key, value: .value})')"
}
# Set the ACTIONS variable who's a list of all psu actions