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

[Feature Request] Apply TrimSpace on some potentially complicated Alert fields #11

Closed
stephenchu opened this issue Oct 13, 2017 · 6 comments

Comments

@stephenchu
Copy link

stephenchu commented Oct 13, 2017

Terraform's strings.TrimSpace will remove whitespace before and after a given string. I would like to propose to use it on the following Wavefront Alert fields that can get big and be implemented in heredocs:

condition
displayExpression
additionalInformation

Trimming the whitespace will make it consistent with the web values too. For example, with the following applied config:

resource "wavefront_alert" "foo" {
  condition = <<-EOS
    ts(stats.gauges.c4-2xl-spot-price) > 0.3
    EOS

  display_expression = <<-EOS
    ts(stats.gauges.c4-2xl-spot-price)
    EOS

... when I go to the web UI and just hit "Save" with non change, the condition and display_expression textboxes show no newline at the end of course, but a subsequent plan shows the following now:

  ~ wavefront_alert.foo
      condition:          "ts(stats.gauges.c4-2xl-spot-price) > 0.3" => "ts(stats.gauges.c4-2xl-spot-price) > 0.3\n"
      display_expression: "ts(stats.gauges.c4-2xl-spot-price)" => "ts(stats.gauges.c4-2xl-spot-price)\n"

      <web saved value> => HCL config heredoc value

... because the web saved value has no newline, but my heredoc has.

This request is motivated by a similar code change in the Datadog Provider, where their message field defines the rendering of an alert.

I haven't started creating other Wavefront objects in this plugin yet, but I am sure some other fields can also benefit from this feature request.

@stephenchu stephenchu changed the title Apply TrimSpace on some potentially complicated Alert fields [Feature Request] Apply TrimSpace on some potentially complicated Alert fields Oct 13, 2017
@stephenchu stephenchu reopened this Oct 14, 2017
@stephenchu
Copy link
Author

Sorry, mis-clicked and closed it. I was gonna say, if you welcome contributions I can also do it, although I am not a Golang programmer I am an experienced programmer. All I would need is maybe a CONTRIBUTION.md to list the steps to set up the development environment after forking.

@nathmclean
Copy link
Collaborator

@stephenchu, we're more than happy to have outside contributors, I've added a CONTRIBUTOR file in #13

@MikeMcMahon
Copy link
Contributor

#21

as we needed this as well

@nathmclean
Copy link
Collaborator

Closed by #21

@stephenchu
Copy link
Author

🙇 ty!

@ashwin1dd
Copy link
Contributor

#40
another fix related to this

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

4 participants