listFilesScript builds a shell script printing every object in the store as a `bucket/key` line, filtered by the glob expressed in the given path. A failure enumerating the buckets aborts the script, so an unreachable endpoint is not mistaken for an empty store, and the per-bucket listings run in pa
(path string)
| 683 | // linearly with the number of buckets. The script ends with the pipeline |
| 684 | // emitting the matches, so callers can append further stages (e.g. `| wc -l`) |
| 685 | func listFilesScript(path string) string { |
| 686 | return fmt.Sprintf( |
| 687 | `buckets=$(aws s3api list-buckets --query "Buckets[].Name" --output text) || exit 1; `+ |
| 688 | `dir=$(mktemp -d) || exit 1; trap "rm -rf $dir" EXIT; n=0; `+ |
| 689 | `for b in $buckets; do `+ |
| 690 | `aws s3api list-objects-v2 --bucket "$b" --query "Contents[].Key" --output text | `+ |
| 691 | `tr "\t" "\n" | sed "s|^|$b/|" > "$dir/$b" & `+ |
| 692 | `n=$((n+1)); [ $((n %% 8)) -eq 0 ] && wait; `+ |
| 693 | `done; wait; `+ |
| 694 | `cat /dev/null "$dir"/* 2>/dev/null | { grep -E "%v" || true; }`, |
| 695 | globToRegexp(path)) |
| 696 | } |
| 697 | |
| 698 | // composeListFiles builds the command to list the filenames matching a given path |
| 699 | func composeListFiles(path string) string { |
no test coverage detected