From 99f5de04cb45d8bb58894c2c82eaf8d6e88aa2f5 Mon Sep 17 00:00:00 2001 From: Ludovic Cleroux Date: Tue, 4 Jul 2023 10:58:17 +0200 Subject: [PATCH] Update README.md --- README.md | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 0ee4153..ff38c0c 100644 --- a/README.md +++ b/README.md @@ -64,36 +64,42 @@ type K8sObjectOverlayPatch struct { ```go package reconciler +import ( + "github.com/stackrox/k8s-overlay-patch/pkg/patch" + "github.com/stackrox/k8s-overlay-patch/pkg/types" +) + func (r reconciler) Reconcile(obj v1alpha1.MyObject){ manifests := renderManifests(obj) patched := patch.YAMLManifestPatch(manifests, obj.Namespace, mapOverlays(obj.Spec.Overlays)) // ... } -func mapOverlays(overlays []v1alpha1.K8sObjectOverlay) []patch.K8sObjectOverlay { - out := make([]patch.K8sObjectOverlay, len(overlays)) - for i, o := range overlays { - out[i] = patch.K8sObjectOverlay{ - ApiVersion: o.ApiVersion, - Kind: o.Kind, - Name: o.Name, - Patches: mapOverlayPatches(o.Patches), - } - } - return out +func mapOverlays(overlays []*v1alpha1.K8sObjectOverlay) []*types.K8sObjectOverlay { + out := make([]*types.K8sObjectOverlay, len(overlays)) + for i, o := range overlays { + out[i] = &types.K8sObjectOverlay{ + ApiVersion: o.ApiVersion, + Kind: o.Kind, + Name: o.Name, + Patches: mapOverlayPatches(o.Patches), + } + } + return out } -func mapOverlayPatches(patches []v1alpha1.K8sObjectOverlayPatch) []patch.K8sObjectOverlayPatch { - out := make([]patch.K8sObjectOverlayPatch, len(patches)) - for i, p := range patches { - out[i] = patch.K8sObjectOverlayPatch{ - Path: p.Path, - Value: p.Value, - } - } - return out +func mapOverlayPatches(patches []*v1alpha1.K8sObjectOverlayPatch) []*types.K8sObjectOverlayPatch { + out := make([]*types.K8sObjectOverlayPatch, len(patches)) + for i, p := range patches { + out[i] = &types.K8sObjectOverlayPatch{ + Path: p.Path, + Value: p.Value, + } + } + return out } + ``` #### Example CRD