From 7f1191bf59d3b35d28c6516e7879e0230792bfbb Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 18 Feb 2023 18:22:46 +0100 Subject: [PATCH] Change broadcast cmd to just take an argument instead of STDIN Simpler --- README.md | 7 +++---- lib/mrsk/commands/auditor.rb | 4 +--- test/commands/auditor_test.rb | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 199e410f..2d87838f 100644 --- a/README.md +++ b/README.md @@ -348,7 +348,7 @@ If you need separate env variables for different destinations, you can set them ### Using audit broadcasts -If you'd like to broadcast audits of deploys, rollbacks, etc to a chatroom or elsewhere, you can configure the `audit_broadcast_cmd` setting with the path to a bin file that reads the audit line from STDIN, and then does whatever with it: +If you'd like to broadcast audits of deploys, rollbacks, etc to a chatroom or elsewhere, you can configure the `audit_broadcast_cmd` setting with the path to a bin file that will be passed the audit line as the first argument: ```yaml audit_broadcast_cmd: @@ -359,14 +359,13 @@ The broadcast command could look something like: ```bash #!/usr/bin/env bash -read -curl -q -d content="[My app] ${REPLY}" https://3.basecamp.com/XXXXX/integrations/XXXXX/buckets/XXXXX/chats/XXXXX/lines +curl -q -d content="[My App] ${1}" https://3.basecamp.com/XXXXX/integrations/XXXXX/buckets/XXXXX/chats/XXXXX/lines ``` That'll post a line like follows to a preconfigured chatbot in Basecamp: ``` -[My App] [2023-02-18 11:29:52] [dhh] Rolled back to version d264c4e92470ad1bd18590f04466787262f605de +[My App] [dhh] Rolled back to version d264c4e92470ad1bd18590f04466787262f605de ``` ### Using custom healthcheck path or port diff --git a/lib/mrsk/commands/auditor.rb b/lib/mrsk/commands/auditor.rb index 8967b0ed..08ed5d12 100644 --- a/lib/mrsk/commands/auditor.rb +++ b/lib/mrsk/commands/auditor.rb @@ -11,9 +11,7 @@ class Mrsk::Commands::Auditor < Mrsk::Commands::Base # Runs locally def broadcast(line) if broadcast_cmd = config.audit_broadcast_cmd - pipe \ - [ :echo, tagged_broadcast_line(line) ], - broadcast_cmd + [ broadcast_cmd, tagged_broadcast_line(line) ] end end diff --git a/test/commands/auditor_test.rb b/test/commands/auditor_test.rb index c5f085c7..cf41987e 100644 --- a/test/commands/auditor_test.rb +++ b/test/commands/auditor_test.rb @@ -16,7 +16,7 @@ class CommandsAuditorTest < ActiveSupport::TestCase test "broadcast" do assert_match \ - /echo '.* app removed container' \| bin\/audit_broadcast/, + /bin\/audit_broadcast '\[.*\] app removed container'/, new_command.broadcast("app removed container").join(" ") end