2acfe1aa0e0c6a9c316fbec508f43dcf9f292ce3

Author
Eduardo Dos Santos Vilke <eduardo.svilke@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(localstack): add plugin (#12595)

Diff

 1diff --git a/plugins/localstack/README.md b/plugins/localstack/README.md
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..2c71e9edf55a1b4f1cbc39a86713e563124291af
 4--- /dev/null
 5+++ b/plugins/localstack/README.md
 6@@ -0,0 +1,24 @@
 7+#  Localstack plugin  #
 8+
 9+CLI support for LOCALSTACK interaction
10+
11+##  Description  ##
12+To use it, add `localstack` to the plugins array in your zshrc file:
13+
14+```zsh
15+plugins=(... localstack)
16+```
17+
18+##  Usage  ##
19+
20+This plugin supplies one command, `lsk`, through which all its features are exposed.
21+
22+## Commands
23+
24+| Command       | Description                                                           |
25+| :------------ | :-------------------------------------------------------------------- |
26+| `lsk sqs-send <queue> <message.json>` | sends a given message in sqs to a given queue |
27+
28+## Examples
29+
30+![staging](sqs-send-result.png)
31diff --git a/plugins/localstack/localstack.plugin.zsh b/plugins/localstack/localstack.plugin.zsh
32new file mode 100644
33index 0000000000000000000000000000000000000000..080b14a54e1fbc296f646d110cfaa86065aa7897
34--- /dev/null
35+++ b/plugins/localstack/localstack.plugin.zsh
36@@ -0,0 +1,37 @@
37+# CLI support for LOCALSTACK interaction
38+#
39+# See README.md for details
40+lsk() {
41+  case $1 in
42+    sqs-send)
43+      shift
44+      sqs-send "$@"
45+      ;;
46+    *)
47+      echo "Command not found: $1"
48+      return 1
49+      ;;
50+  esac
51+}
52+
53+# Send SQS function
54+#
55+# This function sends a given message in sqs to a given queue, when used Localstack
56+#
57+# Use:
58+#   sqs-send <queue> <message>
59+#
60+# Parameters
61+#   <queue> A given queue
62+#   <message> A content of message em json archive
63+#
64+# Example
65+#   sqs-send user user.json
66+sqs-send(){
67+  if [ -z "$1" ]; then
68+	  echo "Use: sqs-send <queue> <payload>"
69+	  return 1
70+  fi
71+
72+  curl -X POST "http://localhost:4566/000000000000/$1" -d "Action=SendMessage" -d "MessageBody=$(cat $2)"
73+}
74diff --git a/plugins/localstack/sqs-send-result.png b/plugins/localstack/sqs-send-result.png
75new file mode 100644
76index 0000000000000000000000000000000000000000..69eb2a64096b0b3fc476234fce1c50e51ea56b5a
77Binary files /dev/null and b/plugins/localstack/sqs-send-result.png differ