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

toEmail annotation array and quotation handling #52

Open
Gillingham opened this issue May 27, 2020 · 2 comments
Open

toEmail annotation array and quotation handling #52

Gillingham opened this issue May 27, 2020 · 2 comments

Comments

@Gillingham
Copy link

I'm using ansible and the sensu-go-ansible playbooks to configure checks. As a result if I pass an array to the toEmail annotation it ends up being configured as ['foo@email.com', 'bar@email.com'] which sensu-email-handler accepts, and then doesnt actually send email.

A quick test of variations of quoting below:

No quotes in the array

curl -X POST -H 'Content-Type: application/json' -d '{
  "check": {
    "metadata": {
      "name": "test-event",
      "annotations": {
        "sensu.io/plugins/email/config/toEmail": "[foo@bar.com]"
      }
    },
    "status": 2,
    "output": "no quote test",
    "handlers": [ "email" ]
  }
}' http://127.0.0.1:3031/events

Results: no email

Single quote in the array

curl -X POST -H 'Content-Type: application/json' -d '{
  "check": {
    "metadata": {
      "name": "test-event",
      "annotations": {
        "sensu.io/plugins/email/config/toEmail": "['foo@bar.com']"
      }
    },
    "status": 2,
    "output": "single quote test",
    "handlers": [ "email" ]
  }
}' http://127.0.0.1:3031/events

Results: no email

Escaped double quotes

curl -X POST -H 'Content-Type: application/json' -d '{
  "check": {
    "metadata": {
      "name": "test-event",
      "annotations": {
        "sensu.io/plugins/email/config/toEmail": "[\"foo@bar.com\"]"
      }
    },
    "status": 2,
    "output": "escaped double quotes test",
    "handlers": [ "email" ]
  }
}' http://127.0.0.1:3031/events

Results: email actually sent

Any advice here? I'm not entirely sure if this is a bug here, or something to be taken up with sensu-go-ansible

@nixwiz
Copy link
Contributor

nixwiz commented May 27, 2020

The annotation is meant to directly override the command line argument toEmail which accepts a comma separated list of addresses.

@Gillingham
Copy link
Author

That doesnt seem to be a direct passing the CLI in the case of array handling though since it will unpack an escaped double quoted array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants