Skip to content

Instantly share code, notes, and snippets.

{
"extractors": [
{
"title": "Remote Address",
"extractor_type": "regex",
"converters": [],
"order": 0,
"cursor_strategy": "copy",
"source_field": "message",
"target_field": "remote_addr",
@wagnst
wagnst / .bashrc-terraformv
Last active May 5, 2020 12:14
Switch terraform version via bash
#Terraform version switch
function terraformv() {
if [ $# -eq 1 ]; then
if test -f "/opt/terraform/terraform-${1}"; then
sudo rm /opt/terraform/terraform
sudo ln -s "/opt/terraform/terraform-${1}" /opt/terraform/terraform
echo "switched to terraform-${1}"
else
echo "terraform-${1} does not exist, pls download from https://releases.hashicorp.com/terraform/ first and store in /opt/terraform."
return 1
@wagnst
wagnst / .bashrc-kctl
Last active May 5, 2020 12:23
kubectl completion
[ -f ~/.kubectl_aliases ] && source ~/.kubectl_aliases
function alias_completion() {
local namespace="alias_completion"
# parse function based completion definitions, where capture group 2 => function and 3 => trigger
local compl_regex='complete( +[^ ]+)* -F ([^ ]+) ("[^"]+"|[^ ]+)'
# parse alias definitions, where capture group 1 => trigger, 2 => command, 3 => command arguments
local alias_regex="alias ([^=]+)='(\"[^\"]+\"|[^ ]+)(( +[^ ]+)*)'"
# create array of function completion triggers, keeping multi-word triggers together
eval "local completions=($(complete -p | sed -Ene "/$compl_regex/s//'\3'/p"))"