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

serviceconnector: Add children to validate activity log #1557

Merged
merged 5 commits into from
Aug 15, 2023
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
9 changes: 5 additions & 4 deletions serviceconnector/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions serviceconnector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@
"package": "npm pack"
},
"dependencies": {
"@microsoft/vscode-azext-utils": "^2.0.0",
"@azure/arm-servicelinker": "^2.1.0",
"@microsoft/vscode-azext-azureutils": "^2.0.0",
"@azure/arm-servicelinker" : "^2.1.0"
"@microsoft/vscode-azext-utils": "2.0.5"
},
"devDependencies": {
"@microsoft/eslint-config-azuretools": "^0.2.0",
"@types/mocha": "^9.0.0",
"@types/node": "^16.0.0",
"@types/vscode": "1.76.0",
"@typescript-eslint/eslint-plugin": "^5.53.0",
"@microsoft/eslint-config-azuretools": "^0.2.0",
"@vscode/test-electron": "^2.1.5",
"eslint": "^8.34.0",
"eslint-plugin-import": "^2.22.1",
Expand Down
7 changes: 6 additions & 1 deletion serviceconnector/src/deleteLinker/IPickLinkerContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { ValidationResultItem } from "@azure/arm-servicelinker";
import { ExecuteActivityContext } from "@microsoft/vscode-azext-utils";
import { ICreateLinkerContext } from "../createLinker/ICreateLinkerContext";

export interface IPickLinkerContext extends ICreateLinkerContext {
export interface IPickLinkerContext extends ICreateLinkerContext, ExecuteActivityContext {
linkerName?: string;

//Validation
validationResult?: ValidationResultItem[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this set or used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was using it in a previous implementation but will remove since it is no longer used.

}

20 changes: 17 additions & 3 deletions serviceconnector/src/validateLinker/ValidateLinkerStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,34 @@
* Licensed under the MIT License. See License.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { AzureWizardExecuteStep, nonNullValue } from "@microsoft/vscode-azext-utils";
import { AzureWizardExecuteStep, GenericTreeItem, nonNullValue } from "@microsoft/vscode-azext-utils";
import { ThemeColor, ThemeIcon } from "vscode";
import { IPickLinkerContext } from "../deleteLinker/IPickLinkerContext";
import { createLinkerClient } from "../linkerClient";
import { KnownValidationResultStatus } from "@azure/arm-servicelinker";

export class ValidateLinkerStep extends AzureWizardExecuteStep<IPickLinkerContext> {
public priority: number = 10;

public async execute(context: IPickLinkerContext): Promise<void> {
const client = await createLinkerClient(context.credentials);
const response = await client.linker.beginValidateAndWait(nonNullValue(context.sourceResourceUri), nonNullValue(context.linkerName));

context.activityChildren = [];

for (const detail of nonNullValue(response.validationDetail)) {
if (detail.result === KnownValidationResultStatus.Failure) {
if (detail.result === "failure") {
context.activityChildren.push(new GenericTreeItem(undefined, {
contextValue: `validateResult-${detail.name}`,
label: nonNullValue(detail.name),
iconPath: new ThemeIcon('error', new ThemeColor('testing.iconFailed'))
}));
throw new Error(detail.description);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although one validation failed, I think it's best to still show all other failed/passed validations as activity children. Maybe throw the error after all the children are added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The portal currently only shows the one failure if the validation errors but I think it would be better to show all the checks.

Copy link
Contributor Author

@motm32 motm32 Aug 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually tested this out and for some reason when there is an error the validation result only contains the failed check. So moving the error after all the children doesn't change anything.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not exactly sure why that happens. But that's fine

} else {
context.activityChildren.push(new GenericTreeItem(undefined, {
contextValue: `validateResult-${detail.name}`,
label: nonNullValue(detail.name),
iconPath: new ThemeIcon('pass', new ThemeColor('testing.iconPassed'))
}));
}
}
}
Expand Down
Loading