Add dependency validation
This commit is contained in:
		
							
								
								
									
										17
									
								
								functions
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								functions
									
									
									
									
									
								
							| @ -7,12 +7,19 @@ source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions" | ||||
|  | ||||
| dokku-ansible-deploy-validate-dependencies() { | ||||
|   # shellcheck disable=SC2034 | ||||
|   declare desc="check that ansible dependencies are available" | ||||
|   declare desc="check that plugin dependencies are available" | ||||
|  | ||||
|   declare ANSIBLE_DIR="$DOKKU_ROOT/.ansible/" | ||||
|  | ||||
|   if ! command -v "ansible-playbook" &>/dev/null; then | ||||
|     dokku_col_log_info1_quiet "Missing ansible dependency, run dokku plugin:install-dependencies" | ||||
|     exit 1 | ||||
|   fi | ||||
|  | ||||
|   if [[ ! -d $ANSIBLE_DIR ]]; then | ||||
|     dokku_col_log_info1_quiet "Missing $ANSIBLE_DIR, run dokku plugin:install-dependencies" | ||||
|     exit 0 | ||||
|   fi | ||||
| } | ||||
|  | ||||
| dokku-ansible-deploy-vault-pass-cmd() { | ||||
| @ -78,6 +85,8 @@ dokku-ansible-deploy-post-extract() { | ||||
|   # shellcheck disable=SC2034 | ||||
|   declare desc="run the post-extract hook to setup the plugin" | ||||
|  | ||||
|   dokku-ansible-deploy-validate-dependencies | ||||
|  | ||||
|   declare APP="$1" TMPDIR="$2" | ||||
|  | ||||
|   if [[ -d "$TMPDIR/deploy.d" ]] && [[ "$(ls -A "$TMPDIR/deploy.d")" ]]; then | ||||
| @ -99,6 +108,8 @@ dokku-ansible-deploy-pre-deploy() { | ||||
|   # shellcheck disable=SC2034 | ||||
|   declare desc="run the pre-deploy hook to setup an app" | ||||
|  | ||||
|   dokku-ansible-deploy-validate-dependencies | ||||
|  | ||||
|   declare APP="$1" | ||||
|   declare APP_CONFIG_PATH="$DOKKU_LIB_ROOT/data/deploy.d/$APP" | ||||
|   declare PLUGIN_PATH="$PLUGIN_CORE_AVAILABLE_PATH/ansible-deploy" | ||||
| @ -116,6 +127,8 @@ dokku-ansible-deploy-post-deploy() { | ||||
|   # shellcheck disable=SC2034 | ||||
|   declare desc="run the post-deploy hook to finish an app setup" | ||||
|  | ||||
|   dokku-ansible-deploy-validate-dependencies | ||||
|  | ||||
|   declare APP="$1" | ||||
|   declare POSTDEPLOY="$PLUGIN_CORE_AVAILABLE_PATH/ansible-deploy/scripts/postdeploy.py" | ||||
|  | ||||
| @ -127,6 +140,8 @@ dokku-ansible-deploy-post-delete() { | ||||
|   # shellcheck disable=SC2034 | ||||
|   declare desc="run the post-delete hook to remove an app" | ||||
|  | ||||
|   dokku-ansible-deploy-validate-dependencies | ||||
|  | ||||
|   declare APP="$1" | ||||
|   declare POSTDELETE="$PLUGIN_CORE_AVAILABLE_PATH/ansible-deploy/scripts/postdelete.py" | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user