Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mapper ¶
type Mapper struct {
CompiledMappingRules []compiledMappingRule
}
Mapper is a collection of compiledMappingRules.
func NewMapper ¶
func NewMapper(rules []MappingRule) (*Mapper, error)
type MappingRule ¶
type MappingRule struct {
// merge controls how the rule's result combines with a value already at
// targetPropPath. Accumulate (the default when empty): when both the
// existing value and the result are lists, the result is the existing list
// followed by the result's items not already present (order-preserving
// set-union), so restating self.<target> is harmless and idempotent.
// Values already at that path in the input — including claims asserted by
// an identity provider — therefore stay in the output. Any other shape
// pair (scalar, map, list vs non-list) replaces. Replace: the result
// always replaces. Use it for any rule meant to filter, transform,
// normalise or override a list already at its own target (e.g. a rule
// that reads self.groups and writes groups).
// +kubebuilder:validation:Optional
// +kubebuilder:validation:Enum=Accumulate;Replace
Merge MergeStrategy `json:"merge,omitempty"`
// required indicates that if the rule fails to produce a value the rule
// will be skipped. Otherwise the execution should fail.
// +kubebuilder:validation:Optional
// +kubebuilder:default:=false
Required bool `json:"required"`
// sourceExpression is CEL program to compute a transformation of input into
// a new form.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=2
// +kubebuilder:example:=`self.oidc.groups.filter(g, g.startsWith('app_')).join(',')`
SourceExpression string `json:"sourceExpression"`
// targetPropPath is a dot-separated property path for where the result
// should be attached in the output.
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=2
// +kubebuilder:example:=`auth.internal_groups`
TargetPropPath string `json:"targetPropPath"`
}
MappingRule defines a transformation rule for mapping arbitrary data from an input to an output.
type MergeStrategy ¶ added in v0.2.0
type MergeStrategy string
MergeStrategy controls how a rule's result combines with a value already present at its targetPropPath.
const ( // MergeAccumulate (the default when empty): when both the existing value // and the result are lists, the result is the existing list followed by // the result's items not already present. Any other shape pair replaces. MergeAccumulate MergeStrategy = "Accumulate" // MergeReplace: the result always replaces the existing value. Use it for // a rule that filters, transforms, normalises or overrides a list already // at its own target. MergeReplace MergeStrategy = "Replace" )