kr8_native_funcs
import "github.com/ice-bergtech/kr8/pkg/kr8_native_funcs"
Package kr8_native_funcs provides native functions that jsonnet code can reference. Functions include processing docker-compose files, helm charts, templating, URL and IP address parsing.
Index
- func NativeHelmTemplate() *jsonnet.NativeFunction
- func NativeHelp(allFuncs []*jsonnet.NativeFunction) *jsonnet.NativeFunction
- func NativeKompose() *jsonnet.NativeFunction
- func NativeNetAddressARPA() *jsonnet.NativeFunction
- func NativeNetAddressBinary() *jsonnet.NativeFunction
- func NativeNetAddressCalcSubnetsV4() *jsonnet.NativeFunction
- func NativeNetAddressCalcSubnetsV6() *jsonnet.NativeFunction
- func NativeNetAddressCompare() *jsonnet.NativeFunction
- func NativeNetAddressDec() *jsonnet.NativeFunction
- func NativeNetAddressDecBy() *jsonnet.NativeFunction
- func NativeNetAddressDelta() *jsonnet.NativeFunction
- func NativeNetAddressHex() *jsonnet.NativeFunction
- func NativeNetAddressInc() *jsonnet.NativeFunction
- func NativeNetAddressIncBy() *jsonnet.NativeFunction
- func NativeNetAddressNetsBetween() *jsonnet.NativeFunction
- func NativeNetAddressSort() *jsonnet.NativeFunction
- func NativeNetIPInfo() *jsonnet.NativeFunction
- func NativeNetUrl() *jsonnet.NativeFunction
- func NativeRegexEscape() *jsonnet.NativeFunction
- func NativeRegexMatch() *jsonnet.NativeFunction
- func NativeRegexSubst() *jsonnet.NativeFunction
- func NativeSprigTemplate() *jsonnet.NativeFunction
- func RegisterNativeFuncs(jvm *jsonnet.VM)
- type IPV4
- func IPV4Info(rawIP string) (*IPV4, error)
- type IPV6
- func IPV6Info(rawIP string) (*IPV6, error)
- type KomposeHook
- func (*KomposeHook) Fire(entry *kLogger.Entry) error
- func (*KomposeHook) Levels() []kLogger.Level
- type KomposeParams
- func ParseKomposeParams(args []interface{}) (*KomposeParams, error)
- func (params *KomposeParams) ExtractParameters()
- type NativeFuncURL
func NativeHelmTemplate
func NativeHelmTemplate() *jsonnet.NativeFunction
Allows executing helm template to process a helm chart and make available to kr8+ configuration.
Source: https://github.com/grafana/tanka/blob/v0.27.1/pkg/helm/template.go#L23
func NativeHelp
func NativeHelp(allFuncs []*jsonnet.NativeFunction) *jsonnet.NativeFunction
func NativeKompose
func NativeKompose() *jsonnet.NativeFunction
Allows converting a docker-compose string into kubernetes resources using kompose. Files in the directory must be in the format `[docker-]compose.y[a]ml`. RootDir is usually `std.thisFile()`.
Source: https://github.com/kubernetes/kompose/blob/main/cmd/convert.go
Inputs: `rootDir`, `listFiles`, `namespace`.
func NativeNetAddressARPA
func NativeNetAddressARPA() *jsonnet.NativeFunction
Convert address to addr.APRA DNS name.
Inputs: "rawIP".
func NativeNetAddressBinary
func NativeNetAddressBinary() *jsonnet.NativeFunction
Return binary string representation of address. This is the default stringer format for v6 net.IP.
Inputs: "rawIP".
func NativeNetAddressCalcSubnetsV4
func NativeNetAddressCalcSubnetsV4() *jsonnet.NativeFunction
Return a list of networks of a given masklen that can be extracted from an IPv4 CIDR. The mask provided must be a larger-integer than the current mask. If set to 0 Subnet carves the network in half.
Inputs: "ip4Net", "maskLen".
func NativeNetAddressCalcSubnetsV6
func NativeNetAddressCalcSubnetsV6() *jsonnet.NativeFunction
Return a list of networks of a given masklen that can be extracted from an IPv6 CIDR. The mask provided must be a larger-integer than the current mask. If set to 0 Subnet carves the network in half. Hostmask must be provided if desired.
Inputs: "ip6Net", "netMaskLen", "hostMaskLen".
func NativeNetAddressCompare
func NativeNetAddressCompare() *jsonnet.NativeFunction
Compare two addresses.
0 if a==b, -1 if a\<b, 1 if a>b.
func NativeNetAddressDec
func NativeNetAddressDec() *jsonnet.NativeFunction
PreviousIP returns a net.IP decremented by one from the input address. If you underflow the IP space the zero address is returned.
Inputs: "rawIP".
func NativeNetAddressDecBy
func NativeNetAddressDecBy() *jsonnet.NativeFunction
Returns a net.IP that is lower than the supplied net.IP by the supplied integer value. If you underflow the IP space the zero address is returned.
Inputs: "rawIP", "count".
func NativeNetAddressDelta
func NativeNetAddressDelta() *jsonnet.NativeFunction
Gets the delta of two addresses. Takes two net.IP's as input and returns the difference between them up to the limit of uint32.
Inputs: "rawIP, "otherIP".
func NativeNetAddressHex
func NativeNetAddressHex() *jsonnet.NativeFunction
Return hex representation of address. This is the default stringer format for v6 net.IP.
Inputs: "rawIP".
func NativeNetAddressInc
func NativeNetAddressInc() *jsonnet.NativeFunction
NextIP returns a net.IP incremented by one from the input address. If you overflow the IP space the all-ones address is returned.
Inputs: "rawIP".
func NativeNetAddressIncBy
func NativeNetAddressIncBy() *jsonnet.NativeFunction
Returns a net.IP that is greater than the supplied net.IP by the supplied integer value. If you overflow the IP space the all-ones address is returned.
Inputs: "rawIP", "count".
func NativeNetAddressNetsBetween
func NativeNetAddressNetsBetween() *jsonnet.NativeFunction
Returns a slice of netblocks spanning the range between the two networks, inclusively. Returns single-address netblocks if required.
Inputs: "ipNet", "otherIPNet".
func NativeNetAddressSort
func NativeNetAddressSort() *jsonnet.NativeFunction
Sort list of ip addresses.
Inputs: "listIPs".
func NativeNetIPInfo
func NativeNetIPInfo() *jsonnet.NativeFunction
net.IP tools. https://github.com/c-robinson/iplib .
Inputs: "rawIP".
func NativeNetUrl
func NativeNetUrl() *jsonnet.NativeFunction
Decode URL information from a string. Based on https://github.com/lintnet/go-jsonnet-native-functions/blob/main/pkg/net/url/url.go .
Inputs: "rawURL".
func NativeRegexEscape
func NativeRegexEscape() *jsonnet.NativeFunction
Escapes a string for use in regex.
Inputs: "str".
func NativeRegexMatch
func NativeRegexMatch() *jsonnet.NativeFunction
Matches a string against a regex pattern.
Inputs: "regex", "string".
func NativeRegexSubst
func NativeRegexSubst() *jsonnet.NativeFunction
Substitutes a regex pattern in a string with another string.
Inputs: "regex", "src", "repl".
func NativeSprigTemplate
func NativeSprigTemplate() *jsonnet.NativeFunction
Uses sprig to process passed in config data and template. Sprig template guide: https://masterminds.github.io/sprig/ .
Inputs: "config" "templateStr".
func RegisterNativeFuncs
func RegisterNativeFuncs(jvm *jsonnet.VM)
Registers additional native functions in the jsonnet VM. These functions are used to extend the functionality of jsonnet. Adds on to functions part of the jsonnet standard lib: https://jsonnet.org/ref/stdlib.html
type IPV4
An IPv4 address or subnet range.
type IPV4 struct {
IP string
Mask int
CIDR string
Count uint32
FirstAddress string
LastAddress string
Broadcast string
}
func IPV4Info
func IPV4Info(rawIP string) (*IPV4, error)
Parses an IPv4 object from a string.
type IPV6
An IPv6 address or subnet range.
type IPV6 struct {
IP string
NetMask string
HostMask string
CIDR string
Count uint128.Uint128
FirstAddress string
LastAddress string
}
func IPV6Info
func IPV6Info(rawIP string) (*IPV6, error)
Parses an IPv6 object from a string.
type KomposeHook
type KomposeHook struct{}
func (*KomposeHook) Fire
func (*KomposeHook) Fire(entry *kLogger.Entry) error
func (*KomposeHook) Levels
func (*KomposeHook) Levels() []kLogger.Level
type KomposeParams
type KomposeParams struct {
// Root directory of the compose files
RootDir string `json:"rootDir"`
// The list of compose files to convert.
ComposeFiles []string `json:"composeFileList"`
// Namespace to assign to resources.
Namespace string `json:"namespace"`
}
func ParseKomposeParams
func ParseKomposeParams(args []interface{}) (*KomposeParams, error)
func (*KomposeParams) ExtractParameters
func (params *KomposeParams) ExtractParameters()
type NativeFuncURL
Contains the url information.
type NativeFuncURL struct {
Scheme string `json:"scheme"`
// encoded opaque data
Opaque string `json:"opaque"`
// username information
Username string `json:"username"`
// Whether the password field is set
PasswordSet bool `json:"passwordSet"`
// password information
Password string `json:"password"`
// host or host:port (see Hostname and Port methods)
Host string `json:"host"`
// path (relative paths may omit leading slash)
Path string `json:"path"`
// encoded path hint (see EscapedPath method)
RawPath string `json:"pathRaw"`
// query values
Query map[string]interface{} `json:"query"`
// encoded query values, without '?'
RawQuery string `json:"queryRaw"`
// fragment for references, without '#'
Fragment string `json:"fragment"`
// encoded fragment hint (see EscapedFragment method)
RawFragment string `json:"fragmentRaw"`
}