-
Notifications
You must be signed in to change notification settings - Fork 122
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
Changes from 2 commits
99b17c4
b305512
c6e9527
3c69d7b
c747a22
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,7 +88,9 @@ Optional: | |
|
|
||
| Optional: | ||
|
|
||
| - `labeltemplate` (String) | ||
| - `pattern` (String) | ||
| - `urltemplate` (String) | ||
|
|
||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,6 +147,12 @@ func getSchema() schema.Schema { | |
| "pattern": schema.StringAttribute{ | ||
| Optional: true, | ||
| }, | ||
| "urltemplate": schema.StringAttribute{ | ||
| Optional: true, | ||
| }, | ||
| "labeltemplate": schema.StringAttribute{ | ||
| Optional: true, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
|
|
@@ -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{} | ||
| if pattern, ok := paramsMap["pattern"]; ok { | ||
| apiFormat.Params = &apiFieldFormatParams{Pattern: pattern.(string)} | ||
| fieldFormatParams.Pattern = pattern.(string) | ||
| } | ||
| if urltemplate, ok := paramsMap["urlTemplate"]; ok { | ||
| fieldFormatParams.Urltemplate = urltemplate.(string) | ||
| } | ||
| if labeltemplate, ok := paramsMap["labelTemplate"]; ok { | ||
| fieldFormatParams.Labeltemplate = labeltemplate.(string) | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -600,7 +613,9 @@ func tfFieldFormatsToAPI(ctx context.Context, fieldFormats types.Map) (map[strin | |
| } | ||
|
|
||
| apiParams = &apiFieldFormatParams{ | ||
| Pattern: tfParams.Pattern.ValueString(), | ||
| Pattern: tfParams.Pattern.ValueString(), | ||
| Urltemplate: tfParams.Urltemplate.ValueString(), | ||
| Labeltemplate: tfParams.Labeltemplate.ValueString(), | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -658,9 +673,13 @@ type apiFieldFormat struct { | |
| } | ||
|
|
||
| type tfFieldFormatParamsV0 struct { | ||
| Pattern types.String `tfsdk:"pattern"` | ||
| Pattern types.String `tfsdk:"pattern"` | ||
| Urltemplate types.String `tfsdk:"urltemplate"` | ||
| Labeltemplate types.String `tfsdk:"labeltemplate"` | ||
kjwardy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| type apiFieldFormatParams struct { | ||
| Pattern string `tfsdk:"pattern" json:"pattern"` | ||
| Pattern string `tfsdk:"pattern" json:"pattern,omitempty"` | ||
| Urltemplate string `tfsdk:"urltemplate" json:"urlTemplate,omitempty"` | ||
| Labeltemplate string `tfsdk:"labeltemplate" json:"labelTemplate,omitempty"` | ||
|
||
| } | ||
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.
You're never setting
apiFormat.Params = &fieldFormatParamshere and so the params are always nil (this is causing the current test failures).