summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/hashicorp/go-sockaddr/template/doc.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/go-sockaddr/template/doc.go')
-rw-r--r--vendor/github.com/hashicorp/go-sockaddr/template/doc.go96
1 files changed, 80 insertions, 16 deletions
diff --git a/vendor/github.com/hashicorp/go-sockaddr/template/doc.go b/vendor/github.com/hashicorp/go-sockaddr/template/doc.go
index 59945d7be..90c8784a3 100644
--- a/vendor/github.com/hashicorp/go-sockaddr/template/doc.go
+++ b/vendor/github.com/hashicorp/go-sockaddr/template/doc.go
@@ -53,23 +53,22 @@ Example:
{{ GetDefaultInterfaces }}
`GetPrivateInterfaces` - Returns one IfAddr for every forwardable IP address
-that is included in RFC 6890, is attached to the interface with the default
-route, and whose interface is marked as up. NOTE: RFC 6890 is a more exhaustive
-version of RFC1918 because it spans IPv4 and IPv6, however it does permit the
+that is included in RFC 6890 and whose interface is marked as up. NOTE: RFC 6890 is a more exhaustive
+version of RFC1918 because it spans IPv4 and IPv6, however, RFC6890 does permit the
inclusion of likely undesired addresses such as multicast, therefore our version
of "private" also filters out non-forwardable addresses.
Example:
- {{ GetPrivateInterfaces | include "flags" "up" }}
+ {{ GetPrivateInterfaces | sort "default" | join "address" " " }}
-`GetPublicInterfaces` - Returns a list of IfAddr that do not match RFC 6890, is
-attached to the default route, and whose interface is marked as up.
+`GetPublicInterfaces` - Returns a list of IfAddr structs whos IPs are
+forwardable, do not match RFC 6890, and whose interface is marked up.
Example:
- {{ GetPublicInterfaces | include "flags" "up" }}
+ {{ GetPublicInterfaces | sort "default" | join "name" " " }}
`GetPrivateIP` - Helper function that returns a string of the first IP address
@@ -80,6 +79,14 @@ Example:
{{ GetPrivateIP }}
+`GetPrivateIPs` - Helper function that returns a string of the all private IP
+addresses on the host.
+
+Example:
+
+ {{ GetPrivateIPs }}
+
+
`GetPublicIP` - Helper function that returns a string of the first IP from
GetPublicInterfaces.
@@ -87,12 +94,29 @@ Example:
{{ GetPublicIP }}
+`GetPublicIPs` - Helper function that returns a space-delimited string of the
+all public IP addresses on the host.
+
+Example:
+
+ {{ GetPrivateIPs }}
+
+
`GetInterfaceIP` - Helper function that returns a string of the first IP from
the named interface.
Example:
- {{ GetInterfaceIP }}
+ {{ GetInterfaceIP "en0" }}
+
+
+
+`GetInterfaceIPs` - Helper function that returns a space-delimited list of all
+IPs on a given interface.
+
+Example:
+
+ {{ GetInterfaceIPs "en0" }}
`sort` - Sorts the IfAddrs result based on its arguments. `sort` takes one
@@ -100,6 +124,8 @@ argument, a list of ways to sort its IfAddrs argument. The list of sort
criteria is comma separated (`,`):
- `address`, `+address`: Ascending sort of IfAddrs by Address
- `-address`: Descending sort of IfAddrs by Address
+ - `default`, `+default`: Ascending sort of IfAddrs, IfAddr with a default route first
+ - `-default`: Descending sort of IfAddrs, IfAttr with default route last
- `name`, `+name`: Ascending sort of IfAddrs by lexical ordering of interface name
- `-name`: Descending sort of IfAddrs by lexical ordering of interface name
- `port`, `+port`: Ascending sort of IfAddrs by port number
@@ -116,7 +142,7 @@ criteria is comma separated (`,`):
Example:
- {{ GetPrivateInterfaces | sort "type,size,address" }}
+ {{ GetPrivateInterfaces | sort "default,-type,size,+address" }}
`exclude` and `include`: Filters IfAddrs based on the selector criteria and its
@@ -142,7 +168,7 @@ available filtering criteria is:
Example:
- {{ GetPrivateInterfaces | exclude "type" "IPv6" | include "flag" "up|forwardable" }}
+ {{ GetPrivateInterfaces | exclude "type" "IPv6" }}
`unique`: Removes duplicate entries from the IfAddrs list, assuming the list has
@@ -152,14 +178,14 @@ already been sorted. `unique` only takes one argument:
Example:
- {{ GetPrivateInterfaces | sort "type,address" | unique "name" }}
+ {{ GetAllInterfaces | sort "default,-type,address" | unique "name" }}
`limit`: Reduces the size of the list to the specified value.
Example:
- {{ GetPrivateInterfaces | include "flags" "forwardable|up" | limit 1 }}
+ {{ GetPrivateInterfaces | limit 1 }}
`offset`: Seeks into the list by the specified value. A negative value can be
@@ -167,7 +193,33 @@ used to seek from the end of the list.
Example:
- {{ GetPrivateInterfaces | include "flags" "forwardable|up" | offset "-2" | limit 1 }}
+ {{ GetPrivateInterfaces | offset "-2" | limit 1 }}
+
+
+`math`: Perform a "math" operation on each member of the list and return new
+values. `math` takes two arguments, the attribute to operate on and the
+operation's value.
+
+Supported operations include:
+
+ - `address`: Adds the value, a positive or negative value expressed as a
+ decimal string, to the address. The sign is required. This value is
+ allowed to over or underflow networks (e.g. 127.255.255.255 `"address" "+1"`
+ will return "128.0.0.0"). Addresses will wrap at IPv4 or IPv6 boundaries.
+ - `network`: Add the value, a positive or negative value expressed as a
+ decimal string, to the network address. The sign is required. Positive
+ values are added to the network address. Negative values are subtracted
+ from the network's broadcast address (e.g. 127.0.0.1 `"network" "-1"` will
+ return "127.255.255.255"). Values that overflow the network size will
+ safely wrap.
+
+Example:
+
+ {{ GetPrivateInterfaces | include "type" "IP" | math "address" "+256" | attr "address" }}
+ {{ GetPrivateInterfaces | include "type" "IP" | math "address" "-256" | attr "address" }}
+ {{ GetPrivateInterfaces | include "type" "IP" | math "network" "+2" | attr "address" }}
+ {{ GetPrivateInterfaces | include "type" "IP" | math "network" "-2" | attr "address" }}
+ {{ GetPrivateInterfaces | include "flags" "forwardable|up" | include "type" "IPv4" | math "network" "+2" | attr "address" }}
`attr`: Extracts a single attribute of the first member of the list and returns
@@ -177,7 +229,19 @@ supported attributes.
Example:
- {{ GetPrivateInterfaces | include "flags" "forwardable|up" | attr "address" }}
+ {{ GetAllInterfaces | exclude "flags" "up" | attr "address" }}
+
+
+`Attr`: Extracts a single attribute from an `IfAttr` and in every other way
+performs the same as the `attr`.
+
+Example:
+
+ {{ with $ifAddrs := GetAllInterfaces | include "type" "IP" | sort "+type,+address" -}}
+ {{- range $ifAddrs -}}
+ {{- Attr "address" . }} -- {{ Attr "network" . }}/{{ Attr "size" . -}}
+ {{- end -}}
+ {{- end }}
`join`: Similar to `attr`, `join` extracts all matching attributes of the list
@@ -187,7 +251,7 @@ and returns them as a string joined by the separator, the second argument to
Example:
- {{ GetPrivateInterfaces | include "flags" "forwardable|up" | join "address" " " }}
+ {{ GetAllInterfaces | include "flags" "forwardable" | join "address" " " }}
`exclude` and `include` flags:
@@ -205,7 +269,7 @@ Example:
- `up`: Is the interface up?
-Attributes for `attr` and `join`:
+Attributes for `attr`, `Attr`, and `join`:
SockAddr Type:
- `string`