Terraform: Documentation Update

Created on 22 Nov 2019  ·  8Comments  ·  Source: hashicorp/terraform

Terraform Version

Terraform v0.12.15

Issue

The pseudo code in the documentation for the range function is incorrect. The written explanation and the examples given are correct and function as expected. The pseudo code states the number will be added to the sequence if it is less than or equal to the limit (when using a positive step count). This should be 'less than' instead of 'less than or equal'.

Imported Package

https://github.com/zclconf/go-cty/blob/master/cty/function/stdlib/sequence.go#L167-L176

Official Documentation

Explanation

The resulting list is created by starting with the given start value and repeatedly adding step to it until the result is equal to or beyond limit.

https://github.com/hashicorp/terraform/blame/master/website/docs/configuration/functions/range.html.md#L28-L29

Pseudo Code

let num = start
while num <= limit: (or, for negative step, num >= limit)
  append num to the sequence
  num = num + step
return the sequence

https://github.com/hashicorp/terraform/blame/master/website/docs/configuration/functions/range.html.md#L38-L42

Example

> range(1, 4)
[
  1,
  2,
  3,
]

https://github.com/hashicorp/terraform/blame/master/website/docs/configuration/functions/range.html.md#L67-L72

bug documentation

All 8 comments

An example that uses less than or equal showing that the result is different than what you get with the terraform range function.
https://play.golang.org/p/zAw6QI8v5TZ

@ZMI-RyanMann thanks for reporting this! The terraform documentation can be updated at https://github.com/hashicorp/terraform-website - are you interested in making a pull request to make these improvements yourself?

@ZMI-RyanMann thanks for reporting this! The terraform documentation can be updated at https://github.com/hashicorp/terraform-website - are you interested in making a pull request to make these improvements yourself?

I will work on getting a pull request in for this.

Thanks! Please feel free to reach out if you need any help.

I've added a pull request to update the documentation. Let me know if you need anything else.

https://github.com/hashicorp/terraform/pull/23823

@ZMI-RyanMann It seems the PR is merged👍

You can close the issue yourself if it’s covered by the merged PR.

Issue resolved.

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings