Skip to content

Commit

Permalink
Merge pull request #22 from navicore/skipvar
Browse files Browse the repository at this point in the history
  • Loading branch information
navicore authored Oct 12, 2021
2 parents d73bcd9 + 7fa77d4 commit 6295b41
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 Ed Sweeney
Copyright (c) 2016-2022 Ed Sweeney

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ resources:
proxy_port: 1234 [optional]
proxy_username: myusername [optional]
proxy_password: mysecret [optional]
skip_cert_verification [optional]
```
* `url`: *Required.* The webhook URL as provided by Teams when you add a
Expand All @@ -73,6 +74,9 @@ form: `https://outlook.office365.com/webhook/XXX`
* `proxy_port`: *Optional.* Basic auth for forwarding proxies
* `proxy_username`: *Optional.* Basic auth for forwarding proxies
* `proxy_password`: *Optional.* Basic auth for forwarding proxies
* `skip_cert_verification`: *Optional.* cURL `-k` option for debugging when behind TLS rewrite proxies when the internal cert is self-signed or not properly distributed
* `verbose`: *Optional.* cURL `-v` option for debugging
* `silent`: *Optional.* cURL `-s` option for no logging

next, define the non-built-in type:

Expand Down
23 changes: 22 additions & 1 deletion out
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

CURL_OPTION="-v"
CURL_OPTION=""

set -e
exec 3>&1
Expand Down Expand Up @@ -56,6 +56,9 @@ proxy_url="$(jq -r '.source.proxy_url // empty' < "${payload}")"
proxy_port="$(jq -r '.source.proxy_port // empty' < "${payload}")"
proxy_username="$(jq -r '.source.proxy_username // empty' < "${payload}")"
proxy_password="$(jq -r '.source.proxy_password // empty' < "${payload}")"
skip_cert_verification="$(jq -r '.source.skip_cert_verification // empty' < "${payload}")"
verbose="$(jq -r '.source.verbose // empty' < "${payload}")"
silent="$(jq -r '.source.silent // empty' < "${payload}")"

if [ -z ${proxy_url} ] || [ -z ${proxy_port} ]; then
PROXY_OPTIONS=""
Expand All @@ -69,6 +72,24 @@ else
PROXY_OPTIONS="--proxy-user ${proxy_username}:${proxy_password} ${PROXY_OPTIONS}"
fi

if [ -z ${skip_cert_verification} ]; then
CURL_OPTION="${CURL_OPTION}"
else
CURL_OPTION="-k ${CURL_OPTION}"
fi

if [ -z ${verbose} ]; then
CURL_OPTION="${CURL_OPTION}"
else
CURL_OPTION="-v ${CURL_OPTION}"
fi

if [ -z ${silent} ]; then
CURL_OPTION="${CURL_OPTION}"
else
CURL_OPTION="-s ${CURL_OPTION}"
fi

redacted_webhook_url=$(echo "${webhook_url}" | sed -e 's#/\([^/\.]\{2\}\)[^/.]\{5,\}\([^/.]\{2\}\)#/\1…\2#g' | jq -R .)

url_path="$(echo ${webhook_url} | sed -e "s/https\{0,1\}:\/\/[^\/]*\(\/[^?&#]*\).*/\1/")"
Expand Down

0 comments on commit 6295b41

Please sign in to comment.