Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Wally #2249

Merged
merged 16 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/custom-registries.md
Original file line number Diff line number Diff line change
Expand Up @@ -583,3 +583,16 @@ Samples:
```txt
https://github.com/vmware-tanzu/carvel-vendir/releases/download/v0.22.0/vendir-linux-amd64
```

## `wally`

Wally releases are downloaded from:

- `https://github.com/containerbase/wally-prebuild/releases`

Samples:

```txt
https://github.com/containerbase/wally-prebuild/releases/0.3.2/wally-0.3.2-jammy-x86_x64.tar.xz.sha512
https://github.com/containerbase/wally-prebuild/releases/0.3.2/wally-0.3.2-jammy-x86_x64.tar.xz
viceice marked this conversation as resolved.
Show resolved Hide resolved
```
6 changes: 4 additions & 2 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
"sops",
"swift",
"uv",
"vendir"
"vendir",
"wally"
],
"separateMinorPatch": false
},
Expand Down Expand Up @@ -129,7 +130,8 @@
"sops",
"swift",
"uv",
"vendir"
"vendir",
"wally"
],
"matchUpdateTypes": ["minor", "patch"],
"automerge": true
Expand Down
2 changes: 2 additions & 0 deletions src/cli/install-tool/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {
} from '../tools/ruby/utils';
import { SkopeoInstallService } from '../tools/skopeo';
import { SopsInstallService } from '../tools/sops';
import { WallyInstallService } from '../tools/wally';
import { logger } from '../utils';
import { LegacyToolInstallService } from './install-legacy-tool.service';
import { INSTALL_TOOL_TOKEN, InstallToolService } from './install-tool.service';
Expand Down Expand Up @@ -106,6 +107,7 @@ function prepareInstallContainer(): Container {
container.bind(INSTALL_TOOL_TOKEN).to(RenovateInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(SkopeoInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(SopsInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(WallyInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(YarnInstallService);
container.bind(INSTALL_TOOL_TOKEN).to(YarnSlimInstallService);

Expand Down
1 change: 1 addition & 0 deletions src/cli/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const NoPrepareTools = [
'skopeo',
'sops',
'uv',
'wally',
'yarn',
'yarn-slim',
];
Expand Down
70 changes: 70 additions & 0 deletions src/cli/tools/wally.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import fs from 'node:fs/promises';
import path from 'node:path';
import { execa } from 'execa';
import { inject, injectable } from 'inversify';
import { BaseInstallService } from '../install-tool/base-install.service';
import {
CompressionService,
EnvService,
HttpService,
PathService,
} from '../services';
import { getDistro } from '../utils';

@injectable()
export class WallyInstallService extends BaseInstallService {
readonly name = 'wally';

private get ghArch(): string {
switch (this.envSvc.arch) {
case 'arm64':
return 'aarch64';
case 'amd64':
return 'x86_64';
}
}

Check warning on line 25 in src/cli/tools/wally.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/tools/wally.ts#L19-L25

Added lines #L19 - L25 were not covered by tests

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 distro = await getDistro();
const filename = `${name}-${version}-${distro.versionCode}-${this.ghArch}.tar.xz`;
const url = `https://github.com/containerbase/${name}-prebuild/releases/download/${version}/${filename}`;
const checksumFileUrl = `${url}.sha512`;

Check warning on line 41 in src/cli/tools/wally.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/tools/wally.ts#L37-L41

Added lines #L37 - L41 were not covered by tests

const checksumFile = await this.http.download({ url: checksumFileUrl });
const expectedChecksum = (await fs.readFile(checksumFile, 'utf-8')).trim();

Check warning on line 44 in src/cli/tools/wally.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/tools/wally.ts#L43-L44

Added lines #L43 - L44 were not covered by tests

const file = await this.http.download({
url,
checksumType: 'sha512',
expectedChecksum,
});

Check warning on line 50 in src/cli/tools/wally.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/tools/wally.ts#L46-L50

Added lines #L46 - L50 were not covered by tests

const cwd = await this.pathSvc.ensureToolPath(name);

Check warning on line 52 in src/cli/tools/wally.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/tools/wally.ts#L52

Added line #L52 was not covered by tests

await this.compress.extract({ file, cwd });
}

Check warning on line 55 in src/cli/tools/wally.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/tools/wally.ts#L54-L55

Added lines #L54 - L55 were not covered by tests

override async link(version: string): Promise<void> {
const src = path.join(
this.pathSvc.versionedToolPath(this.name, version),
'bin',
);
await this.shellwrapper({ srcDir: src });
}

Check warning on line 63 in src/cli/tools/wally.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/tools/wally.ts#L58-L63

Added lines #L58 - L63 were not covered by tests

override async test(_version: string): Promise<void> {
await execa(this.name, ['--version'], {
stdio: ['inherit', 'inherit', 1],
});
}

Check warning on line 69 in src/cli/tools/wally.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/tools/wally.ts#L66-L69

Added lines #L66 - L69 were not covered by tests
}
3 changes: 3 additions & 0 deletions test/Dockerfile.distro
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ RUN install-tool jb v0.6.0
# renovate: datasource=github-releases packageName=vmware-tanzu/carvel-vendir
RUN install-tool vendir v0.43.0

# renovate: datasource=github-releases packageName=containerbase/wally-prebuild
RUN install-tool wally 0.3.2

#--------------------------------------
# Image: test-erlang
#--------------------------------------
Expand Down
Loading