Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream v0.1.12 alignment #9

Merged
merged 4 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.1.12](https://github.com/furan917/MageComm/compare/v0.1.11...v0.1.12) (2023-11-27)


### Bug Fixes

* Slack command output disable affected full message instead of command output only ([0f1773d](https://github.com/furan917/MageComm/commit/0f1773de706b88305230188fa24f11e7da54e355))

## [0.1.11](https://github.com/furan917/MageComm/compare/v0.1.10...v0.1.11) (2023-11-24)


Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ _All caps for envs, lowercase for config file_
- `MAGECOMM_RMQ_PASS` Default: ``
- `MAGECOMM_RMQ_TLS` Default: `false`
- `MAGECOMM_RMQ_VHOST` Default: `/`
- `MAGECOMM_SLACK_ENABLED` Default: `false`, (true|false), if true you must configure the WEBHOOK or APP configurations to work
- `MAGECOMM_SLACK_DISABLE_OUTPUT_NOTIFICATIONS` Default: 'false, (true|false), if true we will not send output notifications to slack
- `MAGECOMM_SLACK_ENABLED` Default: `false`, (true|false), if true you must configure the WEBHOOK or APP configurations to work. When true will send to slack a message when a command has executed with the command, the environment it was on and the commands output
- `MAGECOMM_SLACK_DISABLE_OUTPUT_NOTIFICATIONS` Default: `false`, (true|false), if true command outputs will not be sent to slack along with the execution message
- `MAGECOMM_SLACK_WEBHOOK_URL` Default: ``
- `MAGECOMM_SLACK_WEBHOOK_CHANNEL` Default: ``
- `MAGECOMM_SLACK_WEBHOOK_USERNAME` Default: ``
Expand Down
16 changes: 12 additions & 4 deletions messages/handler/magerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,22 @@ func (handler *MagerunHandler) ProcessMessage(messageBody string, correlationID
output = "Command finished with no output"
}

if config_manager.GetBoolValue(config_manager.ConfigSlackEnabled) && !config_manager.GetBoolValue(config_manager.ConfigSlackDisableOutputNotifications) {
if config_manager.GetBoolValue(config_manager.ConfigSlackEnabled) {
logger.Infof("Slack notification is enabled, sending output notification")
notifier := notifictions.DefaultSlackNotifier
commandOutputMessage := ""
outputMessage := fmt.Sprintf(
" Command: '%v' on environment: '%s' ran with output: \n %s",
"Executed Command: '%v' on Environment: '%s'",
strings.Join(strings.Fields(messageBody), " "),
config_manager.GetValue(config_manager.CommandConfigEnvironment),
output)
config_manager.GetValue(config_manager.CommandConfigEnvironment))

if !config_manager.GetBoolValue(config_manager.ConfigSlackDisableOutputNotifications) {
commandOutputMessage = fmt.Sprintf(
"Returned with output: \n %s",
output)
outputMessage = outputMessage + "\n" + commandOutputMessage
}

err := notifier.Notify(fmt.Sprintf(outputMessage))
if err != nil {
logger.Warnf("Failed to send slack output notification: %v\n", err)
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.1.11 ## x-release-please-version
v0.1.12 ## x-release-please-version