jnetvm

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package jvm contains the jsonnet rendering logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JsonnetRender

func JsonnetRender(cmdFlagsJsonnet types.CmdJsonnetOptions, filename string, vmConfig types.VMConfig) error

Renders a jsonnet file with the specified options.

func JsonnetRenderClusterParams

func JsonnetRenderClusterParams(
	vmconfig types.VMConfig,
	clusterName string,
	componentNames []string,
	clusterParams string,
	prune bool,
) (string, error)

Render cluster params, merged with one or more component's parameters. Empty componentName list renders all component parameters.

func JsonnetRenderClusterParamsOnly

func JsonnetRenderClusterParamsOnly(
	vmconfig types.VMConfig,
	clusterName string,
	clusterParams string,
	prune bool,
) (string, error)

Only render cluster params (_cluster), without components.

func JsonnetRenderFiles

func JsonnetRenderFiles(
	vmConfig types.VMConfig,
	files []string,
	param string,
	prune bool,
	prepend string,
	source string,
) (string, error)

Takes a list of jsonnet files and imports each one. Formats the string for jsonnet using "+".

func JsonnetVM

func JsonnetVM(vmconfig types.VMConfig) (*jsonnet.VM, error)

Create a Jsonnet VM to run commands in.

func MergeComponentDefaults

func MergeComponentDefaults(
	componentMap map[string]kr8_types.Kr8ClusterComponentRef,
	componentNames []string,
	vmconfig types.VMConfig,
) (string, error)

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 file string into kubernetes resources using kompose. Files in the directory must be in the format `[docker-]compose.ym[a]l`.

Source: https://github.com/kubernetes/kompose/blob/main/cmd/convert.go

Inputs: `inFile`, `outPath`, `opts`.

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 stdlib: https://jsonnet.org/ref/stdlib.html

Types

type IPV4

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)

type IPV6

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)

type NativeFuncURL

type NativeFuncURL struct {
	Scheme string
	// encoded opaque data
	Opaque string
	// username information
	Username string
	// Whether the password field is set
	PasswordSet bool
	// password information
	Password string
	// host or host:port (see Hostname and Port methods)
	Host string
	// path (relative paths may omit leading slash)
	Path string
	// encoded path hint (see EscapedPath method)
	RawPath string
	// query values
	Query map[string]interface{}
	// encoded query values, without '?'
	RawQuery string
	// fragment for references, without '#'
	Fragment string
	// encoded fragment hint (see EscapedFragment method)
	RawFragment string
}

Contains the url information.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL