Skip to content

Commit 8803dc0

Browse files
dgolovinvrothbergbenoitf
authored
fix: create facts file in vm to support multi-arch builds (redhat-developer#105)
Signed-off-by: Denis Golovin <[email protected]> Co-authored-by: Valentin Rothberg <[email protected]> Co-authored-by: benoitf <[email protected]>
1 parent 5761f91 commit 8803dc0

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/extension.ts

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
runSubscriptionManagerActivationStatus,
3131
runSubscriptionManagerRegister,
3232
runSubscriptionManagerUnregister,
33+
runCreateFactsFile,
3334
} from './podman-cli';
3435
import { SubscriptionManagerClient } from '@redhat-developer/rhsm-client';
3536
import { isLinux } from './util';
@@ -343,6 +344,10 @@ export async function activate(context: extensionApi.ExtensionContext): Promise<
343344
await restartPodmanVM();
344345
}
345346
if (!(await isPodmanVmSubscriptionActivated())) {
347+
const facts = {
348+
supported_architectures: 'aarch64,x86_64',
349+
};
350+
await runCreateFactsFile(JSON.stringify(facts, undefined, 2));
346351
await createOrReuseActivationKey();
347352
}
348353
}

src/podman-cli.ts

+16
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ const PODMAN_COMMANDS = {
3131
SM_DEACTIVATE_SUBS: () => `machine ssh sudo subscription-manager unregister`.split(' '),
3232
MACHINE_STOP: () => 'machine stop'.split(' '),
3333
MACHINE_START: () => 'machine start'.split(' '),
34+
CREATE_FACTS_FILE: (oneLineJson: string) => [
35+
'machine',
36+
'ssh',
37+
`sudo mkdir -p /etc/rhsm/facts/ && printf '${oneLineJson}\\n' | sudo tee /etc/rhsm/facts/podman-desktop-redhat-account-ext.facts`,
38+
],
3439
};
3540

3641
export function getInstallationPath(): string | undefined {
@@ -132,6 +137,17 @@ export async function runSubscriptionManagerUnregister(): Promise<number | undef
132137
}
133138
}
134139

140+
export async function runCreateFactsFile(jsonText: string): Promise<number> {
141+
try {
142+
await extensionApi.process.exec(getPodmanCli(), PODMAN_COMMANDS.CREATE_FACTS_FILE(jsonText.replace('\n', '\\n')));
143+
return 0;
144+
} catch (err) {
145+
const exitCode = (err as extensionApi.RunError).exitCode;
146+
console.error(`Writing /etc/rhsm/facts/podman-desktop-redhat-account-ext.facts returned exit code: ${exitCode}`);
147+
return exitCode;
148+
}
149+
}
150+
135151
export async function restartPodmanMachine() {
136152
await extensionApi.process.exec(getPodmanCli(), PODMAN_COMMANDS.MACHINE_STOP());
137153
await extensionApi.process.exec(getPodmanCli(), PODMAN_COMMANDS.MACHINE_START());

0 commit comments

Comments
 (0)