Skip to content

Commit 4bf2b47

Browse files
dhaiducekopenshift-merge-bot[bot]
authored andcommitted
Implement kustomizeOptions
Allows passing flags equivalent to `--enable-helm` via the environment variable `POLICY_GEN_ENABLE_HELM` ref: https://issues.redhat.com/browse/ACM-9060 Signed-off-by: Dale Haiducek <[email protected]>
1 parent cea7921 commit 4bf2b47

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ make build
102102
kustomize build --enable-alpha-plugins
103103
```
104104

105+
**NOTE:** To enable Helm processing when passing a Kustomize directory into the generator, set
106+
the environment variable `POLICY_GEN_ENABLE_HELM` to `"true"`.
107+
105108
### As a standalone binary
106109

107110
In order to bypass Kustomize and run the generator binary directly, change to the directory of PolicyGenerator
@@ -119,7 +122,10 @@ cd examples
119122
../PolicyGenerator policyGenerator.yaml
120123
```
121124

122-
**NOTE:** To print the trace in the case of an error, you can add the `--debug` flag to the arguments.
125+
**NOTE:**
126+
- To print the trace in the case of an error, you can add the `--debug` flag to the arguments.
127+
- To enable Helm processing when passing a Kustomize directory into the generator, set
128+
the environment variable `POLICY_GEN_ENABLE_HELM` to `"true"`.
123129

124130
## Additional Policy Generator references
125131

internal/utils.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,14 @@ func setNamespaceSelector(
360360

361361
// processKustomizeDir runs a provided directory through Kustomize in order to generate the manifests within it.
362362
func processKustomizeDir(path string) ([]map[string]interface{}, error) {
363-
k := krusty.MakeKustomizer(krusty.MakeDefaultOptions())
363+
kustomizeOpts := krusty.MakeDefaultOptions()
364+
365+
if os.Getenv("POLICY_GEN_ENABLE_HELM") == "true" {
366+
kustomizeOpts.PluginConfig.HelmConfig.Enabled = true
367+
kustomizeOpts.PluginConfig.HelmConfig.Command = "helm"
368+
}
369+
370+
k := krusty.MakeKustomizer(kustomizeOpts)
364371

365372
resourceMap, err := k.Run(filesys.MakeFsOnDisk(), path)
366373
if err != nil {

0 commit comments

Comments
 (0)