Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ludydoo committed Jul 4, 2023
1 parent 4f1782f commit 99f5de0
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 99f5de0

Please sign in to comment.