Skip to content

Commit c625585

Browse files
feat: values schema json
1 parent 802480b commit c625585

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/utils/workloadUtils.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ export class chartRepo {
207207
this.gitEmail = gitEmail
208208
this.git = simpleGit(this.localPath)
209209
}
210-
async clone() {
211-
await this.git.clone(this.chartRepoUrl, this.localPath)
210+
async clone(branch: string = 'main') {
211+
await this.git.clone(this.chartRepoUrl, this.localPath, ['--branch', branch, '--single-branch'])
212212
}
213213
async cloneSingleChart(refAndPath: string, finalDestinationPath: string) {
214214
const remoteResult = await this.git.listRemote([this.chartRepoUrl])
@@ -328,7 +328,8 @@ export async function fetchWorkloadCatalog(url: string, helmChartsDir: string, t
328328
gitUrl = `${protocol}://${encodedUser}:${encodedPassword}@${bareUrl}`
329329
}
330330
const gitRepo = new chartRepo(helmChartsDir, gitUrl)
331-
await gitRepo.clone()
331+
const branch = 'main'
332+
await gitRepo.clone(branch)
332333

333334
const files = await readdir(helmChartsDir, 'utf-8')
334335
const filesToExclude = ['.git', '.gitignore', '.vscode', 'LICENSE', 'README.md']
@@ -356,12 +357,15 @@ export async function fetchWorkloadCatalog(url: string, helmChartsDir: string, t
356357
}
357358
try {
358359
const values = await readFile(`${helmChartsDir}/${folder}/values.yaml`, 'utf-8')
359-
const c = await readFile(`${helmChartsDir}/${folder}/Chart.yaml`, 'utf-8')
360-
const chartMetadata = YAML.parse(c)
360+
// valuesSchema is optional, hence we add a catch at the end to mitigate a loop break out
361+
const valuesSchema = await readFile(`${helmChartsDir}/${folder}/values.schema.json`, 'utf-8').catch(() => null)
362+
const chart = await readFile(`${helmChartsDir}/${folder}/Chart.yaml`, 'utf-8')
363+
const chartMetadata = YAML.parse(chart)
361364
if (!rbac[folder] || rbac[folder].includes(`team-${teamId}`) || teamId === 'admin') {
362365
const catalogItem = {
363366
name: folder,
364367
values: values || '{}',
368+
valuesSchema: valuesSchema || '{}',
365369
icon: chartMetadata?.icon,
366370
chartVersion: chartMetadata?.version,
367371
chartDescription: chartMetadata?.description,

0 commit comments

Comments
 (0)