Moved to google.golang.org/genproto/googleapis/api/annotations
Fixes #52
This commit is contained in:
1
vendor/github.com/Masterminds/sprig/docs/_config.yml
generated
vendored
Normal file
1
vendor/github.com/Masterminds/sprig/docs/_config.yml
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
theme: jekyll-theme-slate
|
25
vendor/github.com/Masterminds/sprig/docs/conversion.md
generated
vendored
Normal file
25
vendor/github.com/Masterminds/sprig/docs/conversion.md
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# Type Conversion Functions
|
||||
|
||||
The following type conversion functions are provided by Sprig:
|
||||
|
||||
- `atoi`: Convert a string to an integer
|
||||
- `float64`: Convert to a float64
|
||||
- `int`: Convert to an `int` at the system's width.
|
||||
- `int64`: Convert to an `int64`
|
||||
- `toString`: Convert to a string
|
||||
- `toStrings`: Convert a list, slice, or array to a list of strings.
|
||||
|
||||
Only `atoi` requires that the input be a specific type. The others will attempt
|
||||
to convert from any type to the destination type. For example, `int64` can convert
|
||||
floats to ints, and it can also convert strings to ints.
|
||||
|
||||
## toStrings
|
||||
|
||||
Given a list-like collection, produce a slice of strings.
|
||||
|
||||
```
|
||||
list 1 2 3 | toStrings
|
||||
```
|
||||
|
||||
The above converts `1` to `"1"`, `2` to `"2"`, and so on, and then returns
|
||||
them as a list.
|
37
vendor/github.com/Masterminds/sprig/docs/crypto.md
generated
vendored
Normal file
37
vendor/github.com/Masterminds/sprig/docs/crypto.md
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
# Cryptographic and Security Functions
|
||||
|
||||
Sprig provides a couple of advanced cryptographic functions.
|
||||
|
||||
## sha256sum
|
||||
|
||||
The `sha256sum` function receives a string, and computes it's SHA256 digest.
|
||||
|
||||
```
|
||||
sha256sum "Hello world!"
|
||||
```
|
||||
|
||||
The above will compute the SHA 256 sum in an "ASCII armored" format that is
|
||||
safe to print.
|
||||
|
||||
## derivePassword
|
||||
|
||||
The `derivePassword` function can be used to derive a specific password based on
|
||||
some shared "master password" constraints. The algorithm for this is
|
||||
[well specified](http://masterpasswordapp.com/algorithm.html).
|
||||
|
||||
```
|
||||
derivePassword 1 "long" "password" "user" "example.com"
|
||||
```
|
||||
|
||||
Note that it is considered insecure to store the parts directly in the template.
|
||||
|
||||
## generatePrivateKey
|
||||
|
||||
The `generatePrivateKey` function generates a new private key encoded into a PEM
|
||||
block.
|
||||
|
||||
It takes one of the values for its first param:
|
||||
|
||||
- `ecdsa`: Generate an elyptical curve DSA key (P256)
|
||||
- `dsa`: Generate a DSA key (L2048N256)
|
||||
- `rsa`: Generate an RSA 4096 key
|
62
vendor/github.com/Masterminds/sprig/docs/date.md
generated
vendored
Normal file
62
vendor/github.com/Masterminds/sprig/docs/date.md
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
# Date Functions
|
||||
|
||||
## now
|
||||
|
||||
The current date/time. Use this in conjunction with other date functions.
|
||||
|
||||
## date
|
||||
|
||||
The `date` function formats a date.
|
||||
|
||||
|
||||
Format the date to YEAR-MONTH-DAY:
|
||||
```
|
||||
now | date "2006-01-02"
|
||||
```
|
||||
|
||||
Date formatting in Go is a [little bit different](https://pauladamsmith.com/blog/2011/05/go_time.html).
|
||||
|
||||
In short, take this as the base date:
|
||||
|
||||
```
|
||||
Mon Jan 2 15:04:05 MST 2006
|
||||
```
|
||||
|
||||
Write it in the format you want. Above, `2006-01-02` is the same date, but
|
||||
in the format we want.
|
||||
|
||||
## dateInZone
|
||||
|
||||
Same as `date`, but with a timezone.
|
||||
|
||||
```
|
||||
date "2006-01-02" (now) "UTC"
|
||||
```
|
||||
|
||||
## dateModify
|
||||
|
||||
The `dateModify` takes a modification and a date and returns the timestamp.
|
||||
|
||||
Subtract an hour and thirty minutes from the current time:
|
||||
|
||||
```
|
||||
now | date_modify "-1.5h"
|
||||
```
|
||||
|
||||
## htmlDate
|
||||
|
||||
The `htmlDate` function formates a date for inserting into an HTML date picker
|
||||
input field.
|
||||
|
||||
```
|
||||
now | htmlDate
|
||||
```
|
||||
|
||||
## htmlDateInZone
|
||||
|
||||
Same as htmlDate, but with a timezone.
|
||||
|
||||
```
|
||||
htmlDate (now) "UTC"
|
||||
```
|
||||
|
59
vendor/github.com/Masterminds/sprig/docs/defaults.md
generated
vendored
Normal file
59
vendor/github.com/Masterminds/sprig/docs/defaults.md
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
# Default Functions
|
||||
|
||||
Sprig provides tools for setting default values for templates.
|
||||
|
||||
## default
|
||||
|
||||
To set a simple default value, use `default`:
|
||||
|
||||
```
|
||||
default "foo" .Bar
|
||||
```
|
||||
|
||||
In the above, if `.Bar` evaluates to a non-empty value, it will be used. But if
|
||||
it is empty, `foo` will be returned instead.
|
||||
|
||||
The definition of "empty" depends on type:
|
||||
|
||||
- Numeric: 0
|
||||
- String: ""
|
||||
- Lists: `[]`
|
||||
- Dicts: `{}`
|
||||
- Boolean: `false`
|
||||
- And always `nil` (aka null)
|
||||
|
||||
For structs, there is no definition of empty, so a struct will never return the
|
||||
default.
|
||||
|
||||
## empty
|
||||
|
||||
The `empty` function returns `true` if the given value is considered empty, and
|
||||
`false` otherwise. The empty values are listed in the `default` section.
|
||||
|
||||
```
|
||||
empty .Foo
|
||||
```
|
||||
|
||||
Note that in Go template conditionals, emptiness is calculated for you. Thus,
|
||||
you rarely need `if empty .Foo`. Instead, just use `if .Foo`.
|
||||
|
||||
## coalesce
|
||||
|
||||
The `coalesce` function takes a list of values and returns the first non-empty
|
||||
one.
|
||||
|
||||
```
|
||||
coalesce 0 1 2
|
||||
```
|
||||
|
||||
The above returns `1`.
|
||||
|
||||
This function is useful for scanning through multiple variables or values:
|
||||
|
||||
```
|
||||
coalesce .name .parent.name "Matt"
|
||||
```
|
||||
|
||||
The above will first check to see if `.name` is empty. If it is not, it will return
|
||||
that value. If it _is_ empty, `coalesce` will evaluate `.parent.name` for emptiness.
|
||||
Finally, if both `.name` and `.parent.name` are empty, it will return `Matt`.
|
115
vendor/github.com/Masterminds/sprig/docs/dicts.md
generated
vendored
Normal file
115
vendor/github.com/Masterminds/sprig/docs/dicts.md
generated
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
# Dictionaries and Dict Functions
|
||||
|
||||
Sprig provides a key/value storage type called a `dict` (short for "dictionary",
|
||||
as in Python). A `dict` is an _unorder_ type.
|
||||
|
||||
The key to a dictionary **must be a string**. However, the value can be any
|
||||
type, even another `dict` or `list`.
|
||||
|
||||
Unlike `list`s, `dict`s are not immutable. The `set` and `unset` functions will
|
||||
modify the contents of a dictionary.
|
||||
|
||||
## dict
|
||||
|
||||
Creating dictionaries is done by calling the `dict` function and passing it a
|
||||
list of pairs.
|
||||
|
||||
The following creates a dictionary with three items:
|
||||
|
||||
```
|
||||
$myDict := dict "name1" "value1" "name2" "value2" "name3" "value 3"
|
||||
```
|
||||
|
||||
## set
|
||||
|
||||
Use `set` to add a new key/value pair to a dictionary.
|
||||
|
||||
```
|
||||
$_ := set $myDict "name4" "value4"
|
||||
```
|
||||
|
||||
Note that `set` _returns the dictionary_ (a requirement of Go template functions),
|
||||
so you may need to trap the value as done above with the `$_` assignment.
|
||||
|
||||
## unset
|
||||
|
||||
Given a map and a key, delete the key from the map.
|
||||
|
||||
```
|
||||
$_ := unset $myDict "name4"
|
||||
```
|
||||
|
||||
As with `set`, this returns the dictionary.
|
||||
|
||||
Note that if the key is not found, this operation will simply return. No error
|
||||
will be generated.
|
||||
|
||||
## hasKey
|
||||
|
||||
The `hasKey` function returns `true` if the given dict contains the given key.
|
||||
|
||||
```
|
||||
hasKey $myDict "name1"
|
||||
```
|
||||
|
||||
If the key is not found, this returns `false`.
|
||||
|
||||
## pluck
|
||||
|
||||
The `pluck` function makes it possible to give one key and multiple maps, and
|
||||
get a list of all of the matches:
|
||||
|
||||
```
|
||||
pluck "name1" $myDict $myOtherDict
|
||||
```
|
||||
|
||||
The above will return a `list` containing every found value (`[value1 otherValue1]`).
|
||||
|
||||
If the give key is _not found_ in a map, that map will not have an item in the
|
||||
list (and the length of the returned list will be less than the number of dicts
|
||||
in the call to `pluck`.
|
||||
|
||||
If the key is _found_ but the value is an empty value, that value will be
|
||||
inserted.
|
||||
|
||||
A common idiom in Sprig templates is to uses `pluck... | first` to get the first
|
||||
matching key out of a collection of dictionaries.
|
||||
|
||||
|
||||
## keys
|
||||
|
||||
The `keys` function will return a `list` of all of the keys in a `dict`. Since
|
||||
a dictionary is _unordered_, the keys will not be in a predictable order. They
|
||||
can be sorted with `sortAlpha`.
|
||||
|
||||
```
|
||||
keys $myDict | sortAlpha
|
||||
```
|
||||
|
||||
## pick
|
||||
|
||||
The `pick` function selects just the given keys out of a dictionary, creating a
|
||||
new `dict`.
|
||||
|
||||
```
|
||||
$new := pick $myDict "name1" "name3"
|
||||
```
|
||||
|
||||
The above returns `{name1: value1, name2: value2}`
|
||||
|
||||
## omit
|
||||
|
||||
The `omit` function is similar to `pick`, except it returns a new `dict` with all
|
||||
the keys that _do not_ match the given keys.
|
||||
|
||||
```
|
||||
$new := omit $myDict "name1" "name3"
|
||||
```
|
||||
|
||||
The above returns `{name2: value2}`
|
||||
|
||||
## A Note on Dict Internals
|
||||
|
||||
A `dict` is implemented in Go as a `map[string]interface{}`. Go developers can
|
||||
pass `map[string]interface{}` values into the context to make them available
|
||||
to templates as `dict`s.
|
6
vendor/github.com/Masterminds/sprig/docs/encoding.md
generated
vendored
Normal file
6
vendor/github.com/Masterminds/sprig/docs/encoding.md
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
# Encoding Functions
|
||||
|
||||
Sprig has the following encoding and decoding functions:
|
||||
|
||||
- `b64enc`/`b64dec`: Encode or decode with Base64
|
||||
- `b32enc`/`b32dec`: Encode or decode with Base32
|
22
vendor/github.com/Masterminds/sprig/docs/index.md
generated
vendored
Normal file
22
vendor/github.com/Masterminds/sprig/docs/index.md
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
# Sprig Function Documentation
|
||||
|
||||
The Sprig library provides over 70 template functions for Go's template language.
|
||||
|
||||
- [String Functions](strings.html): `trim`, `wrap`, `randAlpha`, `plural`, etc.
|
||||
- [String List Functions](string_slice.html): `splitList`, `sortAlpha`, etc.
|
||||
- [Math Functions](math.html): `add`, `max`, `mul`, etc.
|
||||
- [Integer Slice Functions](integer_slice.html): `until`, `untilStep`
|
||||
- [Date Functions](date.html): `now`, `date`, etc.
|
||||
- [Defaults Functions](defaults.html): `default`, `empty`, `coalesce`
|
||||
- [Encoding Functions](encoding.html): `b64enc`, `b64dec`, etc.
|
||||
- [Lists and List Functions](lists.html): `list`, `first`, `uniq`, etc.
|
||||
- [Dictionaries and Dict Functions](dicts.html): `dict`, `hasKey`, `pluck`, etc.
|
||||
- [Type Conversion Functions](conversion.html): `atoi`, `int64`, `toString`, etc.
|
||||
- [File Path Functions](paths.html): `base`, `dir`, `ext`, `clean`, `isAbs`
|
||||
- Advanced Functions
|
||||
- [UUID Functions](uuid.html): `uuidv4`
|
||||
- [OS Functions](os.html): `env`, `expandenv`
|
||||
- [Version Comparison Functions](semver.html): `semver`, `semverCompare`
|
||||
- [Reflection](reflection.html): `typeOf`, `kindIs`, `typeIsLike`, etc.
|
||||
- [Cryptographic and Security Functions](crypto.html): `derivePassword`, `sha256sum`, `genPrivateKey`
|
||||
|
25
vendor/github.com/Masterminds/sprig/docs/integer_slice.md
generated
vendored
Normal file
25
vendor/github.com/Masterminds/sprig/docs/integer_slice.md
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# Integer Slice Functions
|
||||
|
||||
## until
|
||||
|
||||
The `until` function builds a range of integers.
|
||||
|
||||
```
|
||||
until 5
|
||||
```
|
||||
|
||||
The above generates the list `[0, 1, 2, 3, 4]`.
|
||||
|
||||
This is useful for looping with `range $i, $e := until 5`.
|
||||
|
||||
## untilStep
|
||||
|
||||
Like `until`, `untilStep` generates a list of counting integers. But it allows
|
||||
you to define a start, stop, and step:
|
||||
|
||||
```
|
||||
untilStep 3 6 2
|
||||
```
|
||||
|
||||
The above will produce `[3 5]` by starting with 3, and adding 2 until it is equal
|
||||
or greater than 6. This is similar to Python's `range` function.
|
111
vendor/github.com/Masterminds/sprig/docs/lists.md
generated
vendored
Normal file
111
vendor/github.com/Masterminds/sprig/docs/lists.md
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
# Lists and List Functions
|
||||
|
||||
Sprig provides a simple `list` type that can contain arbitrary sequential lists
|
||||
of data. This is similar to arrays or slices, but lists are designed to be used
|
||||
as immutable data types.
|
||||
|
||||
Create a list of integers:
|
||||
|
||||
```
|
||||
$myList := list 1 2 3 4 5
|
||||
```
|
||||
|
||||
The above creates a list of `[1 2 3 4 5]`.
|
||||
|
||||
## first
|
||||
|
||||
To get the head item on a list, use `first`.
|
||||
|
||||
`first $myList` returns `1`
|
||||
|
||||
## rest
|
||||
|
||||
To get the tail of the list (everything but the first item), use `rest`.
|
||||
|
||||
`rest $myList` returns `[2 3 4 5]`
|
||||
|
||||
## last
|
||||
|
||||
To get the last item on a list, use `last`:
|
||||
|
||||
`last $myList` returns `5`. This is roughly analogous to reversing a list and
|
||||
then calling `first`.
|
||||
|
||||
## initial
|
||||
|
||||
This compliments `last` by returning all _but_ the last element.
|
||||
`initial $myList` returns `[1 2 3 4]`.
|
||||
|
||||
## append
|
||||
|
||||
Append a new item to an existing list, creating a new list.
|
||||
|
||||
```
|
||||
$new = append $myList 6
|
||||
```
|
||||
|
||||
The above would set `$new` to `[1 2 3 4 5 6]`. `$myList` would remain unaltered.
|
||||
|
||||
## prepend
|
||||
|
||||
Push an alement onto the front of a list, creating a new list.
|
||||
|
||||
```
|
||||
prepend $myList 0
|
||||
```
|
||||
|
||||
The above would produce `[0 1 2 3 4 5]`. `$myList` would remain unaltered.
|
||||
|
||||
## reverse
|
||||
|
||||
Produce a new list with the reversed elements of the given list.
|
||||
|
||||
```
|
||||
reverse $myList
|
||||
```
|
||||
|
||||
The above would generate the list `[5 4 3 2 1]`.
|
||||
|
||||
## uniq
|
||||
|
||||
Generate a list with all of the duplicates removed.
|
||||
|
||||
```
|
||||
list 1 1 1 2 | uniq
|
||||
```
|
||||
|
||||
The above would produce `[1 2]`
|
||||
|
||||
## without
|
||||
|
||||
The `without` function filters items out of a list.
|
||||
|
||||
```
|
||||
without $myList 3
|
||||
```
|
||||
|
||||
The above would produce `[1 2 4 5]`
|
||||
|
||||
Without can take more than one filter:
|
||||
|
||||
```
|
||||
without $myList 1 3 5
|
||||
```
|
||||
|
||||
That would produce `[2 4]`
|
||||
|
||||
## has
|
||||
|
||||
Test to see if a list has a particular element.
|
||||
|
||||
```
|
||||
has $myList 4
|
||||
```
|
||||
|
||||
The above would return `true`, while `has $myList "hello"` would return false.
|
||||
|
||||
## A Note on List Internals
|
||||
|
||||
A list is implemented in Go as a `[]interface{}`. For Go developers embedding
|
||||
Sprig, you may pass `[]interface{}` items into your template context and be
|
||||
able to use all of the `list` functions on those items.
|
46
vendor/github.com/Masterminds/sprig/docs/math.md
generated
vendored
Normal file
46
vendor/github.com/Masterminds/sprig/docs/math.md
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
# Math Functions
|
||||
|
||||
All math functions operate on `int64` values unless specified otherwise.
|
||||
|
||||
(In the future, these will be extended to handle floats as well)
|
||||
|
||||
## add
|
||||
|
||||
Sum numbers with `add`
|
||||
|
||||
## add1
|
||||
|
||||
To increment by 1, use `add1`
|
||||
|
||||
## sub
|
||||
|
||||
To subtract, use `sub`
|
||||
|
||||
## div
|
||||
|
||||
Perform integer division with `div`
|
||||
|
||||
## mod
|
||||
|
||||
Modulo with `mod`
|
||||
|
||||
## mul
|
||||
|
||||
Multiply with `mul`
|
||||
|
||||
## max
|
||||
|
||||
Return the largest of a series of integers:
|
||||
|
||||
This will return `3`:
|
||||
|
||||
```
|
||||
max 1 2 3
|
||||
```
|
||||
|
||||
## min
|
||||
|
||||
Return the smallest of a series of integers.
|
||||
|
||||
`min 1 2 3` will return `1`.
|
||||
|
24
vendor/github.com/Masterminds/sprig/docs/os.md
generated
vendored
Normal file
24
vendor/github.com/Masterminds/sprig/docs/os.md
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# OS Functions
|
||||
|
||||
_WARNING:_ These functions can lead to information leakage if not used
|
||||
appropriately.
|
||||
|
||||
_WARNING:_ Some notable implementations of Sprig (such as
|
||||
[Kubernetes Helm](http://helm.sh) _do not provide these functions for security
|
||||
reasons_.
|
||||
|
||||
## env
|
||||
|
||||
The `env` function reads an environment variable:
|
||||
|
||||
```
|
||||
env "HOME"
|
||||
```
|
||||
|
||||
## expandenv
|
||||
|
||||
To substitute environment variables in a string, use `expandenv`:
|
||||
|
||||
```
|
||||
expandenv "Your path is set to $PATH"
|
||||
```
|
43
vendor/github.com/Masterminds/sprig/docs/paths.md
generated
vendored
Normal file
43
vendor/github.com/Masterminds/sprig/docs/paths.md
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# File Path Functions
|
||||
|
||||
While Sprig does not grant access to the filesystem, it does provide functions
|
||||
for working with strings that follow file path conventions.
|
||||
|
||||
# base
|
||||
|
||||
Return the last element of a path.
|
||||
|
||||
```
|
||||
base "foo/bar/baz"
|
||||
```
|
||||
|
||||
The above prints "baz"
|
||||
|
||||
# dir
|
||||
|
||||
Return the directory, stripping the last part of the path. So `dir "foo/bar/baz"`
|
||||
returns `foo/bar`
|
||||
|
||||
# clean
|
||||
|
||||
Clean up a path.
|
||||
|
||||
```
|
||||
clean "foo/bar/../baz"
|
||||
```
|
||||
|
||||
The above resolves the `..` and returns `foo/baz`
|
||||
|
||||
# ext
|
||||
|
||||
Return the file extension.
|
||||
|
||||
```
|
||||
ext "foo.bar"
|
||||
```
|
||||
|
||||
The above returns `.bar`.
|
||||
|
||||
# isAbs
|
||||
|
||||
To check whether a file path is absolute, use `isAbs`.
|
38
vendor/github.com/Masterminds/sprig/docs/reflection.md
generated
vendored
Normal file
38
vendor/github.com/Masterminds/sprig/docs/reflection.md
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# Reflection Functions
|
||||
|
||||
Sprig provides rudimentary reflection tools. These help advanced template
|
||||
developers understand the underlying Go type information for a particular value.
|
||||
|
||||
Go has several primitive _kinds_, like `string`, `slice`, `int64`, and `bool`.
|
||||
|
||||
Go has an open _type_ system that allows developers to create their own types.
|
||||
|
||||
Sprig provides a set of functions for each.
|
||||
|
||||
## Kind Functions
|
||||
|
||||
There are two Kind functions: `kindOf` returns the kind of an object.
|
||||
|
||||
```
|
||||
kindOf "hello"
|
||||
```
|
||||
|
||||
The above would return `string`. For simple tests (like in `if` blocks), the
|
||||
`isKind` function will let you verify that a value is a particular kind:
|
||||
|
||||
```
|
||||
kindIs "int" 123
|
||||
```
|
||||
|
||||
The above will return `true`
|
||||
|
||||
## Type Functions
|
||||
|
||||
Types are slightly harder to work with, so there are three different functions:
|
||||
|
||||
- `typeOf` returns the underlying type of a value: `typeOf $foo`
|
||||
- `typeIs` is like `kindIs`, but for types: `typeIs "*io.Buffer" $myVal`
|
||||
- `typeIsLike` works as `kindIs`, except that it also dereferences pointers.
|
||||
|
||||
**Note:** None of these can test whether or not something implements a given
|
||||
interface, since doing so would require compiling the interface in ahead of time.
|
124
vendor/github.com/Masterminds/sprig/docs/semver.md
generated
vendored
Normal file
124
vendor/github.com/Masterminds/sprig/docs/semver.md
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
# Semantic Version Functions
|
||||
|
||||
Some version schemes are easily parseable and comparable. Sprig provides functions
|
||||
for working with [SemVer 2](http://semver.org) versions.
|
||||
|
||||
## semver
|
||||
|
||||
The `semver` function parses a string into a Semantic Version:
|
||||
|
||||
```
|
||||
$version := semver "1.2.3-alpha.1+123"
|
||||
```
|
||||
|
||||
_If the parser fails, it will cause template execution to halt with an error._
|
||||
|
||||
At this point, `$version` is a pointer to a `Version` object with the following
|
||||
properties:
|
||||
|
||||
- `$version.Major`: The major number (`1` above)
|
||||
- `$version.Minor`: The minor number (`2` above)
|
||||
- `$version.Patch`: The patch number (`3` above)
|
||||
- `$version.Prerelease`: The prerelease (`alpha.1` above)
|
||||
- `$version.Metadata`: The build metadata (`123` above)
|
||||
- `$version.Original`: The original version as a string
|
||||
|
||||
Additionally, you can compare a `Version` to another `version` using the `Compare`
|
||||
function:
|
||||
|
||||
```
|
||||
semver "1.4.3" | (semver "1.2.3").Compare
|
||||
```
|
||||
|
||||
The above will return `-1`.
|
||||
|
||||
The return values are:
|
||||
|
||||
- `-1` if the given semver is greater than the semver whose `Compare` method was called
|
||||
- `1` if the version who's `Compare` function was called is greater.
|
||||
- `0` if they are the same version
|
||||
|
||||
(Note that in SemVer, the `Metadata` field is not compared during version
|
||||
comparison operations.)
|
||||
|
||||
|
||||
## semverCompare
|
||||
|
||||
A more robust comparison function is provided as `semverCompare`. This version
|
||||
supports version ranges:
|
||||
|
||||
- `semverCompare "1.2.3" "1.2.3"` checks for an exact match
|
||||
- `semverCompare "^1.2.0" "1.2.3"` checks that the major and minor versions match, and that the patch
|
||||
number of the second version is _greater than or equal to_ the first parameter.
|
||||
|
||||
The SemVer functions use the [Masterminds semver library](https://github.com/Masterminds/semver),
|
||||
from the creators of Sprig.
|
||||
|
||||
|
||||
## Basic Comparisons
|
||||
|
||||
There are two elements to the comparisons. First, a comparison string is a list
|
||||
of comma separated and comparisons. These are then separated by || separated or
|
||||
comparisons. For example, `">= 1.2, < 3.0.0 || >= 4.2.3"` is looking for a
|
||||
comparison that's greater than or equal to 1.2 and less than 3.0.0 or is
|
||||
greater than or equal to 4.2.3.
|
||||
|
||||
The basic comparisons are:
|
||||
|
||||
* `=`: equal (aliased to no operator)
|
||||
* `!=`: not equal
|
||||
* `>`: greater than
|
||||
* `<`: less than
|
||||
* `>=`: greater than or equal to
|
||||
* `<=`: less than or equal to
|
||||
|
||||
_Note, according to the Semantic Version specification pre-releases may not be
|
||||
API compliant with their release counterpart. It says,_
|
||||
|
||||
> _A pre-release version indicates that the version is unstable and might not satisfy the intended compatibility requirements as denoted by its associated normal version._
|
||||
|
||||
_SemVer comparisons without a pre-release value will skip pre-release versions.
|
||||
For example, `>1.2.3` will skip pre-releases when looking at a list of values
|
||||
while `>1.2.3-alpha.1` will evaluate pre-releases._
|
||||
|
||||
## Hyphen Range Comparisons
|
||||
|
||||
There are multiple methods to handle ranges and the first is hyphens ranges.
|
||||
These look like:
|
||||
|
||||
* `1.2 - 1.4.5` which is equivalent to `>= 1.2, <= 1.4.5`
|
||||
* `2.3.4 - 4.5` which is equivalent to `>= 2.3.4, <= 4.5`
|
||||
|
||||
## Wildcards In Comparisons
|
||||
|
||||
The `x`, `X`, and `*` characters can be used as a wildcard character. This works
|
||||
for all comparison operators. When used on the `=` operator it falls
|
||||
back to the pack level comparison (see tilde below). For example,
|
||||
|
||||
* `1.2.x` is equivalent to `>= 1.2.0, < 1.3.0`
|
||||
* `>= 1.2.x` is equivalent to `>= 1.2.0`
|
||||
* `<= 2.x` is equivalent to `<= 3`
|
||||
* `*` is equivalent to `>= 0.0.0`
|
||||
|
||||
## Tilde Range Comparisons (Patch)
|
||||
|
||||
The tilde (`~`) comparison operator is for patch level ranges when a minor
|
||||
version is specified and major level changes when the minor number is missing.
|
||||
For example,
|
||||
|
||||
* `~1.2.3` is equivalent to `>= 1.2.3, < 1.3.0`
|
||||
* `~1` is equivalent to `>= 1, < 2`
|
||||
* `~2.3` is equivalent to `>= 2.3, < 2.4`
|
||||
* `~1.2.x` is equivalent to `>= 1.2.0, < 1.3.0`
|
||||
* `~1.x` is equivalent to `>= 1, < 2`
|
||||
|
||||
## Caret Range Comparisons (Major)
|
||||
|
||||
The caret (`^`) comparison operator is for major level changes. This is useful
|
||||
when comparisons of API versions as a major change is API breaking. For example,
|
||||
|
||||
* `^1.2.3` is equivalent to `>= 1.2.3, < 2.0.0`
|
||||
* `^1.2.x` is equivalent to `>= 1.2.0, < 2.0.0`
|
||||
* `^2.3` is equivalent to `>= 2.3, < 3`
|
||||
* `^2.x` is equivalent to `>= 2.0.0, < 3`
|
||||
|
55
vendor/github.com/Masterminds/sprig/docs/string_slice.md
generated
vendored
Normal file
55
vendor/github.com/Masterminds/sprig/docs/string_slice.md
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
# String Slice Functions
|
||||
|
||||
These function operate on or generate slices of strings. In Go, a slice is a
|
||||
growable array. In Sprig, it's a special case of a `list`.
|
||||
|
||||
## join
|
||||
|
||||
Join a list of strings into a single string, with the given separator.
|
||||
|
||||
```
|
||||
list "hello" "world" | join "_"
|
||||
```
|
||||
|
||||
The above will produce `hello_world`
|
||||
|
||||
`join` will try to convert non-strings to a string value:
|
||||
|
||||
```
|
||||
list 1 2 3 | join "+"
|
||||
```
|
||||
|
||||
The above will produce `1+2+3`
|
||||
|
||||
## splitList and split
|
||||
|
||||
Split a string into a list of strings:
|
||||
|
||||
```
|
||||
splitList "$" "foo$bar$baz"
|
||||
```
|
||||
|
||||
The above will return `[foo bar baz]`
|
||||
|
||||
The older `split` function splits a string into a `dict`. It is designed to make
|
||||
it easy to use template dot notation for accessing members:
|
||||
|
||||
```
|
||||
$a := split "$" "foo$bar$baz"
|
||||
```
|
||||
|
||||
The above produces a map with index keys. `{_0: foo, _1: bar, _2: baz}`
|
||||
|
||||
```
|
||||
$a._0
|
||||
```
|
||||
|
||||
The above produces `foo`
|
||||
|
||||
## sortAlpha
|
||||
|
||||
The `sortAlpha` function sorts a list of strings into alphabetical (lexicographical)
|
||||
order.
|
||||
|
||||
It does _not_ sort in place, but returns a sorted copy of the list, in keeping
|
||||
with the immutability of lists.
|
285
vendor/github.com/Masterminds/sprig/docs/strings.md
generated
vendored
Normal file
285
vendor/github.com/Masterminds/sprig/docs/strings.md
generated
vendored
Normal file
@@ -0,0 +1,285 @@
|
||||
# String Functions
|
||||
|
||||
Sprig has a number of string manipulation functions.
|
||||
|
||||
## trim
|
||||
|
||||
The `trim` function removes space from either side of a string:
|
||||
|
||||
```
|
||||
trim " hello "
|
||||
```
|
||||
|
||||
The above produces `hello`
|
||||
|
||||
## trimAll
|
||||
|
||||
Remove given characters from the front or back of a string:
|
||||
|
||||
```
|
||||
trimAll "$" "$5.00"
|
||||
```
|
||||
|
||||
The above returns `5.00` (as a string).
|
||||
|
||||
## trimSuffix
|
||||
|
||||
Trim just the suffix from a string:
|
||||
|
||||
```
|
||||
trimSuffix "-" "hello-"
|
||||
```
|
||||
|
||||
The above returns `hello`
|
||||
|
||||
## upper
|
||||
|
||||
Convert the entire string to uppercase:
|
||||
|
||||
```
|
||||
upper "hello"
|
||||
```
|
||||
|
||||
The above returns `HELLO`
|
||||
|
||||
## lower
|
||||
|
||||
Convert the entire string to lowercase:
|
||||
|
||||
```
|
||||
lower "HELLO"
|
||||
```
|
||||
|
||||
The above returns `hello`
|
||||
|
||||
## title
|
||||
|
||||
Convert to title case:
|
||||
|
||||
```
|
||||
title "hello world"
|
||||
```
|
||||
|
||||
The above returns `Hello World`
|
||||
|
||||
## untitle
|
||||
|
||||
Remove title casing. `untitle "Hello World"` produces `hello world`.
|
||||
|
||||
## repeat
|
||||
|
||||
Repeat a string multiple times:
|
||||
|
||||
```
|
||||
repeat 3 "hello"
|
||||
```
|
||||
|
||||
The above returns `hellohellohello`
|
||||
|
||||
## substr
|
||||
|
||||
Get a substring from a string. It takes three parameters:
|
||||
|
||||
- start (int)
|
||||
- length (int)
|
||||
- string (string)
|
||||
|
||||
```
|
||||
substr 0 5 "hello world"
|
||||
```
|
||||
|
||||
The above returns `hello`
|
||||
|
||||
## nospace
|
||||
|
||||
Remove all whitespace from a string.
|
||||
|
||||
```
|
||||
nospace "hello w o r l d"
|
||||
```
|
||||
|
||||
The above returns `helloworld`
|
||||
|
||||
## trunc
|
||||
|
||||
Truncate a string (and add no suffix)
|
||||
|
||||
```
|
||||
trunc 5 "hello world"
|
||||
```
|
||||
|
||||
The above produces `hello`.
|
||||
|
||||
## abbrev
|
||||
|
||||
Truncate a string with ellipses (`...`)
|
||||
|
||||
Parameters:
|
||||
- max length
|
||||
- the string
|
||||
|
||||
```
|
||||
abbrev 5 "hello world"
|
||||
```
|
||||
|
||||
The above returns `he...`, since it counts the width of the ellipses against the
|
||||
maximum length.
|
||||
|
||||
## abbrevboth
|
||||
|
||||
Abbreviate both sides:
|
||||
|
||||
```
|
||||
abbrevboth 5 10 "1234 5678 9123"
|
||||
```
|
||||
|
||||
the above produces `...5678...`
|
||||
|
||||
It takes:
|
||||
|
||||
- left offset
|
||||
- max length
|
||||
- the string
|
||||
|
||||
## initials
|
||||
|
||||
Given multiple words, take the first letter of each word and combine.
|
||||
|
||||
```
|
||||
initials "First Try"
|
||||
```
|
||||
|
||||
The above returns `FT`
|
||||
|
||||
## randAlphaNum, randAlpha, randNumeric, and randAscii
|
||||
|
||||
These four functions generate random strings, but with different base character
|
||||
sets:
|
||||
|
||||
- `randAlphaNum` uses `0-9a-zA-Z`
|
||||
- `randAlpha` uses `a-zA-Z`
|
||||
- `randNumeric` uses `0-9`
|
||||
- `randAscii` uses all printable ASCII characters
|
||||
|
||||
Each of them takes one parameter: the integer length of the string.
|
||||
|
||||
```
|
||||
randNumeric 3
|
||||
```
|
||||
|
||||
The above will produce a random string with three digits.
|
||||
|
||||
## wrap
|
||||
|
||||
Wrap text at a given column count:
|
||||
|
||||
```
|
||||
wrap 80 $someText
|
||||
```
|
||||
|
||||
The above will wrap the string in `$someText` at 80 columns.
|
||||
|
||||
## wrapWith
|
||||
|
||||
`wrapWith` works as `wrap`, but lets you specify the string to wrap with.
|
||||
(`wrap` uses `\n`)
|
||||
|
||||
```
|
||||
wrapWith 5 "\t" "Hello World"
|
||||
```
|
||||
|
||||
The above produces `hello world` (where the whitespace is an ASCII tab
|
||||
character)
|
||||
|
||||
## contains
|
||||
|
||||
Test to see if one string is contained inside of another:
|
||||
|
||||
```
|
||||
contains "cat" "catch"
|
||||
```
|
||||
|
||||
The above returns `true` because `catch` contains `cat`.
|
||||
|
||||
## hasPrefix and hasSuffix
|
||||
|
||||
The `hasPrefix` and `hasSuffix` functions test whether a string has a given
|
||||
prefix or suffix:
|
||||
|
||||
```
|
||||
hasPrefix "cat" "catch"
|
||||
```
|
||||
|
||||
The above returns `true` because `catch` has the prefix `cat`.
|
||||
|
||||
## quote and squote
|
||||
|
||||
These functions wrap a string in double quotes (`quote`) or single quotes
|
||||
(`squote`).
|
||||
|
||||
## cat
|
||||
|
||||
The `cat` function concatenates multiple strings together into one, separating
|
||||
them with spaces:
|
||||
|
||||
```
|
||||
cat "hello" "beautiful" "world"
|
||||
```
|
||||
|
||||
The above produces `hello beautiful world`
|
||||
|
||||
## indent
|
||||
|
||||
The `indent` function indents every line in a given string to the specified
|
||||
indent width. This is useful when aligning multi-line strings:
|
||||
|
||||
```
|
||||
indent 4 $lots_of_text
|
||||
```
|
||||
|
||||
The above will indent every line of text by 4 space characters.
|
||||
|
||||
## replace
|
||||
|
||||
Perform simple string replacement.
|
||||
|
||||
It takes three arguments:
|
||||
|
||||
- string to replace
|
||||
- string to replace with
|
||||
- source string
|
||||
|
||||
```
|
||||
"I Am Henry VIII" | replace " " "-"
|
||||
```
|
||||
|
||||
The above will produce `I-Am-Henry-VIII`
|
||||
|
||||
## plural
|
||||
|
||||
Pluralize a string.
|
||||
|
||||
```
|
||||
len $fish | plural "one anchovy" "many anchovies"
|
||||
```
|
||||
|
||||
In the above, if the length of the string is 1, the first argument will be
|
||||
printed (`one anchovy`). Otherwise, the second argument will be printed
|
||||
(`many anchovies`).
|
||||
|
||||
The arguments are:
|
||||
|
||||
- singular string
|
||||
- plural string
|
||||
- length integer
|
||||
|
||||
NOTE: Sprig does not currently support languages with more complex pluralization
|
||||
rules. And `0` is considered a plural because the English language treats it
|
||||
as such (`zero anchovies`). The Sprig developers are working on a solution for
|
||||
better internationalization.
|
||||
|
||||
## See Also...
|
||||
|
||||
The [Conversion Functions](conversion.html) contain functions for converting
|
||||
strings. The [String Slice Functions](string_slice.html) contains functions
|
||||
for working with an array of strings.
|
9
vendor/github.com/Masterminds/sprig/docs/uuid.md
generated
vendored
Normal file
9
vendor/github.com/Masterminds/sprig/docs/uuid.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# UUID Functions
|
||||
|
||||
Sprig can generate UUID v4 universally unique IDs.
|
||||
|
||||
```
|
||||
uuidv4
|
||||
```
|
||||
|
||||
The above returns a new UUID of the v4 (randomly generated) type.
|
Reference in New Issue
Block a user