Switch to new Swaggo Makefile template
Build Docker and Deploy / Build Docker Container (push) Failing after 50s Details
Build Docker and Deploy / Deploy to Server (push) Has been skipped Details

This commit is contained in:
Mike Schwörer 2023-10-17 15:52:57 +02:00
parent 0a380f861e
commit a0b9b3ac7d
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 73 additions and 9 deletions

View File

@ -1,10 +1,10 @@
#!/usr/bin/env bash
#
# Wrapper around SCN ( https://simplecloudnotifier.de/ )
# ======================================================
# Convenient Wrapper around SCN ( https://simplecloudnotifier.de/ )
# =================================================================
#
# ./scn_send [@channel] title [content] [priority]
# ./scn_send [[options]] [--] [@channel] title [content] [priority]
#
#
# Call with scn_send "${title}"
@ -14,8 +14,60 @@
# or scn_send "@${channel} "${title}" ${content}"
# or scn_send "@${channel} "${title}" ${content}" "${priority:0|1|2}"
#
# content can be of format "--scnsend-read-body-from-file={path}" to read body from file
# (this circumvents max commandline length)
#
# (For positional arguments the channel must always be prefixed with an `@` to differentiate it from the message title)
# (This means that a message without channel cannot have a title starting with an `@`)
# (Use the non-positional arguments (see below) for a more unambiguous usage, e.g. in scripts)
#
#
# Options:
#
# --body <body> # Directly specify message body (alternative to positional arguments)
# --body=<body> #
#
# --channel <channel> # Directly specify message channel (alternative to positional arguments)
# --channel=<channel> #
#
# --title <title> # Directly specify message title (alternative to positional arguments)
# --title=<title> #
#
# --priority <0|1|2> # Directly specify message priority (alternative to positional arguments)
# --priority=<0|1|2> #
#
# --content <content> # Directly specify message content (alternative to positional arguments)
# --content=<content> #
#
# --content-from-stdin # Read message content from stdin
#
# --content-from-file <file> # Read message content from file
# --content-from-file=<file> # (this circumvents the max commandline-length problem)
# --scnsend-read-body-from-file=<file> #
#
# --config-file <file> # Specify the SCN_UID/SCN_KEY config file (default:/etc/scn.conf)
# --config-file=<file> #
#
# --scn-uid <uid> # Supply the key+uid directly instead of using the config file
# --scn-uid=<key> #
# --scn-key <uid> #
# --scn-key=<key> #
#
# --curl # Print the curl command, instead of actually sending it
#
# --ping # Test SCN server for its availability
#
# --help # Show help text
#
# --version # Show script version
#
# More:
#
# Use `--` to enforce the parsing of positional aguments, e.g.:
# ./scn_send -- @MY_CHANNEL "Test Message" "SOmehing happened"
# echo "Test" | ./scn_send --content-from-stdin -- "Somehing happened"
# ./scn_send -- "Test" "--help"
#
# Supply SCN_UID and SCN_KEY to directly specify the used uid/key
# (alternative to cli parameter or config-file)
#
################################################################################
@ -36,6 +88,15 @@ function green() { if cfgcol; then echo -e "\x1B[32m$1\x1B[0m"; else ec
#
# Get env 'SCN_UID' and 'SCN_KEY' from conf file
#
if [ ! -f "/etc/scn.conf" ]; then
rederr "Missing configuration file '/etc/scn.conf'"
rederr "Please create a (user-readable) file with the following content:"
rederr " SCN_UID=your-userid"
rederr " SCN_KEY=your-sendkey"
exit 1
fi
# shellcheck source=/dev/null
. "/etc/scn.conf"
SCN_UID=${SCN_UID:-}
@ -105,7 +166,7 @@ if [ ${#args[@]} -gt 0 ]; then
fi
if [[ "$content" == --scnsend-read-body-from-file=* ]]; then
path="$( awk '{ print substr($0, 31) }' <<< "$content" )"
path="$( awk '{ print substr($0, 31) }' <<< "$content" )" # TODO this is useless, we remove the arg-limit from scn but then send the too-long data to curl -.-
content="$( cat "$path" )"
fi

View File

@ -7,6 +7,9 @@ HASH=$(shell git rev-parse HEAD)
.PHONY: test swagger pygmentize docker migrate dgi pygmentize lint docker
SWAGGO_VERSION=v1.8.12
SWAGGO=github.com/swaggo/swag/cmd/swag@$(SWAGGO_VERSION)
build: swagger pygmentize fmt
mkdir -p _build
rm -f ./_build/scn_backend
@ -38,10 +41,10 @@ docker: dgi
-t "$(DOCKER_REPO)/$(DOCKER_NAME):$(NAMESPACE)-latest" \
-t "$(DOCKER_REPO)/$(DOCKER_NAME):latest" \
.
swagger:
which swag || go install github.com/swaggo/swag/cmd/swag@v1.8.12
swag init -generalInfo api/router.go --propertyStrategy snakecase --output ./swagger/ --outputTypes "json,yaml"
mkdir -p ".swaggobin"
[ -f ".swaggobin/swag_$(SWAGGO_VERSION)" ] || { GOBIN=/tmp/_swaggo go install $(SWAGGO); cp "/tmp/_swaggo/swag" ".swaggobin/swag_$(SWAGGO_VERSION)"; rm -rf "/tmp/_swaggo"; }
".swaggobin/swag_$(SWAGGO_VERSION)" init -generalInfo ./api/router.go --propertyStrategy camelcase --output ./swagger/ --outputTypes "json,yaml" --overridesFile override.swag
pygmentize: website/scn_send.html