-
Notifications
You must be signed in to change notification settings - Fork 381
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
[dashboards] Add new Dashboard resource #249
Conversation
Merge upstream repo
Merge upstream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this is awesome work, thanks a lot for doing this. Couple comments:
- I've left several notes inline the code that should be addressed.
- We'll need documentation for this feature under the
website
directory; while writing it, you can usemake website
to spin up a local Docker container to see if everything is formatted/linked right.
Also thanks for writing the integration tests - they pass for me and I've also been able to play around with this without any issues at all, so great job 👍
Thanks @bkabrda for the review and comments. I've addressed them and would love to hear your thoughts about |
@enbashi as for the As for docs, I would like to have them in the same PR. |
Sync with upstream
@bkabrda I added the docs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work on the docs; I left couple comments inline that should be addressed before we can merge this.
website/datadog.erb
Outdated
@@ -34,15 +37,9 @@ | |||
<li<%= sidebar_current("docs-datadog-resource-monitor") %>> | |||
<a href="/docs/providers/datadog/r/monitor.html">datadog_monitor</a> | |||
</li> | |||
<li<%= sidebar_current("docs-datadog-resource-screenboard") %>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not remove the links to screenboard and timeboard resources just yet. Marking them outdated is sufficient for now IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We wanted to follow the same approach we did for https://docs.datadoghq.com/api/#dashboards when we rolled out the new API to achieve two goals:
- Push users to use the new resource while still having access to the old resources
- Minimize confusion that might be caused by having three related resources accessible from the main page
That said, I don't have a strong opinion about that so if you still think we should keep the links I am happy add them back. let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be really confusing if the documentation just disappeared one day without the users understanding why. There's no good way in TF provider docs to go back to docs of older versions, so keeping the links there and putting the disclaimers there for screenboard and timeboard resources seems like the best solution to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these won't be deprecated
in the next immediate provider version, I also think we should keep the links. Once we start deprecation on the resources we should remove the links and log a notice. For now I think we should just leave a note at the top of each screenboard/timeboard page.
You can even use this to make it a big note !>
at the top of the timeboard/screenboard pages. https://github.com/hashicorp/terraform-website#callouts (Just tested locally and confirmed it works. There is a make website
command that will spin up a local copy of the site in docker)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I added the links back. Thank you both.
} | ||
} | ||
|
||
template_variable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation seems to be a bit off from this line on - let's continue using two spaces to indent as you did above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this. Fixed.
} | ||
|
||
# Create a new Datadog dashboard - Free layout | ||
resource "datadog_dashboard" "free_dashboard" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation in this example is a little weird as well, let's keep using two spaces for each level of indentation.
- `limit` - (Required) | ||
|
||
|
||
### Nested `widget``marker` blocks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a space here between widget
and marker
, would result in bad formatting.
|
||
Only for widgets of type "timeseries". | ||
|
||
Nested `widget``marker` blocks have the following structure: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again missing space between widget
and marker
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now, great work 👍 . Since this is a big one, I'd also like one other approval. @nmuesch could you add your approval as well if you're ok with everything?
Hey. Glad to see this and that its being looked forward to! Apologies for my delay here. I'll be taking a look at this shortly and leaving a review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for this! 💜 Tests/Docs especially. I left a few small comments, but the primary ones I think should get addressed before we merge are:
- The clarification about two build functions per nested schema
- Can you try to reproduce the issue with the non empty plan when updating the example provided in the docs?
} | ||
} | ||
|
||
# Create a new Datadog dashboard - Free layout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would look cleaner as a separate code block with this comment maybe being an anchor title?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. This looks much better. Thanks for the suggestion. Updated.
"strings" | ||
|
||
"github.com/hashicorp/terraform/helper/schema" | ||
"github.com/zorkian/go-datadog-api" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be aliased to datadog
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
"layout_type": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
Description: "The layout type of the dashboard, either 'free' or 'ordered'.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about having a ValidateFunc here to ensure a user provided one of the two expected values - https://www.terraform.io/docs/extend/schemas/schema-behaviors.html#validatefunc
I don't anticipate these options changing soon :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was relying on the upstream API to handle validation in some cases to simplify the resource code, but this could be a nice candidate for ValidateFunc
. Updated.
terraformRequest["apm_query"] = []map[string]interface{}{terraformQuery} | ||
} else if datadogRequest.LogQuery != nil { | ||
terraformQuery := buildTerraformApmOrLogQuery(*datadogRequest.LogQuery) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like something is up here. Running terraform apply
on the documented dashboard example multiple times gives me a non empty diff.
For example:
widget.10.scatterplot_definition.0.xaxis.include_zero: "true" => "1"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That one was super tricky. It seems that all params in TypeMap
are stored in the local state as strings regardless of the provided param type. I had to change the type of the surrounding blocks xaxis
and yaxis
to TypeList
to workaround around that. The docs and tests were updated accordingly. Thanks for catching this.
} | ||
func validateGroupWidgetLayoutType(val interface{}, key string) (warns []string, errs []error) { | ||
value := val.(string) | ||
switch value { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a switch
despite this being one value only because we plan to support more layout types in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks good to me. Thanks for tackling this and the reviews 🙇
One final thing I notice but don't think should block a merge. There is a (likely expected) behavior that when a group of widgets is moved via the UI, the next terraform apply will show a very large diff. Though I don't see a way around this.
@nmuesch yeah, I don't think we can't help that, but nice catch :) All right, everything seems to be in line here. I'm merging! |
Adds a new
datadog_dashboard
resource that uses the new Dashboard API https://docs.datadoghq.com/api/#dashboards