-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
77 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import fs from 'node:fs/promises'; | ||
import { join } from 'node:path'; | ||
import { execa } from 'execa'; | ||
import { inject, injectable } from 'inversify'; | ||
import { InstallToolBaseService } from '../install-tool/install-tool-base.service'; | ||
import { | ||
CompressionService, | ||
EnvService, | ||
HttpService, | ||
PathService, | ||
} from '../services'; | ||
|
||
@injectable() | ||
export class SkopeoInstallService extends InstallToolBaseService { | ||
readonly name = 'skopeo'; | ||
|
||
private get ghArch(): string { | ||
switch (this.envSvc.arch) { | ||
case 'arm64': | ||
return 'aarch64'; | ||
case 'amd64': | ||
return 'x86_64'; | ||
} | ||
} | ||
|
||
constructor( | ||
@inject(EnvService) envSvc: EnvService, | ||
@inject(PathService) pathSvc: PathService, | ||
@inject(HttpService) private http: HttpService, | ||
@inject(CompressionService) private compress: CompressionService, | ||
) { | ||
super(pathSvc, envSvc); | ||
} | ||
|
||
override async install(version: string): Promise<void> { | ||
const name = this.name; | ||
const filename = `${name}-${version}-${this.ghArch}.tar.xz`; | ||
const url = `https://github.com/containerbase/${name}-prebuild/releases/download/${version}/${filename}`; | ||
const checksumFileUrl = `${url}.sha512`; | ||
|
||
const checksumFile = await this.http.download({ url: checksumFileUrl }); | ||
const expectedChecksum = (await fs.readFile(checksumFile, 'utf-8')).trim(); | ||
const file = await this.http.download({ | ||
url, | ||
checksumType: 'sha512', | ||
expectedChecksum, | ||
}); | ||
await this.compress.extract({ file, cwd: await this.getToolPath() }); | ||
} | ||
|
||
override async link(version: string): Promise<void> { | ||
const src = join(this.pathSvc.versionedToolPath(this.name, version), 'bin'); | ||
await this.shellwrapper({ srcDir: src }); | ||
} | ||
|
||
override async test(_version: string): Promise<void> { | ||
await execa('skopeo', ['--version'], { | ||
stdio: ['inherit', 'inherit', 1], | ||
}); | ||
} | ||
|
||
private async getToolPath(): Promise<string> { | ||
return await this.pathSvc.ensureToolPath(this.name); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters