refactor: extracted duplicit code to function (#17154)
Some checks are pending
Argos CI Screenshots / take screenshots (push) Waiting to run
Publish codecov report from main branch / Run tests and push coverage result (push) Waiting to run
e2e-kubernetes-tests-main / Run All E2E tests (push) Waiting to run
e2e-tests-main / Run E2E tests - flatpak-build (push) Waiting to run
e2e-tests-main / Run E2E tests - source-build (push) Waiting to run
e2e-tests-main / windows-11-arm update e2e tests - custom-extensions (push) Waiting to run
e2e-tests-main / windows-2025 update e2e tests - custom-extensions (push) Waiting to run
e2e-tests-main / windows-11-arm update e2e tests - vanilla (push) Waiting to run
e2e-tests-main / windows-2025 update e2e tests - vanilla (push) Waiting to run
e2e-tests-main / macos-15-intel update e2e tests (push) Waiting to run
e2e-tests-main / macos-26 update e2e tests (push) Waiting to run
Managed configuration tests / Managed configuration tests - macos-latest (push) Waiting to run
Managed configuration tests / Managed configuration tests - ubuntu-latest (push) Waiting to run
Managed configuration tests / Managed configuration tests - windows-2025 (push) Waiting to run
next build / Tagging (push) Waiting to run
next build / Build / macos-15 (push) Blocked by required conditions
next build / Build / ubuntu-24.04 (push) Blocked by required conditions
next build / Build / windows-2025 (push) Blocked by required conditions
next build / Release (push) Blocked by required conditions
Publish NPM packages to npmjs.com using OIDC / Prepare version info (push) Waiting to run
Publish NPM packages to npmjs.com using OIDC / Publish to npm (push) Blocked by required conditions
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Publish Website / Build and deploy website (push) Waiting to run

Signed-off-by: Evzen Gasta <evzen.ml@seznam.cz>
This commit is contained in:
Evžen Gasta 2026-04-21 10:19:55 +02:00 committed by GitHub
parent 76b1a0b24e
commit 677f704339
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1152,29 +1152,8 @@ export class ProviderRegistry {
} finally {
if (this.isProviderContainerConnection(providerConnectionInfo)) {
this.fireUpdateContainerConnectionEvents(provider.id, providerConnectionInfo);
} else if (this.isProviderKubernetesConnectionInfo(providerConnectionInfo)) {
this._onDidUpdateKubernetesConnection.fire({
providerId: provider.id,
connection: {
name: providerConnectionInfo.name,
endpoint: providerConnectionInfo.endpoint,
status: (): ProviderConnectionStatus => {
return 'started';
},
},
status: 'started',
});
} else {
this._onDidUpdateVmConnection.fire({
providerId: provider.id,
connection: {
name: providerConnectionInfo.name,
status: (): ProviderConnectionStatus => {
return 'started';
},
},
status: 'started',
});
this.fireConnectionUpdateEvent(provider.id, providerConnectionInfo, 'started');
}
}
}
@ -1250,47 +1229,7 @@ export class ProviderRegistry {
}
try {
if (this.isProviderContainerConnection(providerConnectionInfo)) {
const event = {
providerId: provider.id,
connection: {
displayName: providerConnectionInfo.displayName,
name: providerConnectionInfo.name,
type: providerConnectionInfo.type,
endpoint: providerConnectionInfo.endpoint,
status: (): ProviderConnectionStatus => {
return 'stopped';
},
},
status: 'stopped' as ProviderConnectionStatus,
};
this._onBeforeDidUpdateContainerConnection.fire(event);
this._onDidUpdateContainerConnection.fire(event);
this._onAfterDidUpdateContainerConnection.fire(event);
} else if (this.isProviderKubernetesConnectionInfo(providerConnectionInfo)) {
this._onDidUpdateKubernetesConnection.fire({
providerId: provider.id,
connection: {
name: providerConnectionInfo.name,
endpoint: providerConnectionInfo.endpoint,
status: (): ProviderConnectionStatus => {
return 'stopped';
},
},
status: 'stopped',
});
} else {
this._onDidUpdateVmConnection.fire({
providerId: provider.id,
connection: {
name: providerConnectionInfo.name,
status: (): ProviderConnectionStatus => {
return 'stopped';
},
},
status: 'stopped',
});
}
this.fireConnectionUpdateEvent(provider.id, providerConnectionInfo, 'stopped');
await lifecycle.stop(context, logHandler);
} catch (err) {
console.warn(`Can't stop connection ${provider.id}.${providerConnectionInfo.name}`, err);
@ -1603,6 +1542,48 @@ export class ProviderRegistry {
return undefined;
}
protected fireConnectionUpdateEvent(
providerId: string,
providerConnectionInfo: ProviderConnectionInfo,
status: ProviderConnectionStatus,
): void {
if (this.isProviderContainerConnection(providerConnectionInfo)) {
const event = {
providerId,
connection: {
displayName: providerConnectionInfo.displayName,
name: providerConnectionInfo.name,
type: providerConnectionInfo.type,
endpoint: providerConnectionInfo.endpoint,
status: (): ProviderConnectionStatus => status,
},
status,
};
this._onBeforeDidUpdateContainerConnection.fire(event);
this._onDidUpdateContainerConnection.fire(event);
this._onAfterDidUpdateContainerConnection.fire(event);
} else if (this.isProviderKubernetesConnectionInfo(providerConnectionInfo)) {
this._onDidUpdateKubernetesConnection.fire({
providerId,
connection: {
name: providerConnectionInfo.name,
endpoint: providerConnectionInfo.endpoint,
status: (): ProviderConnectionStatus => status,
},
status,
});
} else {
this._onDidUpdateVmConnection.fire({
providerId,
connection: {
name: providerConnectionInfo.name,
status: (): ProviderConnectionStatus => status,
},
status,
});
}
}
protected fireUpdateContainerConnectionEvents(
providerId: string,
providerConnectionInfo: ProviderContainerConnectionInfo,