mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix type error
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
f9ab64da37
commit
9420c408d0
@ -121,30 +121,32 @@ export class ResourceStack {
|
|||||||
for(const filename of files) {
|
for(const filename of files) {
|
||||||
const file = path.join(folderPath, filename);
|
const file = path.join(folderPath, filename);
|
||||||
const raw = await fse.readFile(file);
|
const raw = await fse.readFile(file);
|
||||||
let resourceData: string;
|
const data = (
|
||||||
|
filename.endsWith(".hb")
|
||||||
|
? hb.compile(raw.toString())(templateContext)
|
||||||
|
: raw.toString()
|
||||||
|
).trim();
|
||||||
|
|
||||||
if (filename.endsWith(".hb")) {
|
if (!data) {
|
||||||
const template = hb.compile(raw.toString());
|
continue;
|
||||||
|
|
||||||
resourceData = template(templateContext);
|
|
||||||
} else {
|
|
||||||
resourceData = raw.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resourceData.trim()) continue;
|
for (const entry of yaml.loadAll(data)) {
|
||||||
|
if (typeof entry !== "object" || !entry) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const resourceArray = yaml.loadAll(resourceData.toString());
|
const resource = entry as Record<string, any>;
|
||||||
|
|
||||||
resourceArray.forEach((resource) => {
|
if (typeof resource.metadata === "object") {
|
||||||
if (resource?.metadata) {
|
resource.metadata.labels ??= {};
|
||||||
resource.metadata.labels ||= {};
|
|
||||||
resource.metadata.labels["app.kubernetes.io/name"] = this.name;
|
resource.metadata.labels["app.kubernetes.io/name"] = this.name;
|
||||||
resource.metadata.labels["app.kubernetes.io/managed-by"] = productName;
|
resource.metadata.labels["app.kubernetes.io/managed-by"] = productName;
|
||||||
resource.metadata.labels["app.kubernetes.io/created-by"] = "resource-stack";
|
resource.metadata.labels["app.kubernetes.io/created-by"] = "resource-stack";
|
||||||
}
|
}
|
||||||
|
|
||||||
resources.push(yaml.dump(resource));
|
resources.push(yaml.dump(resource));
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return resources;
|
return resources;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user