containers
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package containers defines types and functions for resolving qualified names within a namespaceor type provided to CEL.
Index¶
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
Types¶
typeContainer¶
type Container struct {// contains filtered or unexported fields}Container holds a reference to an optional qualified container name and set of aliases.
The program container can be used to simplify variable, function, and type specification withinCEL programs and behaves more or less like a C++ namespace. See ResolveCandidateNames for moredetails.
funcNewContainer¶
func NewContainer(opts ...ContainerOption) (*Container,error)
NewContainer creates a new Container with the fully-qualified name.
func (*Container)AliasSet¶added inv0.24.0
AliasSet returns the alias to fully-qualified name mapping stored in the container.
func (*Container)Extend¶
func (c *Container) Extend(opts ...ContainerOption) (*Container,error)
Extend creates a new Container with the existing settings and applies a series ofContainerOptions to further configure the new container.
func (*Container)Name¶
Name returns the fully-qualified name of the container.
The name may conceptually be a namespace, package, or type.
func (*Container)ResolveCandidateNames¶
ResolveCandidateNames returns the candidates name of namespaced identifiers in C++ resolutionorder.
Names which shadow other names are returned first. If a name includes a leading dot ('.'),the name is treated as an absolute identifier which cannot be shadowed.
Given a container name a.b.c.M.N and a type name R.s, this will deliver in order:
a.b.c.M.N.R.sa.b.c.M.R.sa.b.c.R.sa.b.R.sa.R.sR.s
If aliases or abbreviations are configured for the container, then alias names will takeprecedence over containerized names.
typeContainerOption¶
ContainerOption specifies a functional configuration option for a Container.
Note, ContainerOption implementations must be able to handle nil container inputs.
funcAbbrevs¶
func Abbrevs(qualifiedNames ...string)ContainerOption
Abbrevs configures a set of simple names as abbreviations for fully-qualified names.
An abbreviation (abbrev for short) is a simple name that expands to a fully-qualified name.Abbreviations can be useful when working with variables, functions, and especially types frommultiple namespaces:
// CEL object constructionqual.pkg.version.ObjTypeName{ field: alt.container.ver.FieldTypeName{value: ...}}Only one the qualified names above may be used as the CEL container, so at least one of thesereferences must be a long qualified name within an otherwise short CEL program. Using thefollowing abbreviations, the program becomes much simpler:
// CEL Go optionAbbrevs("qual.pkg.version.ObjTypeName", "alt.container.ver.FieldTypeName")// Simplified Object constructionObjTypeName{field: FieldTypeName{value: ...}}There are a few rules for the qualified names and the simple abbreviations generated from them:- Qualified names must be dot-delimited, e.g. `package.subpkg.name`.- The last element in the qualified name is the abbreviation.- Abbreviations must not collide with each other.- The abbreviation must not collide with unqualified names in use.
Abbreviations are distinct from container-based references in the following important ways:
- Abbreviations must expand to a fully-qualified name.
- Expanded abbreviations do not participate in namespace resolution.
- Abbreviation expansion is done instead of the container search for a matching identifier.
- Containers follow C++ namespace resolution rules with searches from the most qualified nameto the least qualified name.
- Container references within the CEL program may be relative, and are resolved to fullyqualified names at either type-check time or program plan time, whichever comes first.
If there is ever a case where an identifier could be in both the container and as anabbreviation, the abbreviation wins as this will ensure that the meaning of a program ispreserved between compilations even as the container evolves.
funcAlias¶
func Alias(qualifiedName, aliasstring)ContainerOption
Alias associates a fully-qualified name with a user-defined alias.
In general, Abbrevs is preferred to Alias since the names generated from the Abbrevs optionare more easily traced back to source code. The Alias option is useful for propagating aliasconfiguration from one Container instance to another, and may also be useful for remappingpoorly chosen protobuf message / package names.
Note: all of the rules that apply to Abbrevs also apply to Alias.