Fix minio-client creating config directory in user's home

main
Brian Picciano 9 months ago
parent 98e5f4c98c
commit 3c3bd8649a
  1. 1
      default.nix
  2. 32
      go/cmd/entrypoint/garage.go
  3. 13
      tests/cases/garage/00-cli.sh
  4. 8
      tests/cases/garage/01-mc.sh
  5. 9
      tests/entrypoint.sh

@ -169,6 +169,7 @@ in rec {
appImage
pkgs.busybox
pkgs.yq-go
pkgs.jq
]}
export SHELL=${pkgs.bash}/bin/bash
exec ${pkgs.bash}/bin/bash ${./tests}/entrypoint.sh "$@"

@ -7,6 +7,28 @@ import (
"syscall"
)
// minio-client keeps a configuration directory which contains various pieces of
// information which may or may not be useful. Unfortunately when it initializes
// this directory it likes to print some annoying logs, so we pre-initialize in
// order to prevent it from doing so.
func initMCConfigDir() (string, error) {
var (
path = filepath.Join(envDataDirPath, "mc")
sharePath = filepath.Join(path, "share")
configJSONPath = filepath.Join(path, "config.json")
)
if err := os.MkdirAll(sharePath, 0700); err != nil {
return "", fmt.Errorf("creating %q: %w", sharePath, err)
}
if err := os.WriteFile(configJSONPath, []byte(`{}`), 0600); err != nil {
return "", fmt.Errorf("writing %q: %w", configJSONPath, err)
}
return path, nil
}
var subCmdGarageMC = subCmd{
name: "mc",
descr: "Runs the mc (minio-client) binary. The isle garage can be accessed under the `garage` alias",
@ -50,7 +72,15 @@ var subCmdGarageMC = subCmd{
args = args[i:]
}
args = append([]string{binPath("mc")}, args...)
configDir, err := initMCConfigDir()
if err != nil {
return fmt.Errorf("initializing minio-client config directory: %w", err)
}
args = append([]string{
binPath("mc"),
"--config-dir", configDir,
}, args...)
var (
mcHostVar = fmt.Sprintf(

@ -0,0 +1,13 @@
# shellcheck source=../../utils/with-single-node-cluster.sh
source "$UTILS"/with-single-node-cluster.sh
status="$(isle garage cli status | tail -n+3)"
[ "$(echo "$status" | wc -l)" = "3" ]
echo "$status" | grep -q '10.6.9.1:3900'
echo "$status" | grep -q '10.6.9.1:3910'
echo "$status" | grep -q '10.6.9.1:3920'
buckets="$(isle garage cli bucket list | tail -n+2)"
[ "$(echo "$buckets" | wc -l)" = 1 ]
echo "$buckets" | grep -q 'global-shared'

@ -0,0 +1,8 @@
# shellcheck source=../../utils/with-single-node-cluster.sh
source "$UTILS"/with-single-node-cluster.sh
files="$(isle garage mc -- tree --json garage)"
[ "$(echo "$files" | jq -s '.|length')" -ge "1" ]
file="$(echo "$files" | jq -sr '.[0].key')"
[ "$(isle garage mc -- cat "garage/$file" | wc -c)" -gt "0" ]

@ -50,7 +50,7 @@ test_files=$(
find ./cases -type f -name '*.sh' \
| sed "s|^\./cases/||" \
| grep -v entrypoint.sh \
| sort -n
| sort
)
for r in "${REGEXS[@]}"; do
@ -61,7 +61,12 @@ echo -e "number of tests: $(echo "$test_files" | wc -l)\n"
for file in $test_files; do
echo "Running test case: $file"
[ -z "$VERBOSE" ] && output="$TMPDIR/$file.log" || output=/dev/stdout
if [ -z "$VERBOSE" ]; then
output="$TMPDIR/$file.log"
mkdir -p "$(dirname "$output")"
else
output=/dev/stdout
fi
(
export TEST_CASE_FILE="$file"

Loading…
Cancel
Save