Repository navigation
Expand file tree
/
Copy pathhelm.ts
More file actions
47 lines (42 loc) · 1.47 KB
/
Copy pathhelm.ts
File metadata and controls
47 lines (42 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import path from 'node:path';
import { injectFromHierarchy, injectable } from 'inversify';
import { BaseInstallService } from '../install-tool/base-install.service.ts';
@injectable()
@injectFromHierarchy()
export class HelmInstallService extends BaseInstallService {
readonly name = 'helm';
/**
* Downloads the helm archive from get.helm.sh, verified against its
* `.sha256sum`, and extracts it into the versioned `bin` folder.
*/
override async install(version: string): Promise<void> {
const name = this.name;
const filename = `${name}-v${version}-linux-${this.envSvc.arch}.tar.gz`;
const url = `https://get.helm.sh/${filename}`;
const expectedChecksum = await this.getChecksum(`${url}.sha256sum`);
const file = await this.http.download({
url,
checksumType: 'sha256',
expectedChecksum,
});
await this.pathSvc.ensureToolPath(this.name);
const cwd = await this.pathSvc.createVersionedToolPath(
this.name,
version,
'bin',
);
await this.compress.extract({ file, cwd, strip: 1 });
}
/** Links the `helm` binary into the global bin folder. */
override async link(version: string): Promise<void> {
const src = path.join(
this.pathSvc.versionedToolPath(this.name, version),
'bin',
);
await this.shellwrapper({ srcDir: src });
}
/** Checks that `helm version` runs. */
override async test(_version: string): Promise<void> {
await this._spawn(this.name, ['version']);
}
}