-
Notifications
You must be signed in to change notification settings - Fork 112
Open
Labels
area/server-side-applySSA related issues and pull requestsSSA related issues and pull requestsenhancementNew feature or requestNew feature or request
Description
To make kustomize-controller compatible with VPA, HPA for custom resources and other controllers which mutate Flux-managed fields in-cluster, we need to wire the ssa/jsondiff logic into the SSA apply functions.
Tasks:
- Move the
saafunctions used injsondiffto a dedicated package - Add
[]jsondiff.IgnoreRuleto thessa.ApplyOptions - Remove the ignored fields before the final apply if they diverge
Example:
appliedObject := object.DeepCopy()
if existingObject.GetResourceVersion() != "" {
var sm = make(map[*jsondiff.SelectorRegex][]string, len(opts.DriftIgnoreRule))
for _, ips := range opts.DriftIgnoreRule {
sr, err := jsondiff.NewSelectorRegex(ips.Selector)
if err != nil {
return nil, fmt.Errorf("failed to create ignore rule selector: %w", err)
}
sm[sr] = ips.Paths
}
var ignorePaths jsondiff.IgnorePaths
for sr, paths := range sm {
if sr.MatchUnstructured(appliedObject) {
ignorePaths = append(ignorePaths, paths...)
}
}
if len(ignorePaths) > 0 {
patch := jsondiff.GenerateRemovePatch(ignorePaths...)
if err := jsondiff.ApplyPatchToUnstructured(appliedObject, patch); err != nil {
return nil, err
}
}
}
if err := m.apply(ctx, appliedObject); err != nil {
return nil, fmt.Errorf("%s apply failed: %w", FmtUnstructured(appliedObject), err)
}sdhibit, lictw, fadecore, matheuscscp and onedr0p
Metadata
Metadata
Assignees
Labels
area/server-side-applySSA related issues and pull requestsSSA related issues and pull requestsenhancementNew feature or requestNew feature or request