Skip to content

Commit

Permalink
create buckets on star
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Cairns committed Sep 4, 2024
1 parent 39b00fa commit 60ab59e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 23 deletions.
44 changes: 44 additions & 0 deletions commands/minio/create-buckets
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
## Description: Creates buckets for drupal
## Usage: create-buckets [-f]
## Flags: [{"Usage": "recreates the buckets", "Shorthand": "f"}]
#ddev-generated

force=false
while getopts "f" flag; do
case $flag in
f) # Handle the -f flag with an argument
force=true
# Process the specified file
;;
\?)
echo Invalid arguments
exit 1
;;
esac
done

bucket=minio/flysystem

bucket-exits() {
if mc ls $bucket &> /dev/null; then
echo "The bucket $bucket already exists"
else
echo "The bucket $bucket does not exists"
return 1
fi
}

if [ "$force" = "true" ]; then
if bucket-exits; then
echo Deleting bucket $bucket
mc rm --recursive --force $bucket > /dev/null
mc rb $bucket > /dev/null
fi
fi

if ! bucket-exits; then
echo Creating bucket $bucket
mc mb $bucket > /dev/null
fi

13 changes: 0 additions & 13 deletions commands/minio/init-buckets

This file was deleted.

4 changes: 4 additions & 0 deletions config.flysystem-minio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# ddev-generated
hooks:
post-start:
- exec-host: "ddev create-buckets"
12 changes: 2 additions & 10 deletions install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@ dependencies:
- minio

project_files:
- commands/minio/init-buckets
- commands/minio/create-buckets
- minio-flysystem/flysystem_config.json
- docker-compose.web-flysystem.yaml

post_install_actions:
- |
if ! grep 'ddev init-buckets' commands/host/full-install; then
sed -i '/ddev start/a ddev init-buckets' commands/host/full-install
fi
removal_actions:
- |
sed -ni '/ddev init-buckets/!p' commands/host/full-install
- config.flysystem-minio.yaml

0 comments on commit 60ab59e

Please sign in to comment.