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

Vendor Data Source can't find Sentry #54

Closed
nicknovitski opened this issue Dec 22, 2017 · 2 comments · Fixed by #55
Closed

Vendor Data Source can't find Sentry #54

nicknovitski opened this issue Dec 22, 2017 · 2 comments · Fixed by #55
Labels

Comments

@nicknovitski
Copy link

nicknovitski commented Dec 22, 2017

The following configuration doesn't find the Vendor "Sentry," but instead "IPSentry," obliging me to instead put the Sentry vendor's id in a local.

data "pagerduty_vendor" "sentry" {
  name = "Sentry"
}

I haven't looked at the code, but I have looked at the PagerDuty API. Running curl -X GET --header 'Accept: application/vnd.pagerduty+json;version=2' --header 'Authorization: Token token=<your token>' 'https://api.pagerduty.com/vendors?query=Sentry' gives back both vendors, with IPSentry first.

{
  "vendors": [
    {
      "id": "PY3OLY6",
      "type": "vendor",
      "summary": "IPSentry",
      "self": "https://api.pagerduty.com/vendors/PY3OLY6",
      "html_url": null,
      "name": "IPSentry",
      "website_url": "http://ipsentry.com/",
      "long_name": "IPSentry",
      "logo_url": "",
      "thumbnail_url": "",
      "description": "IPSentry is a Windows based network monitoring software package used by thousands of information system specialists, system administrators, and IT solution providers around the world.",
      "integration_guide_url": "https://www.pagerduty.com/docs/guides/ipsentry-integration-guide/",
      "connectable": false,
      "generic_service_type": "api",
      "alert_creation_default": "create_alerts_and_incidents",
      "alert_creation_editable": true,
      "is_pd_cef": false
    },
    {
      "id": "PKG4M95",
      "type": "vendor",
      "summary": "Sentry",
      "self": "https://api.pagerduty.com/vendors/PKG4M95",
      "html_url": null,
      "name": "Sentry",
      "website_url": "https://getsentry.com/welcome/",
      "long_name": "Sentry",
      "logo_url": "https://s3.amazonaws.com/pdpartner/sentry_large.png",
      "thumbnail_url": "https://s3.amazonaws.com/pdpartner/sentry_thumb.png",
      "description": "Sentry provides real-time crash reporting for your web apps, mobile apps, and games.",
      "integration_guide_url": "https://www.pagerduty.com/docs/guides/sentry-integration-guide/",
      "connectable": false,
      "generic_service_type": "api",
      "alert_creation_default": "create_alerts_and_incidents",
      "alert_creation_editable": true,
      "is_pd_cef": false
    }
  ],
  "query": "Sentry",
  "limit": 25,
  "offset": 0,
  "total": null,
  "more": false
}

I think it'd be a good idea to find the object with the matching name field in the array, rather than just taking the first one. This would also require users to specify the full, exact name of the vendor in the data source's name, which is what I assumed was the case from the start; as it stands, I get the same results using "Sen".

@nicknovitski
Copy link
Author

Having looked at the code, I was wrong: it does look for an object with a matching name, it just does it in such a way that will always find the first item in the result list.

it seems like the fix would be as simple as changing this line to only match against the entire string.

@heimweh
Copy link
Collaborator

heimweh commented Jan 4, 2018

Hi @nicknovitski thanks for catching and reporting this!

I've published a fix here: #55 which I believe should resolve the issue you're experiencing.

@heimweh heimweh added the bug label Jan 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants