diff --git a/src/lib/assets/assets.ts b/src/lib/assets/assets.ts index 499655b27..120fd2b84 100644 --- a/src/lib/assets/assets.ts +++ b/src/lib/assets/assets.ts @@ -52,7 +52,6 @@ export class Assets { this.apiToken = crypto.randomBytes(32).toString("hex"); } - // TODO: Appears unused setHash = (hash: string): void => { this.hash = hash; }; @@ -69,20 +68,15 @@ export class Assets { allYaml = async (imagePullSecret?: string): Promise => { this.capabilities = await loadCapabilities(this.path); // give error if namespaces are not respected - for (const capability of this.capabilities) { - namespaceComplianceValidator(capability, this.alwaysIgnore?.namespaces); - } + this.capabilities.forEach(capability => namespaceComplianceValidator(capability, this.alwaysIgnore?.namespaces)); + + const code = await fs.readFile(this.path); const webhooks = { mutate: await webhookConfig(this, "mutate", this.config.webhookTimeout), validate: await webhookConfig(this, "validate", this.config.webhookTimeout), }; - const code = await fs.readFile(this.path); - - // Generate a hash of the code - this.hash = crypto.createHash("sha256").update(code).digest("hex"); - const deployments = { default: getDeployment(this, this.hash, this.buildTimestamp, imagePullSecret), watch: getWatcher(this, this.hash, this.buildTimestamp, imagePullSecret), @@ -92,7 +86,7 @@ export class Assets { apiToken: this.apiToken, capabilities: this.capabilities, config: this.config, - hash: this.hash, + hash: crypto.createHash("sha256").update(code).digest("hex"), name: this.name, path: this.path, tls: this.tls,