Skip to content

Commit

Permalink
Merge pull request #3 from grafana/examples
Browse files Browse the repository at this point in the history
docs: added awesome k6 list generator exampe
  • Loading branch information
szkiba authored Jul 30, 2024
2 parents 1974e14 + 549cf99 commit 5af0fc1
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
48 changes: 48 additions & 0 deletions examples/awesome-k6-extensions/awesome-k6-extensions
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

appname=awesome-k6-extensions

TEMP=$(getopt -o 'n:h' --long 'stars:,help' -n $appname -- "$@")

stars=15

usage() {
cat >&2 <<EOF
Create awesome k6 extension list based on registry.
Usage:
$appname [flags]
Flags:
-n, --stars num minimum number of stars for community extensions (default $stars)
-h, --help print usage
EOF
}

if [ $? -ne 0 ]; then
exit 1
fi

eval set -- "$TEMP"
unset TEMP

while true; do
case "$1" in
'-n'|'--stars')
stars=$2
shift 2
continue
;;
'-h'|'--help')
usage
exit 0
;;
'--')
shift
break
;;
esac
done

curl -s https://grafana.github.io/k6-extension-registry/registry.json |
jq --argjson stars $stars -r -f awesome-k6-extensions.jq
18 changes: 18 additions & 0 deletions examples/awesome-k6-extensions/awesome-k6-extensions.jq
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
map(
select(.module != "go.k6.io/k6") |
select( (.repo.stars >= $stars or .official)) |
{
name:.repo.name,
url: .repo.url,
description: (if .description | endswith(".") then .description else .description + "." end),
order: (if .official then 1 else 2 end),
tier: (if .official then "Official" else "Community" end)
}
) |
group_by(.order) | .[] |
(
["\n### \(.|first|.tier)\n"] +
(sort_by(.name)| map("- [\(.name)](\(.url)) - \(.description)"))
) |
.[]

0 comments on commit 5af0fc1

Please sign in to comment.