Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/otomi-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import {
getValuesSchema,
removeBlankAttributes,
} from 'src/utils'
import { deepQuote } from 'src/utils/yamlUtils'
import {
cleanEnv,
CUSTOM_ROOT_CA,
Expand Down Expand Up @@ -1853,9 +1854,11 @@ export default class OtomiStack {
}

async editWorkloadValues(teamId: string, name: string, data: WorkloadValues): Promise<WorkloadValues> {
const workload = this.repoService
.getTeamConfigService(teamId)
.patchWorkload(name, { spec: { values: stringifyYaml(data.values) } })
const workload = this.repoService.getTeamConfigService(teamId).patchWorkload(name, {
spec: {
values: stringifyYaml(deepQuote(data.values)),
},
})
await this.saveTeamWorkloadValues(workload)
await this.doTeamDeployment(
teamId,
Expand Down
18 changes: 18 additions & 0 deletions src/utils/yamlUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import YAML from 'yaml'

export function quoteIfDangerous(value: unknown) {
if (typeof value === 'string' && ['yes', 'no', 'on', 'off'].includes(value.toLowerCase())) {
const scalar = new YAML.Scalar(value)
scalar.type = YAML.Scalar.QUOTE_DOUBLE
return scalar
}
return value
}

export function deepQuote(obj: any): any {
if (Array.isArray(obj)) return obj.map(deepQuote)
if (obj && typeof obj === 'object') {
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, deepQuote(v)]))
}
return quoteIfDangerous(obj)
}
Loading