Documentation ¶
Overview ¶
Package yttlibrary implements the "Standard Library" of modules that are built-in to the ytt templating engine.
Index ¶
- Constants
- Variables
- func RegisterExt(mod *starlarkstruct.Module)
- type API
- type DataLoader
- type DataModule
- type IPAddrValue
- func (av *IPAddrValue) AsStarlarkValue() starlark.Value
- func (av *IPAddrValue) ConversionHint() string
- func (av *IPAddrValue) IsIPv4(thread *starlark.Thread, f *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- func (av *IPAddrValue) IsIPv6(thread *starlark.Thread, f *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- func (av *IPAddrValue) Type() string
- type IPNetValue
- type TemplateModule
- type URLUser
- type URLValue
- func (uv *URLValue) AsStarlarkValue() starlark.Value
- func (uv *URLValue) ConversionHint() string
- func (uv *URLValue) Hostname(thread *starlark.Thread, f *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- func (uv *URLValue) Type() string
- func (uv *URLValue) User() starlark.Value
- func (uv *URLValue) WithoutUser(thread *starlark.Thread, f *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
Constants ¶
const (
SemverRegex string = `^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)` +
`(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))` +
`?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$`
)
Variables ¶
var ( AssertAPI = starlark.StringDict{ "assert": &starlarkstruct.Module{ Name: "assert", Members: starlark.StringDict{ "equals": starlark.NewBuiltin("assert.equals", core.ErrWrapper(assertModule{}.Equals)), "fail": starlark.NewBuiltin("assert.fail", core.ErrWrapper(assertModule{}.Fail)), "try_to": starlark.NewBuiltin("assert.try_to", core.ErrWrapper(assertModule{}.TryTo)), }, }, } )
var ( Base64API = starlark.StringDict{ "base64": &starlarkstruct.Module{ Name: "base64", Members: starlark.StringDict{ "encode": starlark.NewBuiltin("base64.encode", core.ErrWrapper(base64Module{}.Encode)), "decode": starlark.NewBuiltin("base64.decode", core.ErrWrapper(base64Module{}.Decode)), }, }, } )
var ( // IPAPI describes the contents of "@ytt:ip" module of the ytt standard library. IPAPI = starlark.StringDict{ "ip": &starlarkstruct.Module{ Name: "ip", Members: starlark.StringDict{ "parse_addr": starlark.NewBuiltin("ip.parse_addr", core.ErrWrapper(ipModule{}.ParseAddr)), "parse_cidr": starlark.NewBuiltin("ip.parse_cidr", core.ErrWrapper(ipModule{}.ParseCIDR)), }, }, } )
var ( // JSONAPI contains the definition of the @ytt:json module JSONAPI = starlark.StringDict{ "json": &starlarkstruct.Module{ Name: "json", Members: starlark.StringDict{ "encode": starlark.NewBuiltin("json.encode", core.ErrWrapper(jsonModule{}.Encode)), "decode": starlark.NewBuiltin("json.decode", core.ErrWrapper(jsonModule{}.Decode)), }, }, } )
var ( MD5API = starlark.StringDict{ "md5": &starlarkstruct.Module{ Name: "md5", Members: starlark.StringDict{ "sum": starlark.NewBuiltin("md5.sum", core.ErrWrapper(md5Module{}.Sum)), }, }, } )
var ( ModuleAPI = starlark.StringDict{ "module": &starlarkstruct.Module{ Name: "module", Members: starlark.StringDict{ "make": starlark.NewBuiltin("module.make", core.ErrWrapper(starlarkstruct.MakeModule)), }, }, } )
var ( RegexpAPI = starlark.StringDict{ "regexp": &starlarkstruct.Module{ Name: "regexp", Members: starlark.StringDict{ "match": starlark.NewBuiltin("regexp.match", core.ErrWrapper(regexpModule{}.Match)), "replace": starlark.NewBuiltin("regexp.replace", core.ErrWrapper(regexpModule{}.Replace)), }, }, } )
var ( SHA256API = starlark.StringDict{ "sha256": &starlarkstruct.Module{ Name: "sha256", Members: starlark.StringDict{ "sum": starlark.NewBuiltin("sha256.sum", core.ErrWrapper(sha256Module{}.Sum)), }, }, } )
var ( StructAPI = starlark.StringDict{ "struct": &starlarkstruct.Module{ Name: "struct", Members: starlark.StringDict{ "make": starlark.NewBuiltin("struct.make", core.ErrWrapper(structModule{}.Make)), "make_and_bind": starlark.NewBuiltin("struct.make_and_bind", core.ErrWrapper(structModule{}.MakeAndBind)), "bind": starlark.NewBuiltin("struct.bind", core.ErrWrapper(structModule{}.Bind)), "encode": starlark.NewBuiltin("struct.encode", core.ErrWrapper(structModule{}.Encode)), "decode": starlark.NewBuiltin("struct.decode", core.ErrWrapper(structModule{}.Decode)), }, }, } )
var ( URLAPI = starlark.StringDict{ "url": &starlarkstruct.Module{ Name: "url", Members: starlark.StringDict{ "path_segment_encode": starlark.NewBuiltin("url.path_segment_encode", core.ErrWrapper(urlModule{}.PathSegmentEncode)), "path_segment_decode": starlark.NewBuiltin("url.path_segment_decode", core.ErrWrapper(urlModule{}.PathSegmentDecode)), "query_param_value_encode": starlark.NewBuiltin("url.query_param_value_encode", core.ErrWrapper(urlModule{}.QueryParamValueEncode)), "query_param_value_decode": starlark.NewBuiltin("url.query_param_value_decode", core.ErrWrapper(urlModule{}.QueryParamValueDecode)), "query_params_encode": starlark.NewBuiltin("url.query_params_encode", core.ErrWrapper(urlModule{}.QueryParamsEncode)), "query_params_decode": starlark.NewBuiltin("url.query_params_decode", core.ErrWrapper(urlModule{}.QueryParamsDecode)), "parse": starlark.NewBuiltin("url.parse", core.ErrWrapper(urlModule{}.ParseURL)), }, }, } )
var ( VersionAPI = starlark.StringDict{ "version": &starlarkstruct.Module{ Name: "version", Members: starlark.StringDict{ "require_at_least": starlark.NewBuiltin("version.require_at_least", core.ErrWrapper(versionModule{}.RequireAtLeast)), }, }, } )
var ( // YAMLAPI contains the definition of the @ytt:yaml module YAMLAPI = starlark.StringDict{ "yaml": &starlarkstruct.Module{ Name: "yaml", Members: starlark.StringDict{ "encode": starlark.NewBuiltin("yaml.encode", core.ErrWrapper(yamlModule{}.starlarkEncode)), "decode": starlark.NewBuiltin("yaml.decode", core.ErrWrapper(yamlModule{}.Decode)), }, }, } )
Functions ¶
func RegisterExt ¶ added in v0.41.0
func RegisterExt(mod *starlarkstruct.Module)
RegisterExt adds "mod" to the standard set of ytt library modules as an extension. An "extension" is a Starlark module that has external Go dependencies (as opposed to other Starlark modules in the ytt library that either have no dependencies or depend on the Go standard lib). This enables those using ytt as a Go module to opt-in (rather than be forced) to accept such dependencies. Only Carvel-maintained extensions can be registered; this reserves the `@ytt:` namespace. Integrators who want to write their own extensions should construct their own library.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
func NewAPI ¶
func NewAPI(replaceNodeFunc tplcore.StarlarkFunc, dataMod DataModule, libraryMod starlark.StringDict) API
func (API) FindModule ¶ added in v0.40.0
func (a API) FindModule(module string) (starlark.StringDict, error)
type DataLoader ¶ added in v0.40.0
type DataModule ¶ added in v0.40.0
type DataModule struct {
// contains filtered or unexported fields
}
func NewDataModule ¶
func NewDataModule(values *yamlmeta.Document, loader DataLoader) DataModule
func (DataModule) AsModule ¶ added in v0.40.0
func (b DataModule) AsModule() starlark.StringDict
type IPAddrValue ¶ added in v0.40.0
type IPAddrValue struct { *core.StarlarkStruct // TODO: keep authorship of the interface by delegating instead of embedding // contains filtered or unexported fields }
IPAddrValue stores a parsed IP
func (*IPAddrValue) AsStarlarkValue ¶ added in v0.40.0
func (av *IPAddrValue) AsStarlarkValue() starlark.Value
AsStarlarkValue converts this instance into a value suitable for use in a Starlark program.
func (*IPAddrValue) ConversionHint ¶ added in v0.40.0
func (av *IPAddrValue) ConversionHint() string
ConversionHint provides a hint on how the user can explicitly convert this value to a type that can be automatically encoded.
func (*IPAddrValue) IsIPv4 ¶ added in v0.40.0
func (av *IPAddrValue) IsIPv4(thread *starlark.Thread, f *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)
IsIPv4 is a core.StarlarkFunc that reveals whether this value is an IPv4 address.
func (*IPAddrValue) IsIPv6 ¶ added in v0.40.0
func (av *IPAddrValue) IsIPv6(thread *starlark.Thread, f *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)
IsIPv6 is a core.StarlarkFunc that reveals whether this value is an IPv6 address.
func (*IPAddrValue) Type ¶ added in v0.40.0
func (av *IPAddrValue) Type() string
Type reports the name of this type as seen from a Starlark program (i.e. via the `type()` built-in)
type IPNetValue ¶ added in v0.40.0
type IPNetValue struct { *core.StarlarkStruct // TODO: keep authorship of the interface by delegating instead of embedding // contains filtered or unexported fields }
IPNetValue holds the data for an instance of an IP Network value
func (*IPNetValue) Addr ¶ added in v0.40.0
func (inv *IPNetValue) Addr(thread *starlark.Thread, f *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)
Addr is a core.StarlarkFunc that returns the masked address portion of the network value
func (*IPNetValue) AsStarlarkValue ¶ added in v0.40.0
func (inv *IPNetValue) AsStarlarkValue() starlark.Value
AsStarlarkValue converts this instance into a value suitable for use in a Starlark program.
func (*IPNetValue) ConversionHint ¶ added in v0.40.0
func (inv *IPNetValue) ConversionHint() string
ConversionHint provides a hint on how the user can explicitly convert this value to a type that can be automatically encoded.
func (*IPNetValue) Type ¶ added in v0.40.0
func (inv *IPNetValue) Type() string
Type reports the name of this type as seen from a Starlark program (i.e. via the `type()` built-in)
type TemplateModule ¶ added in v0.40.0
type TemplateModule struct {
// contains filtered or unexported fields
}
func NewTemplateModule ¶
func NewTemplateModule(replaceNodeFunc core.StarlarkFunc) TemplateModule
func (TemplateModule) AsModule ¶ added in v0.40.0
func (b TemplateModule) AsModule() starlark.StringDict
type URLUser ¶ added in v0.40.0
type URLUser struct { *core.StarlarkStruct // TODO: keep authorship of the interface by delegating instead of embedding // contains filtered or unexported fields }
URLUser stores the user information
func (*URLUser) ConversionHint ¶ added in v0.40.0
type URLValue ¶ added in v0.40.0
type URLValue struct { *core.StarlarkStruct // TODO: keep authorship of the interface by delegating instead of embedding // contains filtered or unexported fields }
URLValue stores a parsed URL