Bump github.com/hashicorp/terraform-plugin-sdk/v2 from 2.20.0 to 2.24.1

Bumps [github.com/hashicorp/terraform-plugin-sdk/v2](https://github.com/hashicorp/terraform-plugin-sdk) from 2.20.0 to 2.24.1.
- [Release notes](https://github.com/hashicorp/terraform-plugin-sdk/releases)
- [Changelog](https://github.com/hashicorp/terraform-plugin-sdk/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/terraform-plugin-sdk/compare/v2.20.0...v2.24.1)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/terraform-plugin-sdk/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2022-12-24 16:57:19 +00:00
committed by Tobias Trabelsi
parent 683a051502
commit 282cd097f9
195 changed files with 3914 additions and 3093 deletions

View File

@ -6,6 +6,7 @@ import (
)
var NotFunc = function.New(&function.Spec{
Description: `Applies the logical NOT operation to the given boolean value.`,
Params: []function.Parameter{
{
Name: "val",
@ -21,6 +22,7 @@ var NotFunc = function.New(&function.Spec{
})
var AndFunc = function.New(&function.Spec{
Description: `Applies the logical AND operation to the given boolean values.`,
Params: []function.Parameter{
{
Name: "a",
@ -42,6 +44,7 @@ var AndFunc = function.New(&function.Spec{
})
var OrFunc = function.New(&function.Spec{
Description: `Applies the logical OR operation to the given boolean values.`,
Params: []function.Parameter{
{
Name: "a",

View File

@ -30,6 +30,7 @@ func BytesVal(buf []byte) cty.Value {
// BytesLen is a Function that returns the length of the buffer encapsulated
// in a Bytes value.
var BytesLenFunc = function.New(&function.Spec{
Description: `Returns the total number of bytes in the given buffer.`,
Params: []function.Parameter{
{
Name: "buf",
@ -46,6 +47,7 @@ var BytesLenFunc = function.New(&function.Spec{
// BytesSlice is a Function that returns a slice of the given Bytes value.
var BytesSliceFunc = function.New(&function.Spec{
Description: `Extracts a subslice from the given buffer.`,
Params: []function.Parameter{
{
Name: "buf",

View File

@ -12,6 +12,7 @@ import (
)
var HasIndexFunc = function.New(&function.Spec{
Description: `Returns true if if the given collection can be indexed with the given key without producing an error, or false otherwise.`,
Params: []function.Parameter{
{
Name: "collection",
@ -37,6 +38,7 @@ var HasIndexFunc = function.New(&function.Spec{
})
var IndexFunc = function.New(&function.Spec{
Description: `Returns the element with the given key from the given collection, or raises an error if there is no such element.`,
Params: []function.Parameter{
{
Name: "collection",
@ -106,6 +108,7 @@ var IndexFunc = function.New(&function.Spec{
})
var LengthFunc = function.New(&function.Spec{
Description: `Returns the number of elements in the given collection.`,
Params: []function.Parameter{
{
Name: "collection",
@ -127,6 +130,7 @@ var LengthFunc = function.New(&function.Spec{
})
var ElementFunc = function.New(&function.Spec{
Description: `Returns the element with the given index from the given list or tuple, applying the modulo operation to the given index if it's greater than the number of elements.`,
Params: []function.Parameter{
{
Name: "list",
@ -206,9 +210,11 @@ var ElementFunc = function.New(&function.Spec{
// CoalesceListFunc is a function that takes any number of list arguments
// and returns the first one that isn't empty.
var CoalesceListFunc = function.New(&function.Spec{
Params: []function.Parameter{},
Description: `Returns the first of the given sequences that has a length greater than zero.`,
Params: []function.Parameter{},
VarParam: &function.Parameter{
Name: "vals",
Description: `List or tuple values to test in the given order.`,
Type: cty.DynamicPseudoType,
AllowUnknown: true,
AllowDynamicType: true,
@ -270,6 +276,7 @@ var CoalesceListFunc = function.New(&function.Spec{
// CompactFunc is a function that takes a list of strings and returns a new list
// with any empty string elements removed.
var CompactFunc = function.New(&function.Spec{
Description: `Removes all empty string elements from the given list of strings.`,
Params: []function.Parameter{
{
Name: "list",
@ -306,6 +313,7 @@ var CompactFunc = function.New(&function.Spec{
// ContainsFunc is a function that determines whether a given list or
// set contains a given single value as one of its elements.
var ContainsFunc = function.New(&function.Spec{
Description: `Returns true if the given value is a value in the given list, tuple, or set, or false otherwise.`,
Params: []function.Parameter{
{
Name: "list",
@ -364,6 +372,7 @@ var ContainsFunc = function.New(&function.Spec{
// DistinctFunc is a function that takes a list and returns a new list
// with any duplicate elements removed.
var DistinctFunc = function.New(&function.Spec{
Description: `Removes any duplicate values from the given list, preserving the order of remaining elements.`,
Params: []function.Parameter{
{
Name: "list",
@ -399,14 +408,17 @@ var DistinctFunc = function.New(&function.Spec{
// ChunklistFunc is a function that splits a single list into fixed-size chunks,
// returning a list of lists.
var ChunklistFunc = function.New(&function.Spec{
Description: `Splits a single list into multiple lists where each has at most the given number of elements.`,
Params: []function.Parameter{
{
Name: "list",
Description: `The list to split into chunks.`,
Type: cty.List(cty.DynamicPseudoType),
AllowMarked: true,
},
{
Name: "size",
Description: `The maximum length of each chunk. All but the last element of the result is guaranteed to be of exactly this size.`,
Type: cty.Number,
AllowMarked: true,
},
@ -471,6 +483,7 @@ var ChunklistFunc = function.New(&function.Spec{
// FlattenFunc is a function that takes a list and replaces any elements
// that are lists with a flattened sequence of the list contents.
var FlattenFunc = function.New(&function.Spec{
Description: `Transforms a list, set, or tuple value into a tuple by replacing any given elements that are themselves sequences with a flattened tuple of all of the nested elements concatenated together.`,
Params: []function.Parameter{
{
Name: "list",
@ -525,6 +538,7 @@ func flattener(flattenList cty.Value) ([]cty.Value, []cty.ValueMarks, bool) {
if len(flattenListMarks) > 0 {
markses = append(markses, flattenListMarks)
}
if !flattenList.Length().IsKnown() {
// If we don't know the length of what we're flattening then we can't
// predict the length of our result yet either.
@ -542,7 +556,7 @@ func flattener(flattenList cty.Value) ([]cty.Value, []cty.ValueMarks, bool) {
isKnown = false
}
if val.Type().IsListType() || val.Type().IsSetType() || val.Type().IsTupleType() {
if !val.IsNull() && (val.Type().IsListType() || val.Type().IsSetType() || val.Type().IsTupleType()) {
if !val.IsKnown() {
isKnown = false
_, unknownMarks := val.Unmark()
@ -566,9 +580,11 @@ func flattener(flattenList cty.Value) ([]cty.Value, []cty.ValueMarks, bool) {
// KeysFunc is a function that takes a map and returns a sorted list of the map keys.
var KeysFunc = function.New(&function.Spec{
Description: `Returns a list of the keys of the given map in lexicographical order.`,
Params: []function.Parameter{
{
Name: "inputMap",
Description: `The map to extract keys from. May instead be an object-typed value, in which case the result is a tuple of the object attributes.`,
Type: cty.DynamicPseudoType,
AllowUnknown: true,
AllowMarked: true,
@ -641,6 +657,7 @@ var KeysFunc = function.New(&function.Spec{
// LookupFunc is a function that performs dynamic lookups of map types.
var LookupFunc = function.New(&function.Spec{
Description: `Returns the value of the element with the given key from the given map, or returns the default value if there is no such element.`,
Params: []function.Parameter{
{
Name: "inputMap",
@ -733,7 +750,8 @@ var LookupFunc = function.New(&function.Spec{
// If more than one given map or object defines the same key then the one that
// is later in the argument sequence takes precedence.
var MergeFunc = function.New(&function.Spec{
Params: []function.Parameter{},
Description: `Merges all of the elements from the given maps into a single map, or the attributes from given objects into a single object.`,
Params: []function.Parameter{},
VarParam: &function.Parameter{
Name: "maps",
Type: cty.DynamicPseudoType,
@ -849,6 +867,7 @@ var MergeFunc = function.New(&function.Spec{
// ReverseListFunc takes a sequence and produces a new sequence of the same length
// with all of the same elements as the given sequence but in reverse order.
var ReverseListFunc = function.New(&function.Spec{
Description: `Returns the given list with its elements in reverse order.`,
Params: []function.Parameter{
{
Name: "list",
@ -897,9 +916,11 @@ var ReverseListFunc = function.New(&function.Spec{
// preserving the ordering of all of the input lists. Otherwise the result is a
// set of tuples.
var SetProductFunc = function.New(&function.Spec{
Params: []function.Parameter{},
Description: `Calculates the cartesian product of two or more sets.`,
Params: []function.Parameter{},
VarParam: &function.Parameter{
Name: "sets",
Description: "The sets to consider. Also accepts lists and tuples, and if all arguments are of list or tuple type then the result will preserve the input ordering",
Type: cty.DynamicPseudoType,
AllowMarked: true,
},
@ -1037,6 +1058,7 @@ var SetProductFunc = function.New(&function.Spec{
// SliceFunc is a function that extracts some consecutive elements
// from within a list.
var SliceFunc = function.New(&function.Spec{
Description: `Extracts a subslice of the given list or tuple value.`,
Params: []function.Parameter{
{
Name: "list",
@ -1158,9 +1180,10 @@ func sliceIndexes(args []cty.Value) (int, int, bool, error) {
// ValuesFunc is a function that returns a list of the map values,
// in the order of the sorted keys.
var ValuesFunc = function.New(&function.Spec{
Description: `Returns the values of elements of a given map, or the values of attributes of a given object, in lexicographic order by key or attribute name.`,
Params: []function.Parameter{
{
Name: "values",
Name: "mapping",
Type: cty.DynamicPseudoType,
AllowMarked: true,
},
@ -1225,6 +1248,7 @@ var ValuesFunc = function.New(&function.Spec{
// ZipmapFunc is a function that constructs a map from a list of keys
// and a corresponding list of values.
var ZipmapFunc = function.New(&function.Spec{
Description: `Constructs a map from a list of keys and a corresponding list of values, which must both be of the same length.`,
Params: []function.Parameter{
{
Name: "keys",

View File

@ -1,6 +1,7 @@
package stdlib
import (
"fmt"
"strconv"
"github.com/zclconf/go-cty/cty"
@ -18,6 +19,7 @@ import (
// a tuple.
func MakeToFunc(wantTy cty.Type) function.Function {
return function.New(&function.Spec{
Description: fmt.Sprintf("Converts the given value to %s, or raises an error if that conversion is impossible.", wantTy.FriendlyName()),
Params: []function.Parameter{
{
Name: "v",

View File

@ -11,6 +11,7 @@ import (
)
var CSVDecodeFunc = function.New(&function.Spec{
Description: `Parses the given string as Comma Separated Values (as defined by RFC 4180) and returns a map of objects representing the table of data, using the first row as a header row to define the object attributes.`,
Params: []function.Parameter{
{
Name: "str",

View File

@ -12,6 +12,7 @@ import (
)
var FormatDateFunc = function.New(&function.Spec{
Description: `Formats a timestamp given in RFC 3339 syntax into another timestamp in some other machine-oriented time syntax, as described in the format string.`,
Params: []function.Parameter{
{
Name: "format",
@ -205,6 +206,7 @@ var FormatDateFunc = function.New(&function.Spec{
// TimeAddFunc is a function that adds a duration to a timestamp, returning a new timestamp.
var TimeAddFunc = function.New(&function.Spec{
Description: `Adds the duration represented by the given duration string to the given RFC 3339 timestamp string, returning another RFC 3339 timestamp.`,
Params: []function.Parameter{
{
Name: "timestamp",

View File

@ -18,6 +18,7 @@ import (
//go:generate gofmt -w format_fsm.go
var FormatFunc = function.New(&function.Spec{
Description: `Constructs a string by applying formatting verbs to a series of arguments, using a similar syntax to the C function \"printf\".`,
Params: []function.Parameter{
{
Name: "format",
@ -45,6 +46,7 @@ var FormatFunc = function.New(&function.Spec{
})
var FormatListFunc = function.New(&function.Spec{
Description: `Constructs a list of strings by applying formatting verbs to a series of arguments, using a similar syntax to the C function \"printf\".`,
Params: []function.Parameter{
{
Name: "format",

View File

@ -9,6 +9,7 @@ import (
)
var EqualFunc = function.New(&function.Spec{
Description: `Returns true if the two given values are equal, or false otherwise.`,
Params: []function.Parameter{
{
Name: "a",
@ -32,6 +33,7 @@ var EqualFunc = function.New(&function.Spec{
})
var NotEqualFunc = function.New(&function.Spec{
Description: `Returns false if the two given values are equal, or true otherwise.`,
Params: []function.Parameter{
{
Name: "a",
@ -55,7 +57,8 @@ var NotEqualFunc = function.New(&function.Spec{
})
var CoalesceFunc = function.New(&function.Spec{
Params: []function.Parameter{},
Description: `Returns the first of the given arguments that isn't null, or raises an error if there are no non-null arguments.`,
Params: []function.Parameter{},
VarParam: &function.Parameter{
Name: "vals",
Type: cty.DynamicPseudoType,

View File

@ -7,6 +7,7 @@ import (
)
var JSONEncodeFunc = function.New(&function.Spec{
Description: `Returns a string containing a JSON representation of the given value.`,
Params: []function.Parameter{
{
Name: "val",
@ -39,6 +40,7 @@ var JSONEncodeFunc = function.New(&function.Spec{
})
var JSONDecodeFunc = function.New(&function.Spec{
Description: `Parses the given string as JSON and returns a value corresponding to what the JSON document describes.`,
Params: []function.Parameter{
{
Name: "str",

View File

@ -11,6 +11,7 @@ import (
)
var AbsoluteFunc = function.New(&function.Spec{
Description: `If the given number is negative then returns its positive equivalent, or otherwise returns the given number unchanged.`,
Params: []function.Parameter{
{
Name: "num",
@ -26,6 +27,7 @@ var AbsoluteFunc = function.New(&function.Spec{
})
var AddFunc = function.New(&function.Spec{
Description: `Returns the sum of the two given numbers.`,
Params: []function.Parameter{
{
Name: "a",
@ -59,6 +61,7 @@ var AddFunc = function.New(&function.Spec{
})
var SubtractFunc = function.New(&function.Spec{
Description: `Returns the difference between the two given numbers.`,
Params: []function.Parameter{
{
Name: "a",
@ -92,6 +95,7 @@ var SubtractFunc = function.New(&function.Spec{
})
var MultiplyFunc = function.New(&function.Spec{
Description: `Returns the product of the two given numbers.`,
Params: []function.Parameter{
{
Name: "a",
@ -126,6 +130,7 @@ var MultiplyFunc = function.New(&function.Spec{
})
var DivideFunc = function.New(&function.Spec{
Description: `Divides the first given number by the second.`,
Params: []function.Parameter{
{
Name: "a",
@ -160,6 +165,7 @@ var DivideFunc = function.New(&function.Spec{
})
var ModuloFunc = function.New(&function.Spec{
Description: `Divides the first given number by the second and then returns the remainder.`,
Params: []function.Parameter{
{
Name: "a",
@ -194,6 +200,7 @@ var ModuloFunc = function.New(&function.Spec{
})
var GreaterThanFunc = function.New(&function.Spec{
Description: `Returns true if and only if the second number is greater than the first.`,
Params: []function.Parameter{
{
Name: "a",
@ -215,6 +222,7 @@ var GreaterThanFunc = function.New(&function.Spec{
})
var GreaterThanOrEqualToFunc = function.New(&function.Spec{
Description: `Returns true if and only if the second number is greater than or equal to the first.`,
Params: []function.Parameter{
{
Name: "a",
@ -236,6 +244,7 @@ var GreaterThanOrEqualToFunc = function.New(&function.Spec{
})
var LessThanFunc = function.New(&function.Spec{
Description: `Returns true if and only if the second number is less than the first.`,
Params: []function.Parameter{
{
Name: "a",
@ -257,6 +266,7 @@ var LessThanFunc = function.New(&function.Spec{
})
var LessThanOrEqualToFunc = function.New(&function.Spec{
Description: `Returns true if and only if the second number is less than or equal to the first.`,
Params: []function.Parameter{
{
Name: "a",
@ -278,6 +288,7 @@ var LessThanOrEqualToFunc = function.New(&function.Spec{
})
var NegateFunc = function.New(&function.Spec{
Description: `Multiplies the given number by -1.`,
Params: []function.Parameter{
{
Name: "num",
@ -293,7 +304,8 @@ var NegateFunc = function.New(&function.Spec{
})
var MinFunc = function.New(&function.Spec{
Params: []function.Parameter{},
Description: `Returns the numerically smallest of all of the given numbers.`,
Params: []function.Parameter{},
VarParam: &function.Parameter{
Name: "numbers",
Type: cty.Number,
@ -317,7 +329,8 @@ var MinFunc = function.New(&function.Spec{
})
var MaxFunc = function.New(&function.Spec{
Params: []function.Parameter{},
Description: `Returns the numerically greatest of all of the given numbers.`,
Params: []function.Parameter{},
VarParam: &function.Parameter{
Name: "numbers",
Type: cty.Number,
@ -341,6 +354,7 @@ var MaxFunc = function.New(&function.Spec{
})
var IntFunc = function.New(&function.Spec{
Description: `Discards any fractional portion of the given number.`,
Params: []function.Parameter{
{
Name: "num",
@ -363,6 +377,7 @@ var IntFunc = function.New(&function.Spec{
// CeilFunc is a function that returns the closest whole number greater
// than or equal to the given value.
var CeilFunc = function.New(&function.Spec{
Description: `Returns the smallest whole number that is greater than or equal to the given value.`,
Params: []function.Parameter{
{
Name: "num",
@ -392,6 +407,7 @@ var CeilFunc = function.New(&function.Spec{
// FloorFunc is a function that returns the closest whole number lesser
// than or equal to the given value.
var FloorFunc = function.New(&function.Spec{
Description: `Returns the greatest whole number that is less than or equal to the given value.`,
Params: []function.Parameter{
{
Name: "num",
@ -420,6 +436,7 @@ var FloorFunc = function.New(&function.Spec{
// LogFunc is a function that returns the logarithm of a given number in a given base.
var LogFunc = function.New(&function.Spec{
Description: `Returns the logarithm of the given number in the given base.`,
Params: []function.Parameter{
{
Name: "num",
@ -448,6 +465,7 @@ var LogFunc = function.New(&function.Spec{
// PowFunc is a function that returns the logarithm of a given number in a given base.
var PowFunc = function.New(&function.Spec{
Description: `Returns the given number raised to the given power (exponentiation).`,
Params: []function.Parameter{
{
Name: "num",
@ -477,6 +495,7 @@ var PowFunc = function.New(&function.Spec{
// SignumFunc is a function that determines the sign of a number, returning a
// number between -1 and 1 to represent the sign..
var SignumFunc = function.New(&function.Spec{
Description: `Returns 0 if the given number is zero, 1 if the given number is positive, or -1 if the given number is negative.`,
Params: []function.Parameter{
{
Name: "num",
@ -502,6 +521,7 @@ var SignumFunc = function.New(&function.Spec{
// ParseIntFunc is a function that parses a string argument and returns an integer of the specified base.
var ParseIntFunc = function.New(&function.Spec{
Description: `Parses the given string as a number of the given base, or raises an error if the string contains invalid characters.`,
Params: []function.Parameter{
{
Name: "number",

View File

@ -10,6 +10,7 @@ import (
)
var RegexFunc = function.New(&function.Spec{
Description: `Applies the given regular expression pattern to the given string and returns information about a single match, or raises an error if there is no match.`,
Params: []function.Parameter{
{
Name: "pattern",
@ -54,6 +55,7 @@ var RegexFunc = function.New(&function.Spec{
})
var RegexAllFunc = function.New(&function.Spec{
Description: `Applies the given regular expression pattern to the given string and returns a list of information about all non-overlapping matches, or an empty list if there are no matches.`,
Params: []function.Parameter{
{
Name: "pattern",

View File

@ -9,7 +9,8 @@ import (
)
var ConcatFunc = function.New(&function.Spec{
Params: []function.Parameter{},
Description: `Concatenates together all of the given lists or tuples into a single sequence, preserving the input order.`,
Params: []function.Parameter{},
VarParam: &function.Parameter{
Name: "seqs",
Type: cty.DynamicPseudoType,
@ -137,6 +138,7 @@ var ConcatFunc = function.New(&function.Spec{
})
var RangeFunc = function.New(&function.Spec{
Description: `Returns a list of numbers spread evenly over a particular range.`,
VarParam: &function.Parameter{
Name: "params",
Type: cty.Number,

View File

@ -10,6 +10,7 @@ import (
)
var SetHasElementFunc = function.New(&function.Spec{
Description: `Returns true if the given set contains the given element, or false otherwise.`,
Params: []function.Parameter{
{
Name: "set",
@ -29,6 +30,7 @@ var SetHasElementFunc = function.New(&function.Spec{
})
var SetUnionFunc = function.New(&function.Spec{
Description: `Returns the union of all given sets.`,
Params: []function.Parameter{
{
Name: "first_set",
@ -48,6 +50,7 @@ var SetUnionFunc = function.New(&function.Spec{
})
var SetIntersectionFunc = function.New(&function.Spec{
Description: `Returns the intersection of all given sets.`,
Params: []function.Parameter{
{
Name: "first_set",
@ -67,6 +70,7 @@ var SetIntersectionFunc = function.New(&function.Spec{
})
var SetSubtractFunc = function.New(&function.Spec{
Description: `Returns the relative complement of the two given sets.`,
Params: []function.Parameter{
{
Name: "a",
@ -86,6 +90,7 @@ var SetSubtractFunc = function.New(&function.Spec{
})
var SetSymmetricDifferenceFunc = function.New(&function.Spec{
Description: `Returns the symmetric difference of the two given sets.`,
Params: []function.Parameter{
{
Name: "first_set",

View File

@ -14,6 +14,7 @@ import (
)
var UpperFunc = function.New(&function.Spec{
Description: "Returns the given string with all Unicode letters translated to their uppercase equivalents.",
Params: []function.Parameter{
{
Name: "str",
@ -30,6 +31,7 @@ var UpperFunc = function.New(&function.Spec{
})
var LowerFunc = function.New(&function.Spec{
Description: "Returns the given string with all Unicode letters translated to their lowercase equivalents.",
Params: []function.Parameter{
{
Name: "str",
@ -46,6 +48,7 @@ var LowerFunc = function.New(&function.Spec{
})
var ReverseFunc = function.New(&function.Spec{
Description: "Returns the given string with all of its Unicode characters in reverse order.",
Params: []function.Parameter{
{
Name: "str",
@ -73,6 +76,7 @@ var ReverseFunc = function.New(&function.Spec{
})
var StrlenFunc = function.New(&function.Spec{
Description: "Returns the number of Unicode characters (technically: grapheme clusters) in the given string.",
Params: []function.Parameter{
{
Name: "str",
@ -97,19 +101,23 @@ var StrlenFunc = function.New(&function.Spec{
})
var SubstrFunc = function.New(&function.Spec{
Description: "Extracts a substring from the given string.",
Params: []function.Parameter{
{
Name: "str",
Description: "The input string.",
Type: cty.String,
AllowDynamicType: true,
},
{
Name: "offset",
Description: "The starting offset in Unicode characters.",
Type: cty.Number,
AllowDynamicType: true,
},
{
Name: "length",
Description: "The maximum length of the result in Unicode characters.",
Type: cty.Number,
AllowDynamicType: true,
},
@ -197,15 +205,18 @@ var SubstrFunc = function.New(&function.Spec{
})
var JoinFunc = function.New(&function.Spec{
Description: "Concatenates together the elements of all given lists with a delimiter, producing a single string.",
Params: []function.Parameter{
{
Name: "separator",
Type: cty.String,
Name: "separator",
Description: "Delimiter to insert between the given strings.",
Type: cty.String,
},
},
VarParam: &function.Parameter{
Name: "lists",
Type: cty.List(cty.String),
Name: "lists",
Description: "One or more lists of strings to join.",
Type: cty.List(cty.String),
},
Type: function.StaticReturnType(cty.String),
Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) {
@ -244,6 +255,7 @@ var JoinFunc = function.New(&function.Spec{
})
var SortFunc = function.New(&function.Spec{
Description: "Applies a lexicographic sort to the elements of the given list.",
Params: []function.Parameter{
{
Name: "list",
@ -282,14 +294,17 @@ var SortFunc = function.New(&function.Spec{
})
var SplitFunc = function.New(&function.Spec{
Description: "Produces a list of one or more strings by splitting the given string at all instances of a given separator substring.",
Params: []function.Parameter{
{
Name: "separator",
Type: cty.String,
Name: "separator",
Description: "The substring that delimits the result strings.",
Type: cty.String,
},
{
Name: "str",
Type: cty.String,
Name: "str",
Description: "The string to split.",
Type: cty.String,
},
},
Type: function.StaticReturnType(cty.List(cty.String)),
@ -311,6 +326,7 @@ var SplitFunc = function.New(&function.Spec{
// ChompFunc is a function that removes newline characters at the end of a
// string.
var ChompFunc = function.New(&function.Spec{
Description: "Removes one or more newline characters from the end of the given string.",
Params: []function.Parameter{
{
Name: "str",
@ -327,14 +343,17 @@ var ChompFunc = function.New(&function.Spec{
// IndentFunc is a function that adds a given number of spaces to the
// beginnings of all but the first line in a given multi-line string.
var IndentFunc = function.New(&function.Spec{
Description: "Adds a given number of spaces after each newline character in the given string.",
Params: []function.Parameter{
{
Name: "spaces",
Type: cty.Number,
Name: "spaces",
Description: "Number of spaces to add after each newline character.",
Type: cty.Number,
},
{
Name: "str",
Type: cty.String,
Name: "str",
Description: "The string to transform.",
Type: cty.String,
},
},
Type: function.StaticReturnType(cty.String),
@ -352,6 +371,7 @@ var IndentFunc = function.New(&function.Spec{
// TitleFunc is a function that converts the first letter of each word in the
// given string to uppercase.
var TitleFunc = function.New(&function.Spec{
Description: "Replaces one letter after each non-letter and non-digit character with its uppercase equivalent.",
Params: []function.Parameter{
{
Name: "str",
@ -367,6 +387,7 @@ var TitleFunc = function.New(&function.Spec{
// TrimSpaceFunc is a function that removes any space characters from the start
// and end of the given string.
var TrimSpaceFunc = function.New(&function.Spec{
Description: "Removes any consecutive space characters (as defined by Unicode) from the start and end of the given string.",
Params: []function.Parameter{
{
Name: "str",
@ -382,20 +403,26 @@ var TrimSpaceFunc = function.New(&function.Spec{
// TrimFunc is a function that removes the specified characters from the start
// and end of the given string.
var TrimFunc = function.New(&function.Spec{
Description: "Removes consecutive sequences of characters in \"cutset\" from the start and end of the given string.",
Params: []function.Parameter{
{
Name: "str",
Type: cty.String,
Name: "str",
Description: "The string to trim.",
Type: cty.String,
},
{
Name: "cutset",
Type: cty.String,
Name: "cutset",
Description: "A string containing all of the characters to trim. Each character is taken separately, so the order of characters is insignificant.",
Type: cty.String,
},
},
Type: function.StaticReturnType(cty.String),
Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) {
str := args[0].AsString()
cutset := args[1].AsString()
// NOTE: This doesn't properly handle any character that is encoded
// with multiple sequential code units, such as letters with
// combining diacritics and emoji modifier sequences.
return cty.StringVal(strings.Trim(str, cutset)), nil
},
})
@ -403,14 +430,17 @@ var TrimFunc = function.New(&function.Spec{
// TrimPrefixFunc is a function that removes the specified characters from the
// start the given string.
var TrimPrefixFunc = function.New(&function.Spec{
Description: "Removes the given prefix from the start of the given string, if present.",
Params: []function.Parameter{
{
Name: "str",
Type: cty.String,
Name: "str",
Description: "The string to trim.",
Type: cty.String,
},
{
Name: "prefix",
Type: cty.String,
Name: "prefix",
Description: "The prefix to remove, if present.",
Type: cty.String,
},
},
Type: function.StaticReturnType(cty.String),
@ -424,14 +454,17 @@ var TrimPrefixFunc = function.New(&function.Spec{
// TrimSuffixFunc is a function that removes the specified characters from the
// end of the given string.
var TrimSuffixFunc = function.New(&function.Spec{
Description: "Removes the given suffix from the start of the given string, if present.",
Params: []function.Parameter{
{
Name: "str",
Type: cty.String,
Name: "str",
Description: "The string to trim.",
Type: cty.String,
},
{
Name: "suffix",
Type: cty.String,
Name: "suffix",
Description: "The suffix to remove, if present.",
Type: cty.String,
},
},
Type: function.StaticReturnType(cty.String),

View File

@ -12,18 +12,22 @@ import (
// substring, and replaces each occurence with a given replacement string.
// The substr argument is a simple string.
var ReplaceFunc = function.New(&function.Spec{
Description: `Replaces all instances of the given substring in the given string with the given replacement string.`,
Params: []function.Parameter{
{
Name: "str",
Type: cty.String,
Name: "str",
Description: `The string to search within.`,
Type: cty.String,
},
{
Name: "substr",
Type: cty.String,
Name: "substr",
Description: `The substring to search for.`,
Type: cty.String,
},
{
Name: "replace",
Type: cty.String,
Name: "replace",
Description: `The new substring to replace substr with.`,
Type: cty.String,
},
},
Type: function.StaticReturnType(cty.String),
@ -40,13 +44,14 @@ var ReplaceFunc = function.New(&function.Spec{
// given substring, and replaces each occurence with a given replacement
// string. The substr argument must be a valid regular expression.
var RegexReplaceFunc = function.New(&function.Spec{
Description: `Applies the given regular expression pattern to the given string and replaces all matches with the given replacement string.`,
Params: []function.Parameter{
{
Name: "str",
Type: cty.String,
},
{
Name: "substr",
Name: "pattern",
Type: cty.String,
},
{