This repository has been archived by the owner on Jul 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(poller): lodash template preprocess for externalsecret.spec.temp…
…late field (#626)
- Loading branch information
Showing
9 changed files
with
369 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,4 +60,5 @@ typings/ | |
# e2e test stuff | ||
e2e/**/.kubeconfig | ||
|
||
# IDE | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: 'kubernetes-client.io/v1' | ||
kind: ExternalSecret | ||
metadata: | ||
name: hello-service | ||
spec: | ||
backendType: vault | ||
vaultMountPoint: my-kubernetes-vault-mount-point | ||
vaultRole: my-vault-role | ||
kvVersion: 2 | ||
data: | ||
- key: kv/data/test/secret1 | ||
name: s1 | ||
- key: kv/data/test/secret2 | ||
name: s2 | ||
template: | ||
metadata: | ||
labels: | ||
world: <% let content = JSON.parse(data.s1) %><%= content.f2.f22 %> | ||
stringData: | ||
file.yaml: | | ||
<%= yaml.dump(JSON.parse(data.s1)) %> | ||
<% let s2 = JSON.parse(data.s2) %><% s2.arr.forEach((e, i) => { %>arr_<%= i %>: <%= e %> | ||
<% }) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const yaml = require('js-yaml') | ||
const parseTemplate = require('lodash.template') | ||
const mapValues = require('lodash.mapvalues') | ||
|
||
const compileTemplate = (template, data) => parseTemplate(template, { imports: { yaml }, variable: 'data' })(data) | ||
|
||
const compileObjectTemplateKeys = (object, data) => { | ||
return mapValues(object, (value) => { | ||
if (value) { | ||
const valueType = typeof value | ||
|
||
if (valueType === 'string') { | ||
return compileTemplate(value, data) | ||
} else if (valueType === 'object' && !Array.isArray(value)) { | ||
return compileObjectTemplateKeys(value, data) | ||
} | ||
} | ||
|
||
return value | ||
}) | ||
} | ||
|
||
module.exports = { | ||
compileTemplate, | ||
compileObjectTemplateKeys | ||
} |
Oops, something went wrong.