Skip to content

Add URL support to data_view field_formats #812

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

Merged
merged 5 commits into from
Oct 1, 2024
Merged

Conversation

kjwardy
Copy link
Contributor

@kjwardy kjwardy commented Sep 30, 2024

This PR adds support for the urlTemplate and labelTemplate attributes when specifying a field in a Data View as type URL, as well as adding functionality to account for when any available field_formats.params.attributes don't exist.

By specifying that all fields in apiFieldFormatParams are optional, other custom field format types (colour, key/value, etc.) can be added much easier.

- Adds support for `urlTemplate` and `labelTemplate` to data_views.field_formats
- Amends API request build process to account for when some/any data_views.field_formats.attributes aren't passed in
Copy link

cla-checker-service bot commented Sep 30, 2024

💚 CLA has been signed

@kjwardy kjwardy changed the title Add URL support to data_view field_formats (#1) Add URL support to data_view field_formats Sep 30, 2024
@@ -334,8 +340,15 @@ func dataViewFromResponse(resp data_views.DataViewResponseObjectDataView) apiDat

if params, ok := formatMap["params"]; ok {
if paramsMap, ok := params.(map[string]interface{}); ok {
fieldFormatParams := apiFieldFormatParams{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're never setting apiFormat.Params = &fieldFormatParams here and so the params are always nil (this is causing the current test failures).

Comment on lines 682 to 684
Pattern string `tfsdk:"pattern" json:"pattern,omitempty"`
Urltemplate string `tfsdk:"urltemplate" json:"urlTemplate,omitempty"`
Labeltemplate string `tfsdk:"labeltemplate" json:"labelTemplate,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should potentially be *string since they're optional in the schema.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's exactly what I was missing! Thanks for the assist. Changes made and pushed.

Copy link
Member

@tobio tobio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for taking the time to add this in to the provider!

@tobio tobio merged commit 49e3c95 into elastic:main Oct 1, 2024
20 checks passed
tobio added a commit that referenced this pull request Oct 3, 2024
* origin/main:
  fix package policy secrets (#821)
  chore(deps): update codecov/codecov-action digest to b9fd7d1 (#815)
  Bump release memory
  Switch to golang 1.23.2 in release
  Bump release memory
  Prepare release v0.11.8 (#810)
  Add key_id as an explicit attribute (#789)
  standalone-output resource (#811)
  Add URL support to data_view field_formats (#812)
  migrate fleet integration_policy to framework, fix secret churn (#797)
  Allow mappings to be unknown to support mappings defined in index templates (#803)
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

Successfully merging this pull request may close these issues.

2 participants