Skip to content

Commit

Permalink
preparing v1.4.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuchard committed Jul 14, 2024
1 parent aa369d1 commit 01654dd
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### 1.4.1 (Next)
### 1.4.1
- Add `sorted` parameter to `list_index` function.
- Add `end_index` parameter to `replace` function.
- Fix `end_index` auto-deduction in `replace` function.
Expand Down
12 changes: 12 additions & 0 deletions docs/data-sources/list_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ data "stdlib_list_index" "one" {
}
# => 1
# Return the element's index within a sorted list:
data "stdlib_list_index" "c" {
list_param = ["a", "b", "c", "d"]
elem_param = "c"
sorted = true
}
# => 2
# Return the element's first occurrence index within a list:
data "stdlib_list_index" "two" {
list_param = ["zero", "one", "two", "three", "two", "one", "zero"]
Expand All @@ -44,6 +52,10 @@ data "stdlib_list_index" "infinity" {
- `elem_param` (String) Element in the list to determine its index.
- `list_param` (List of String) Input list parameter for determining the element's index.

### Optional

- `sorted` (Boolean) Whether the list is sorted in ascending order or not (note: see `stdlib_sort_list`). If the list is sorted then the efficient binary search algorithm will be utilized, but the combination of sorting and searching may be less efficient overall in some situations.

### Read-Only

- `id` (String) Aliased to string input parameter(s) for efficiency and proper plan diff detection.
Expand Down
25 changes: 19 additions & 6 deletions docs/data-sources/replace.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,46 @@
page_title: "stdlib_replace Data Source - stdlib"
subcategory: ""
description: |-
Return the list where values are replaced at a specific element index. This function errors if the specified index plus the length of the replace_values list is out of range for the list (length of list_param + 1). Note also that the terminating index is determined by generic slice s[i:j] in Go, and so it may be helpful in Terraform to consider the terminating index as beginning at element 1, and that the length of the resulting list will therefore be one greater than the original.
Return the list where values are replaced at a specific element index. This function errors if the end_index, or the specified index plus the length of the replace_values list, is out of range for the original list (greater than or equal to the length of list_param).
---

# stdlib_replace (Data Source)

Return the list where values are replaced at a specific element index. This function errors if the specified index plus the length of the replace_values list is out of range for the list (length of list_param + 1). Note also that the terminating index is determined by generic slice s[i:j] in Go, and so it may be helpful in Terraform to consider the terminating index as beginning at element 1, and that the length of the resulting list will therefore be one greater than the original.
Return the list where values are replaced at a specific element index. This function errors if the end_index, or the specified index plus the length of the replace_values list, is out of range for the original list (greater than or equal to the length of list_param).

## Example Usage

```terraform
# Return the list with beginning value replaced.
data "stdlib_replace" "begin" {
list_param = ["foo", "two", "three"]
list_param = ["foo", "bar", "two", "three"]
replace_values = ["zero", "one"]
index = 0
}
# => ["zero", "one", "two", "three"]
# Return the list with middle values replaced.
data "stdlib_replace" "replace" {
list_param = ["zero", "foo", "bar", "four", "five"]
list_param = ["zero", "foo", "bar", "baz", "four", "five"]
replace_values = ["one", "two", "three"]
index = 1
}
# => ["zero", "one", "two", "three", "four", "five"]
# Return the list with middle values replaced and zeroed.
data "stdlib_replace" "zeroed" {
list_param = ["zero", "foo", "bar", "four", "five"]
replace_values = ["one"]
index = 1
end_index = 2
}
# => ["zero", "one", "four", "five"]
# Return the list with terminating values replaced.
data "stdlib_replace" "append" {
list_param = ["zero", "foo", "bar"]
list_param = ["zero", "foo", "bar", "baz"]
replace_values = ["one", "two", "three"]
index = length(["zero", "foo", "bar"]) - (length(["one", "two", "three"]) - 1)
index = length(["zero", "foo", "bar", "baz"]) - (length(["one", "two", "three"]))
}
# => ["zero", "one", "two", "three"]
```
Expand All @@ -47,6 +56,10 @@ data "stdlib_replace" "append" {
- `list_param` (List of String) Input list parameter for which the values will be replaced.
- `replace_values` (List of String) Input list of values which will replace values in the list_param.

### Optional

- `end_index` (Number) The index in the list at which to end replacing values. If the difference between this and the index is greater than or equal to the length of the list of the replace_values, then the additional elements in the original list will all be zeroed (i.e. removed; see example stdlib_replace.zeroed). This parameter input value is only necessary for that situation as otherwise its value will be automatically deduced by the provider function.

### Read-Only

- `id` (String) Aliased to string input parameter(s) for efficiency and proper plan diff detection.
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// provider documentation generation.
//go:generate tfplugindocs generate --provider-name stdlib

const version string = "1.4.0"
const version string = "1.4.1"

func main() {
// start provider server
Expand Down

0 comments on commit 01654dd

Please sign in to comment.