Skip to content

Commit

Permalink
fix: extract secrets path bug fixed (#506)
Browse files Browse the repository at this point in the history
* fix: extract secrets path bug fixed

* fix: linter

Co-authored-by: Jehoszafat Zimnowoda <jehoszafat.zimnowoda@redkubes.com>
  • Loading branch information
mojtabaimani and j-zimnowoda committed Aug 10, 2021
1 parent 3221510 commit e93c137
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/cmd/lib/chart.ts
Expand Up @@ -8,17 +8,19 @@ import { loadYaml, terminal } from '../../common/utils'

const debug = terminal('chart')
let hasSops = false
const extractSecrets = (schema: any, parentAddress?: string): Array<string> => {
export const extractSecrets = (schema: any, parentAddress?: string): Array<string> => {
const schemaKeywords = ['properties', 'anyOf', 'allOf', 'oneOf']

return Object.keys(schema)
.flatMap((key) => {
const childObj = schema[key]
if (typeof childObj !== 'object') return false
if ('x-secret' in childObj) return parentAddress ? `${parentAddress}.${key}` : key
let address = `${parentAddress}.${key}`
if (parentAddress === undefined) address = key
else if (schemaKeywords.includes(key) || !Number.isNaN(Number(key))) address = parentAddress
let address
if (parentAddress === undefined) {
address = schemaKeywords.includes(key) ? undefined : key
} else if (schemaKeywords.includes(key) || !Number.isNaN(Number(key))) address = parentAddress
else address = `${parentAddress}.${key}`
return extractSecrets(childObj, address)
})
.filter(Boolean)
Expand Down

0 comments on commit e93c137

Please sign in to comment.