Skip to content

Commit 60a5fdc

Browse files
committed
Address review comments
Also drops one line of excess logging. Signed-off-by: Mark Yen <[email protected]>
1 parent 032ab1e commit 60a5fdc

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

pkg/rancher-desktop/integrations/pathManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export interface PathManager {
88
/** The PathManagementStrategy that corresponds to the implementation. */
99
readonly strategy: PathManagementStrategy
1010
/**
11-
* Makes real any changes to the system. Should be idempotent, and should not
12-
* throw any exceptions.
11+
* Applies changes to the system. Should be idempotent, and should not throw
12+
* any exceptions.
1313
*/
1414
enforce(): Promise<void>
1515
/**

pkg/rancher-desktop/integrations/pathManagerImpl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class RcFilePathManager implements PathManager {
6161
try {
6262
await manageLinesInFile(filePath, lines, desiredPresent);
6363
mainEvents.emit('diagnostics-event', 'path-management', { fileName, error: undefined });
64-
} catch (error) {
64+
} catch (error: any) {
6565
mainEvents.emit('diagnostics-event', 'path-management', { fileName, error });
6666
throw error;
6767
}

pkg/rancher-desktop/main/diagnostics/diagnostics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ export class DiagnosticsManager {
4747
this.checkers = diagnostics ? Promise.resolve(diagnostics) : (async() => {
4848
const imports = (await Promise.all([
4949
import('./connectedToInternet'),
50-
import('./pathManagement'),
5150
import('./dockerCliSymlinks'),
5251
import('./kubeConfigSymlink'),
5352
import('./kubeContext'),
5453
import('./limaDarwin'),
5554
import('./mockForScreenshots'),
55+
import('./pathManagement'),
5656
import('./rdBinInShell'),
5757
import('./testCheckers'),
5858
import('./wslFromStore'),

pkg/rancher-desktop/main/diagnostics/pathManagement.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import { DiagnosticsCategory, DiagnosticsChecker, DiagnosticsCheckerResult, Diag
22

33
import { ErrorHasExtendedAttributes, ErrorNotRegularFile, ErrorWritingFile } from '@pkg/integrations/manageLinesInFile';
44
import mainEvents from '@pkg/main/mainEvents';
5-
import Logging from '@pkg/utils/logging';
65

7-
const console = Logging.diagnostics;
86
const cachedResults: Record<string, DiagnosticsCheckerResult> = {};
97

8+
/**
9+
* Check for any errors raised from handling path management (i.e. handling of
10+
* ~/.bashrc and related files) and report them to the user.
11+
*/
1012
const CheckPathManagement: DiagnosticsChecker = {
1113
id: 'PATH_MANAGEMENT',
1214
category: DiagnosticsCategory.Utilities,
@@ -24,7 +26,6 @@ const CheckPathManagement: DiagnosticsChecker = {
2426
};
2527

2628
mainEvents.on('diagnostics-event', (id, state) => {
27-
console.log('diagnostics-event', id, state);
2829
if (id !== 'path-management') {
2930
return;
3031
}

pkg/rancher-desktop/main/mainEvents.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ interface MainEventNames {
105105
* @param id The diagnostic identifier.
106106
* @param state The new state for the diagnostic.
107107
*/
108-
'diagnostics-event'(id: string, state: any): void;
108+
'diagnostics-event'<K extends keyof DiagnosticsEventPayload>(id: K, state: DiagnosticsEventPayload[K]): void;
109109

110110
/**
111111
* Emitted when an extension is uninstalled via the extension manager.
@@ -144,6 +144,14 @@ interface MainEventNames {
144144
'dialog-info'(args: Record<string, string>): void;
145145
}
146146

147+
/**
148+
* DiagnosticsEventPayload defines the data that will be passed on a
149+
* 'diagnostics-event' event.
150+
*/
151+
type DiagnosticsEventPayload = {
152+
'path-management': { fileName: string; error: Error | undefined };
153+
};
154+
147155
/**
148156
* Helper type definition to check if the given event name is a handler (i.e.
149157
* has a return value) instead of an event (i.e. returns void).

0 commit comments

Comments
 (0)