@@ -28,7 +28,7 @@ import { getErrorMessage } from './utils';
28
28
const MACADAM_CLI_NAME = 'macadam' ;
29
29
const MACADAM_DISPLAY_NAME = 'Macadam' ;
30
30
const MACADAM_MARKDOWN = `Podman Desktop can help you run RHEL and other linux-based VM by using Macadam.\n\nMore information: Link to macadam here` ;
31
- const stopLoop = false ;
31
+ let stopLoop = false ;
32
32
33
33
type StatusHandler = ( name : string , event : extensionApi . ProviderConnectionStatus ) => void ;
34
34
const macadamMachinesInfo = new Map < string , MachineInfo > ( ) ;
@@ -117,12 +117,19 @@ async function getJSONMachineList(macadam: Macadam): Promise<MachineJSONListOutp
117
117
try {
118
118
const macadamCli = await macadam . getExecutable ( ) ;
119
119
const { stdout, stderr } = await extensionApi . process . exec ( macadamCli , [ 'list' ] ) ;
120
- list . push ( ...( JSON . parse ( stdout ) as MachineJSON [ ] ) ) ;
120
+ console . log ( stdout ) ;
121
+ if ( stdout !== '' ) {
122
+ console . log ( "stdout" ) ;
123
+ list . push ( ...( JSON . parse ( stdout ) as MachineJSON [ ] ) ) ;
124
+ }
121
125
error = stderr ;
122
126
} catch ( err ) {
123
127
error = getErrorMessage ( err ) ;
124
128
}
125
129
130
+ console . log ( list . length ) ;
131
+ console . log ( error ) ;
132
+
126
133
return { list, error } ;
127
134
}
128
135
@@ -186,7 +193,6 @@ async function registerProviderFor(
186
193
macadam : Macadam ,
187
194
provider : extensionApi . Provider ,
188
195
machineInfo : MachineInfo ,
189
- socketPath : string ,
190
196
context : extensionApi . ExtensionContext ,
191
197
) : Promise < void > {
192
198
const lifecycle : extensionApi . ProviderConnectionLifecycle = {
@@ -207,6 +213,8 @@ async function registerProviderFor(
207
213
const providerConnectionShellAccess = new ProviderConnectionShellAccessImpl ( machineInfo ) ;
208
214
context . subscriptions . push ( providerConnectionShellAccess ) ;
209
215
216
+ // we are not really working with a containerProviderConnection of type podman
217
+ // however it offers most of the things we would need, so it is good for a POC
210
218
const containerProviderConnection : extensionApi . ContainerProviderConnection = {
211
219
name : 'macadam' ,
212
220
displayName : 'Macadam' ,
@@ -215,14 +223,10 @@ async function registerProviderFor(
215
223
shellAccess : providerConnectionShellAccess ,
216
224
lifecycle,
217
225
endpoint : {
218
- socketPath,
226
+ socketPath : 'no-socket' ,
219
227
} ,
220
228
} ;
221
229
222
- // Since Podman 4.5, machines are using the same path for all sockets of machines
223
- // so a machine is not distinguishable from another one.
224
- // monitorPodmanSocket(socketPath, machineInfo.name);
225
-
226
230
const disposable = provider . registerContainerProviderConnection ( containerProviderConnection ) ;
227
231
provider . updateStatus ( 'ready' ) ;
228
232
@@ -246,6 +250,8 @@ async function updateMachines(
246
250
// init machines available
247
251
const machineListOutput = await getJSONMachineList ( macadam ) ;
248
252
253
+ console . log ( 'qui' ) ;
254
+
249
255
if ( machineListOutput . error ) {
250
256
// TODO handle the error
251
257
}
@@ -308,7 +314,6 @@ async function updateMachines(
308
314
macadam ,
309
315
provider ,
310
316
podmanMachineInfo ,
311
- '/var/folders/n4/n5hyrstd2739lcy9903jn8f40000gn/T/podman/macadam.sock' ,
312
317
context ,
313
318
) ;
314
319
}
@@ -434,72 +439,24 @@ async function createVM(
434
439
telemetryRecords . OS = 'mac' ;
435
440
}
436
441
437
- /* To be uncommented when init command will support these flags
438
- // cpu
439
- if (params['macadam.factory.machine.cpus']) {
440
- const cpusValue = params['macadam.factory.machine.cpus'];
441
- parameters.push('--cpus');
442
- parameters.push(cpusValue);
443
- telemetryRecords.cpus = cpusValue;
444
- }
445
-
446
- // memory
447
- if (params['macadam.factory.machine.memory']) {
448
- parameters.push('--memory');
449
- const memoryAsMiB = +params['macadam.factory.machine.memory'] / (1024 * 1024);
450
- // Hyper-V requires VMs to have memory in 2 MB increments. So we round it
451
- const roundedMemoryMiB = Math.floor((memoryAsMiB + 1) / 2) * 2;
452
- parameters.push(roundedMemoryMiB.toString());
453
- telemetryRecords.memory = params['macadam.factory.machine.memory'];
454
- }
455
-
456
- // disk size
457
- if (params['macadam.factory.machine.diskSize']) {
458
- parameters.push('--disk-size');
459
- const diskAsGiB = +params['macadam.factory.machine.diskSize'] / (1024 * 1024 * 1024);
460
- parameters.push(Math.floor(diskAsGiB).toString());
461
- telemetryRecords.diskSize = params['macadam.factory.machine.diskSize'];
462
- }
463
- */
464
-
465
442
// image-path
466
443
const imagePath = params [ 'macadam.factory.machine.image-path' ] ;
467
444
if ( imagePath ) {
468
445
parameters . push ( imagePath ) ;
469
446
telemetryRecords . imagePath = 'custom' ;
470
447
}
471
448
449
+ // ssh identity path
450
+ const sshIdentityPath = params [ 'macadam.factory.machine.ssh-identity-path' ] ;
451
+ if ( sshIdentityPath ) {
452
+ parameters . push ( '--ssh-identity-path' ) ;
453
+ parameters . push ( sshIdentityPath ) ;
454
+ }
455
+
472
456
// push args for demo
473
- parameters . push ( '--ssh-identity-path' ) ;
474
- parameters . push ( path . join ( path . dirname ( imagePath ) , 'id_ed25519' ) ) ;
475
457
parameters . push ( '--username' ) ;
476
458
parameters . push ( 'core' ) ;
477
459
478
- /* else if (params['macadam.factory.machine.image-uri']) {
479
- const imageUri = params['macadam.factory.machine.image-uri'].trim();
480
- parameters.push('--image-path');
481
- if (imageUri.startsWith('https://') || imageUri.startsWith('http://')) {
482
- parameters.push(imageUri);
483
- telemetryRecords.imagePath = 'custom-url';
484
- } else {
485
- parameters.push(`docker://${imageUri}`);
486
- telemetryRecords.imagePath = 'custom-registry';
487
- }
488
- } */
489
-
490
- /* if (!telemetryRecords.imagePath) {
491
- telemetryRecords.imagePath = 'default';
492
- } */
493
-
494
- // name at the end
495
- /* if (params['macadam.factory.machine.name']) {
496
- parameters.push(params['macadam.factory.machine.name']);
497
- telemetryRecords.customName = params['macadam.factory.machine.name'];
498
- telemetryRecords.defaultName = false;
499
- } else {
500
- telemetryRecords.defaultName = true;
501
- } */
502
-
503
460
const startTime = performance . now ( ) ;
504
461
try {
505
462
const macadamCli = await macadam . getExecutable ( ) ;
@@ -522,3 +479,8 @@ async function createVM(
522
479
//sendTelemetryRecords('macadam.machine.init', telemetryRecords, false);
523
480
}
524
481
}
482
+
483
+ export function deactivate ( ) : void {
484
+ stopLoop = true ;
485
+ console . log ( 'stopping macadam extension' ) ;
486
+ }
0 commit comments