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

1ESPT Schema Rollout #543

Merged
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
35b7ec9
1ESPT Schema Rollout
priyatejankar Aug 25, 2023
e9f62f0
minor updates
priyatejankar Aug 25, 2023
f84dc1f
address feedback comments
priyatejankar Aug 25, 2023
c0f6147
comment
priyatejankar Aug 25, 2023
a0cf006
fix
priyatejankar Aug 25, 2023
0ba9870
addressed PR comments
priyatejankar Aug 29, 2023
ee0cec1
added comment
priyatejankar Aug 29, 2023
38dbf3d
PR comments
priyatejankar Aug 30, 2023
4d1235f
lastUpdated1ESPTSchema converted to map
priyatejankar Aug 30, 2023
4515b18
disable 1ESPTSchema in workspace when signed out
priyatejankar Aug 30, 2023
2128f3c
add activation event lang to yaml
priyatejankar Aug 30, 2023
2a0ed10
read and update workspace 1ESPTSchemaFile Setting
priyatejankar Aug 30, 2023
781e67d
Update src/schema-association-service-1espt.ts
priyatejankar Aug 31, 2023
1b08f36
simplified logic
priyatejankar Aug 31, 2023
c65b851
Merge branch 'dev/ptejankar/rollout1esptSchema' of https://github.com…
priyatejankar Aug 31, 2023
d49b756
remove activation on yaml
priyatejankar Aug 31, 2023
134f1cd
Update schema-association-service.ts
priyatejankar Aug 31, 2023
ce06fb6
minor update
priyatejankar Aug 31, 2023
d790654
pr comments
priyatejankar Sep 5, 2023
4c80765
logic if 1espt repo not found
priyatejankar Sep 5, 2023
caa1565
PR comments
priyatejankar Sep 12, 2023
4f4fd10
minor update
priyatejankar Sep 12, 2023
7f7cbb1
add Don't Ask Again option in popup
priyatejankar Sep 13, 2023
ccc8c43
Update src/messages.ts
priyatejankar Sep 13, 2023
2ab0279
Update src/schema-association-service-1espt.ts
priyatejankar Sep 13, 2023
e05ef54
change repoId1espt to let
priyatejankar Sep 13, 2023
60dff21
Explain the caching
winstliu Sep 13, 2023
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
Prev Previous commit
Next Next commit
logic if 1espt repo not found
  • Loading branch information
priyatejankar committed Sep 5, 2023
commit 4c807652b69fb5f5d8a0c76675c3bee528540c4a
33 changes: 21 additions & 12 deletions src/schema-association-service-1espt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ export async function get1ESPTSchemaUriIfAvailable(azureDevOpsClient: azdev.WebA
const gitApi = await azureDevOpsClient.getGitApi();
const repositories = await gitApi.getRepositories('1ESPipelineTemplates');
if (!repositories || repositories.length === 0) {
logger.log(`1ESPT repo not found for org ${organizationName}`, `SchemaDetection`)
const config = vscode.workspace.getConfiguration('azure-pipelines')
config.update('1ESPipelineTemplatesSchemaFile', false, vscode.ConfigurationTarget.Workspace); // disable the 1ESPT schema configuration
vscode.window.showInformationMessage(Messages.disabled1ESPTSchemaAsADOOrgNotContains1ESPT)
return undefined; // 1ESPT repo not found
logger.log(`1ESPipelineTemplates ADO project not found for org ${organizationName}`, `SchemaDetection`);
disable1ESPTSchemaConfiguration();
return undefined; // 1ESPT ADO project not found
}
const repository = repositories.find(repo => repo.name === "1ESPipelineTemplates");

const repository = repositories.find(repo => repo.name === "1ESPipelineTemplates");
if(!repository){
logger.log(`1ESPipelineTemplates repo not found for org ${organizationName}`, `SchemaDetection`);
disable1ESPTSchemaConfiguration();
return undefined; // 1ESPT repo not found
}
// Using getItem from GitApi: getItem(repositoryId: string, path: string, project?: string, scopePath?: string, recursionLevel?: GitInterfaces.VersionControlRecursionType, includeContentMetadata?: boolean, latestProcessedChange?: boolean, download?: boolean, versionDescriptor?: GitInterfaces.GitVersionDescriptor, includeContent?: boolean, resolveLfs?: boolean, sanitize?: boolean): Promise<GitInterfaces.GitItem>;
const schemaFile = await gitApi.getItem(repository.id, "schema/1espt-base-schema.json", "1ESPipelineTemplates", undefined, undefined, true, true, true, undefined, true, true)
const schemaFile = await gitApi.getItem(repository.id, "schema/1espt-base-schema.json", "1ESPipelineTemplates", undefined, undefined, true, true, true, undefined, true, true);

const schemaContent = schemaFile.content;
const schemaUri = Utils.joinPath(context.globalStorageUri, '1ESPTSchema', `${organizationName}-1espt-schema.json`);
winstliu marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -37,9 +40,9 @@ export async function get1ESPTSchemaUriIfAvailable(azureDevOpsClient: azdev.WebA
else
// if user is signed in with account other than microsoft, then disable 1ESPT schema and delete the 1ESPT schema file
winstliu marked this conversation as resolved.
Show resolved Hide resolved
{
const config = vscode.workspace.getConfiguration('azure-pipelines', workspaceFolder)
const config = vscode.workspace.getConfiguration('azure-pipelines', workspaceFolder);
config.update('1ESPipelineTemplatesSchemaFile', false, vscode.ConfigurationTarget.Workspace);
await vscode.workspace.fs.delete(Utils.joinPath(context.globalStorageUri, '1ESPTSchema'), { recursive: true })
await vscode.workspace.fs.delete(Utils.joinPath(context.globalStorageUri, '1ESPTSchema'), { recursive: true });
}
}
catch (error) {
Expand Down Expand Up @@ -70,17 +73,17 @@ export async function getCached1ESPTSchema(context: vscode.ExtensionContext, org
if ((new Date().getTime() - lastUpdated1ESPTSchema.get(organizationName).getTime()) < milliseconds24hours) {
const schemaFileExists = await vscode.workspace.fs.stat(schemaUri1ESPT);
if (schemaFileExists) {
logger.log("Returning cached schema for 1ESPT", 'SchemaDetection')
logger.log("Returning cached schema for 1ESPT", 'SchemaDetection');
return schemaUri1ESPT;
}
}
// schema is older than 24 hours, fetch schema file again
else {
logger.log(`Skipping cached 1ESPT schema for ${organizationName} as it is older than 24 hours`, `SchemaDetection`)
logger.log(`Skipping cached 1ESPT schema for ${organizationName} as it is older than 24 hours`, `SchemaDetection`);
}
}
else {
logger.log(`Skipping cached 1ESPT schema for ${organizationName} as user is not signed in with Microsoft account`, `SchemaDetection`)
logger.log(`Skipping cached 1ESPT schema for ${organizationName} as user is not signed in with Microsoft account`, `SchemaDetection`);
}
}
catch (error) {
Expand All @@ -90,3 +93,9 @@ export async function getCached1ESPTSchema(context: vscode.ExtensionContext, org
return undefined;
}

function disable1ESPTSchemaConfiguration() : void{
const config = vscode.workspace.getConfiguration('azure-pipelines');
config.update('1ESPipelineTemplatesSchemaFile', false, vscode.ConfigurationTarget.Workspace); // disable the 1ESPT schema configuration
vscode.window.showInformationMessage(Messages.disabled1ESPTSchemaAsADOOrgNotContains1ESPT);
}