Repository navigation
feat(lbiplists): onboard lbiplists - #1788
SerseusWasTaken wants to merge 2 commits into
Conversation
998b6e3 to
64477ee
Compare
| respLabels, _ := ipList.GetLabelsOk() | ||
| labels, err := utils.MapLabels(ctx, respLabels, model.Labels) | ||
| if err != nil { | ||
| return fmt.Errorf("mapping labels: %w", err) | ||
| } | ||
| model.Labels = labels |
There was a problem hiding this comment.
You can directly map the labels to the model. In the datasource the model will never have any labels set. It's just a simple mapping of api response to terraform state.
And you can use here directly the labels attribute ipList.Labels instead of using the GetOk function
There was a problem hiding this comment.
yeah true, though we have a handful of datasources that use that helper as well.
I changed it to labels, err := types.MapValue(types.StringType, map[string]attr.Value{})
There was a problem hiding this comment.
Actually no, i left it as it is. many other datasources use it as well and not using it just results in more boilerplate code - i dont see the benefit here
| > **NOTE**: [Write-only arguments](https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments) are supported in Terraform 1.11 and later. | ||
|
|
||
| - `file_content` (String, [Write-only](https://developer.hashicorp.com/terraform/language/resources/ephemeral#write-only-arguments)) Raw upload payload as a plain UTF-8 string. Newline-separated .txt list of IPv4 CIDR entries, or CSV with cidr,labels columns (any other columns are ignored). Write-only - never stored in state and never returned by the API. To rotate the content, update this value AND increment file_content_version. Changing this field alone will NOT trigger an update. | ||
| - `file_content_version` (Number) User-managed rotation counter for the file_content. Must be incremented every time file_content is changed. Terraform diffs this field to detect changes in the defined IP list - changing file_content alone will NOT trigger an update because it is write-only and never stored in state. |
There was a problem hiding this comment.
We could also do this a bit different. Instead of using the write-only attribute, we could save the file_content directly to the state. Then we can calculate the hash locally and compare it with the hash from the API, if they are not equal, we can set the file_content to an null string, to trigger an update. For this approach we would need to know, how the Service calculates the hash, to calculate it the same. But I think this provides a better user exerience.
We can discuss it also in a private chat.
Relates to STACKITTPR-864
f180c2c to
b2df37a
Compare
b2df37a to
b6e5bc1
Compare
| @@ -0,0 +1,35 @@ | |||
| --- | |||
There was a problem hiding this comment.
Don't forget to adjust the labeler config so future contributions for this integration get labelled automatically :)
Description
Onboards the new lbiplists service
Relates to STACKITTPR-864
Checklist
make fmtexamples/directory)make generate-docs(will be checked by CI)make test(will be checked by CI)make lint(will be checked by CI)