-
Notifications
You must be signed in to change notification settings - Fork 144
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
Multi account support | Fix #98 #137
Conversation
f2b8cac
to
2245eaf
Compare
2245eaf
to
ba45689
Compare
This is a huge change, literally and figuratively both. I have tested multiple scenarios to make it break free, like with no config, with config having old values, config having old and new values both, config with just new values. This has been working so far. After this is merged then the service accounts pull request will be updated accordingly. |
ba45689
to
cda59ac
Compare
4796e60
to
aa0a33e
Compare
@Akianonymus is this PR safe to merge? |
@labbots Have to test again, it's been a while since i touched this. Will be ready in this week probably, given no anamolies. |
3c24c68
to
b6fbb3f
Compare
Add four new flags * -a | --account - Use a different account than default * -la | --list accounts - List all the accounts configured with CLIENT_ID, CLIENT_SECRET and REFRESH_TOKEN * -ca | --create-account - Create a new account * -da | --delete-account - Delete an existing account --list-accounts, --create-accounts and --delete-account flags can be used without any usual input required The config format is changed, ACCOUNT_${account}_ prefix is added to every config var, where ${account} is the account name The old configs will be automatically migrated with account name default( if default taken then a number suffix will be added like default1, default2, etc ) move authentication/config related functions to auth-utils.[bash|sh] create more authentication functions to reduce some clutter add a lot of error checks, minute situations like chmod failing, failing to write to config file bash script changes: export all sub functions in their sub scripts export variables when it is created that are needed for parallel uploads
… changes * as it is supposed to be a sample script, so don't modify default config * new flag "add" - authenticates a new user but will use the client id and secret if available. If not, then same as create flag.
b6fbb3f
to
06cf011
Compare
@labbots This should be safe to merge now. I have tried to test in many scenarios as possible, as mentioned in one of my previous comments in this thread, regarding config files and authentication. For upload tests, i ran this script, which covers almost all of the uploading aspects of the script:- #!/usr/bin/env bash
set -e
shell="${1:?Give Shell}"
cd "${shell}/release" || exit 1
LOGNAME="$((RANDOM * RANDOM))"
FILE="${LOGNAME}".testfile
trap 'exit' INT TERM
trap 'rm -rf "${FILE}"* "${LOGNAME}"* Test_gupload ; kill -- -$$' EXIT
trap '' TSTP # ignore ctrl + z
_show_log() {
printf "%s\n" "$(< "${LOGNAME}")" && rm "${LOGNAME}"
printf "\n"
}
# File test
printf "" >| "${FILE}"
DEFAULT_ARGS="./gupload ${FILE} -C Test_gupload --skip-internet-check"
${DEFAULT_ARGS}
${DEFAULT_ARGS} -d -r root -i "${LOGNAME}" -S
TEST_FILE_ID="$(: $(grep ID "${LOGNAME}") && printf "%s\n" "${_/ID: /}")"
_show_log
${DEFAULT_ARGS} -o -r root -i "${LOGNAME}" -S
_show_log
# Folder upload tests
mkdir -p Test_gupload/test
for i in {Test_gupload,Test_gupload/test}/{1..2}; do
printf "%s\n" "" >| "${i}"
done
DEFAULT_FOLDER_ARGS="./gupload Test_gupload --skip-internet-check"
${DEFAULT_FOLDER_ARGS} -d -r root -i "${LOGNAME}" -S
_show_log
${DEFAULT_FOLDER_ARGS} -o -r root -i "${LOGNAME}"
_show_log
${DEFAULT_FOLDER_ARGS} -s -d -r root -i "${LOGNAME}"
_show_log
${DEFAULT_FOLDER_ARGS} -s -o -r root -i "${LOGNAME}" -S
_show_log
${DEFAULT_FOLDER_ARGS} -d -r root -i "${LOGNAME}" -p 2 -S
_show_log
${DEFAULT_FOLDER_ARGS} -o -r root -i "${LOGNAME}" -p 2
_show_log
${DEFAULT_FOLDER_ARGS} -s -d -r root -i "${LOGNAME}" -p 2
_show_log
${DEFAULT_FOLDER_ARGS} -s -o -r root -i "${LOGNAME}" -p 2 -S
_show_log
# file clone test
./gupload -C Test_gupload -cl "${TEST_FILE_ID}" -r root -i "${LOGNAME}" -S
_show_log
./gupload -C Test_gupload -cl "${TEST_FILE_ID}" -r root -i "${LOGNAME}" -d -S
_show_log
./gupload -C Test_gupload -cl "${TEST_FILE_ID}" -r root -i "${LOGNAME}" -o -S
_show_log
|
@Akianonymus I ve approved the changes. Feel free to merge whenever you are ready |
Enable rebase and merge option, seem like it is disabled. |
@Akianonymus Rebase and merge is now enabled |
Add four new flags
-a | --account - Use a different account than default
-la | --list accounts - List all the accounts configured with CLIENT_ID, CLIENT_SECRET and REFRESH_TOKEN
-ca | --create-account - Create a new account
-da | --delete-account - Delete an existing account
--list-accounts, --create-accounts and --delete-account flags can be used without any usual input required
The config format is changed, ACCOUNT_${account}_ prefix is added to every config var, where ${account} is the account name
The old configs will be automatically migrated with account name default( if default taken then a number suffix will be added like default1, default2, etc )
move authentication/config related functions to auth-utils.[bash|sh]
create more authentication functions to reduce some clutter
add a lot of error checks, minute situations like chmod failing, failing to write to config file
bash script changes: export all sub functions in their sub scripts
export variables when it is created that are needed for parallel uploads
google-oauth2.[sh|bash]: Make changes for refactored functions | Misc changes
as it is supposed to be a sample script, so don't modify default config
new flag "add" - authenticates a new user but will use the client id and secret if available. If not, then same as create flag.