Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor integration script #711

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions integration_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ logUnhandledError() {
log_info "You could try deleting the file storage '${OPENPROJECT_STORAGE_NAME}' in OpenProject and run the script again."
}

checkForOpenProjectOrNextcloudIntegrationConfiguration() {
# This function check whether the configuration is complete or not in both OpenProject and Nextcloud
logCompleteIntegrationConfiguration() {
log_success "Setup of OpenProject and Nextcloud is complete."
exit 0
}

checkOpenProjectIntegrationConfiguration() {
# At this point we know that the file storage already exists, so we only check if it is configured completely in OpenProject
log_success "File storage name '$OPENPROJECT_STORAGE_NAME' in OpenProject already exists."
status_op=$(isOpenProjectFileStorageConfigOk)
Expand All @@ -148,6 +152,9 @@ checkForOpenProjectOrNextcloudIntegrationConfiguration() {
exit 1
fi
log_success "File storage name '$OPENPROJECT_STORAGE_NAME' in OpenProject for integration with Nextcloud is configured."
}

checkNextcloudIntegrationConfiguration() {
status_nc=$(isNextcloudAdminConfigOk)
if [[ "$status_nc" -ne 0 ]]; then
log_error "Some admin configuration is incomplete in Nextcloud '${NEXTCLOUD_HOST}' for integration with OpenProject."
Expand All @@ -158,8 +165,6 @@ checkForOpenProjectOrNextcloudIntegrationConfiguration() {
exit 1
fi
log_success "Admin configuration in Nextcloud for integration with OpenProject is configured."
log_success "Setup of OpenProject and Nextcloud is complete."
exit 0
}

# check if both instances are started or not
Expand Down Expand Up @@ -260,12 +265,16 @@ if [[ ${response_type} == "Error" ]]; then
logUnhandledError
exit 1
fi
checkForOpenProjectOrNextcloudIntegrationConfiguration
checkOpenProjectIntegrationConfiguration
checkNextcloudIntegrationConfiguration
logCompleteIntegrationConfiguration
elif [[ ${error_id} == "urn:openproject-org:api:v3:errors:PropertyConstraintViolation" ]]; then
# A PropertyConstraintViolation is always a single error
error_messages_grep=$(echo $create_storage_response | jq -r '.message')
if [[ "$error_messages_grep" == "Host has already been taken." || "$error_messages_grep" == "Name has already been taken." ]]; then
checkForOpenProjectOrNextcloudIntegrationConfiguration
checkOpenProjectIntegrationConfiguration
checkNextcloudIntegrationConfiguration
logCompleteIntegrationConfiguration
else
logUnhandledError
exit 1
Expand Down Expand Up @@ -395,4 +404,4 @@ EOF
fi
fi

log_success "Setup of OpenProject and Nextcloud is complete."
logCompleteIntegrationConfiguration
Loading