Skip to content

Commit

Permalink
Tidy up assets class
Browse files Browse the repository at this point in the history
  • Loading branch information
samayer12 committed Jan 7, 2025
1 parent 90fa95d commit de44833
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/lib/assets/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export class Assets {
this.apiToken = crypto.randomBytes(32).toString("hex");
}

// TODO: Appears unused
setHash = (hash: string): void => {
this.hash = hash;
};
Expand All @@ -69,20 +68,15 @@ export class Assets {
allYaml = async (imagePullSecret?: string): Promise<string> => {
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),
Expand All @@ -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,
Expand Down

0 comments on commit de44833

Please sign in to comment.