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 all 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 @@ -578,3 +578,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/download/0.3.2/wally-0.3.2-jammy-x86_x64.tar.xz.sha512
https://github.com/containerbase/wally-prebuild/releases/download/0.3.2/wally-0.3.2-jammy-x86_x64.tar.xz
```
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
76 changes: 76 additions & 0 deletions src/cli/tools/wally.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
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, logger } 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();
let code = distro.versionCode;

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L37 - L39 were not covered by tests

if (code === 'noble') {
logger.debug(`Using jammy prebuild for ${name} on ${code}`);
code = 'jammy';
}
const filename = `${name}-${version}-${code}-${this.ghArch}.tar.xz`;
const url = `https://github.com/containerbase/${name}-prebuild/releases/download/${version}/${filename}`;
const checksumFileUrl = `${url}.sha512`;

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

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L41 - L47 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 50 in src/cli/tools/wally.ts

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L49 - L50 were not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

src/cli/tools/wally.ts#L52-L56

Added lines #L52 - L56 were not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

src/cli/tools/wally.ts#L58

Added line #L58 was not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

src/cli/tools/wally.ts#L60-L61

Added lines #L60 - L61 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 69 in src/cli/tools/wally.ts

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L64 - L69 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 75 in src/cli/tools/wally.ts

View check run for this annotation

Codecov / codecov/patch

src/cli/tools/wally.ts#L72-L75

Added lines #L72 - L75 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
3 changes: 3 additions & 0 deletions test/latest/Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ RUN install-tool skopeo 1.17.0
# renovate: datasource=github-releases packageName=getsops/sops
RUN install-tool sops v3.9.2

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

#--------------------------------------
# Image: final
#--------------------------------------
Expand Down
Loading