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

Plugin respects target set in the config #167

Merged
merged 2 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions changelog.d/+target-selection.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed a bug where mirrord was not respecting target selected in the mirrord config.
6 changes: 3 additions & 3 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ export class MirrordAPI {
*
* Has 60 seconds timeout
*/
async binaryExecute(target: UserSelection, configFile: string | null, executable: string | null, configEnv: EnvVars): Promise<MirrordExecution> {
async binaryExecute(target: UserSelection | undefined, configFile: string | null, executable: string | null, configEnv: EnvVars): Promise<MirrordExecution> {
t4lz marked this conversation as resolved.
Show resolved Hide resolved
tickMirrordForTeamsCounter();
tickFeedbackCounter();
tickDiscordCounter();
Expand All @@ -387,9 +387,9 @@ export class MirrordAPI {
reject("timeout");
}, 120 * 1000);

const args = makeMirrordArgs(target.path ?? "targetless", configFile, executable);
const args = makeMirrordArgs(target?.path, configFile, executable);
let env: EnvVars;
if (target.namespace) {
if (target?.namespace) {
// eslint-disable-next-line @typescript-eslint/naming-convention
env = { MIRRORD_TARGET_NAMESPACE: target.namespace, ...configEnv };
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/debugger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async function main(
let mirrordApi = new MirrordAPI(cliPath);

config.env ||= {};
let target: UserSelection = {};
let target: UserSelection | undefined = undefined;

let configPath = await MirrordConfigManager.getInstance().resolveMirrordConfig(folder, config);
const verifiedConfig = await mirrordApi.verifyConfig(configPath, config.env);
Expand Down
9 changes: 4 additions & 5 deletions src/targetQuickPick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const TARGET_SELECTION_PAGES: (TargetQuickPickPage & {targetType: string})[] = [
* An item in the @see TargetQuickPick.
*/
type TargetQuickPickItem = vscode.QuickPickItem & (
{ type: 'target', value?: string } | // select target
{ type: 'target', value: string } | // select target
{ type: 'namespace', value: string } | // switch to another namespace
{ type: 'page', value: TargetQuickPickPage } // switch to another page (e.g select pod -> select deployment)
);
Expand All @@ -62,6 +62,7 @@ type TargetQuickPickItem = vscode.QuickPickItem & (
const TARGETLESS_ITEM: TargetQuickPickItem = {
type: 'target',
label: 'No Target (\"targetless\")',
value: 'targetless',
};

/**
Expand All @@ -75,10 +76,8 @@ export type TargetFetcher = (namespace?: string) => Thenable<MirrordLsOutput>;
export type UserSelection = {
/**
* Selected target.
*
* undefined if targetless.
*/
path?: string,
path: string,
/**
* Selected namespace.
*
Expand Down Expand Up @@ -313,7 +312,7 @@ export class TargetQuickPick {
.withDisableAction("promptTargetless")
.info();

return { namespace: this.lsOutput.current_namespace };
return { path: 'targetless', namespace: this.lsOutput.current_namespace };
}
}
}
Expand Down