Documentation ¶
Overview ¶
Package ns provides a way to map entities from one namespace into another. The key idea here is that we can reduce the operator's privilege by only granting it privileges in a separate namespace which is not the same as where the operator's custom resources are created.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NamespaceMapper ¶
type NamespaceMapper interface { // DestName returns the destination name of a given namespace/name. DestName(srcNS, srcName string) string // DestNamespace returns the destination namespace for a given namespace. DestNamespace(srcNS string) string }
NamespaceMapper maps an entity namespace/name to another namespace/name.
func NewNSPrefixMapper ¶
func NewNSPrefixMapper(nsPrefix string) NamespaceMapper
NewNSPrefixMapper returns a NamespaceMapper that redirects all entities to another namespace with the specified prefix. The entity name doesn't change. The destination namespace may have a prefix-hash appended at the end for long names (with truncation). Examples, for namespace prefix "pre" { ns: "a", "name: "b" } -> { ns: "pre-a", name: "b" } { ns: "", name: "c" } -> { ns: "pre", name: "c" } { ns: "long-name", name: "c" } -> { ns: "pre-long-clipped-hash", name: "c" }
func NewPrefixSwappingNSMapper ¶
func NewPrefixSwappingNSMapper(oldPrefix, newPrefix string) NamespaceMapper
NewPrefixSwappingNSMapper returns a NamespaceMapper that replaces the old prefix of a namespace with a new prefix. If the namespace does not have the old prefix, a new prefix will be added in front of the namespace. The entity name doesn't change. The destination namespace may have a prefix-hash appended at the end for long names (with truncation) Examples, for an old prefix "g-" and a new prefix "gs-ods-" { ns: "g-a", "name: "b" } -> { ns: "gs-ods-a", name: "b" } { ns: "g-g-a", name: "c" } -> { ns: "gs-ods-g-a", name: "c" } { ns: "a, name: "c" } -> { ns: "gs-ods-a", name: "c" }
func NewRedirectMapper ¶
func NewRedirectMapper(destNS string) NamespaceMapper
NewRedirectMapper returns a NamespaceMapper that redirects all entities to one select target namespace. To avoid collision of the same name from different namespaces, the mapper prefixes the source-namespace and appends a hash. Long names may get truncated. Examples: destNs: "target" { ns: "a", "name: "b" } -> { ns: "target", name: "a-b-hash" } { ns: "", name: "c" } -> { ns: "target", name: "c-hash" }
func NewSameMapper ¶
func NewSameMapper() NamespaceMapper
NewSameMapper returns a NamespaceMapper that maps to the same namespace/name.