-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLI command to upload plugins/themes to AspireCloud (#42)
* feat: add meta/bin/push-to-aspirecloud * feat: upload to AC in chunks of 100 (configurable) * fix: add ASPIRECLOUD_ADMIN_API_* envars to docker-compose.yml * feat: add --after parameter to meta dump commands * feat: enable compression in push-to-aspirecloud * fix: respect the --update-all flag once again * docs: update README with AC integration instructions
- Loading branch information
1 parent
afcc757
commit d9406d3
Showing
10 changed files
with
185 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# EXAMPLE: bin/console sync:meta:dump:plugins --after='-1 hour' | meta/bin/push-to-aspirecloud | ||
# | ||
|
||
. $(dirname $0)/prelude.bash | ||
|
||
URL=${ASPIRECLOUD_ADMIN_API_URL:?variable not defined} | ||
KEY=${ASPIRECLOUD_ADMIN_API_KEY:?variable not defined} | ||
|
||
CHUNK_SIZE=${CHUNK_SIZE:-100} # values > 100 are likely to run into POST size limits | ||
|
||
CURL_ARGS=${CURL_ARGS:-'--compressed'} | ||
|
||
function main() { | ||
local buffer=$(mktemp) | ||
trap 'rm -f "$buffer"' EXIT | ||
|
||
local count=0 | ||
|
||
while IFS= read -r line || [[ -n $line ]]; do | ||
echo "$line" >> $buffer | ||
(( count += 1 )) | ||
echo -e -n "\ruploading $count ... " | ||
[[ $(wc -l < $buffer) -ge $CHUNK_SIZE ]] && upload $buffer | ||
done | ||
|
||
upload $buffer | ||
|
||
echo "done" | ||
} | ||
|
||
function upload() { | ||
buffer=$1 | ||
[[ -s $buffer ]] && curl --silent -XPOST \ | ||
-H "Authorization: Bearer $KEY" \ | ||
-H 'Content-Type: application/nljson' \ | ||
-H 'Accept: application/json' \ | ||
--data-binary @"$buffer" \ | ||
$CURL_ARGS \ | ||
"$URL/v1/import" > /dev/null | ||
cp /dev/null $buffer | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.