chore: update task versions and add maxResults input to ListBlobs task
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
"version": {
|
"version": {
|
||||||
"Major": 1,
|
"Major": 1,
|
||||||
"Minor": 0,
|
"Minor": 0,
|
||||||
"Patch": 5
|
"Patch": 8
|
||||||
},
|
},
|
||||||
"instanceNameFormat": "Configure federated auth: $(serviceConnectionARM)",
|
"instanceNameFormat": "Configure federated auth: $(serviceConnectionARM)",
|
||||||
"inputs": [
|
"inputs": [
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"version": {
|
"version": {
|
||||||
"Major": 1,
|
"Major": 1,
|
||||||
"Minor": 0,
|
"Minor": 0,
|
||||||
"Patch": 0
|
"Patch": 2
|
||||||
},
|
},
|
||||||
"instanceNameFormat": "Copy blob: $(srcStorageAccountName)/$(srcContainerName)/$(blobName)",
|
"instanceNameFormat": "Copy blob: $(srcStorageAccountName)/$(srcContainerName)/$(blobName)",
|
||||||
"inputs": [
|
"inputs": [
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "list-blobs-task",
|
"name": "list-blobs-task",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"author": "Slawomir Koszewski",
|
"author": "Slawomir Koszewski",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|||||||
@@ -26,10 +26,11 @@ function parseBlobNames(xml: string): string[] {
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildListUrl(storageAccountName: string, containerName: string, prefix: string): string {
|
function buildListUrl(storageAccountName: string, containerName: string, prefix: string, maxResults: number): string {
|
||||||
const url = new URL(`https://${storageAccountName}.blob.core.windows.net/${encodeURIComponent(containerName)}`);
|
const url = new URL(`https://${storageAccountName}.blob.core.windows.net/${encodeURIComponent(containerName)}`);
|
||||||
url.searchParams.set('restype', 'container');
|
url.searchParams.set('restype', 'container');
|
||||||
url.searchParams.set('comp', 'list');
|
url.searchParams.set('comp', 'list');
|
||||||
|
url.searchParams.set('maxresults', String(maxResults));
|
||||||
|
|
||||||
if (prefix) {
|
if (prefix) {
|
||||||
url.searchParams.set('prefix', prefix);
|
url.searchParams.set('prefix', prefix);
|
||||||
@@ -63,12 +64,18 @@ async function run(): Promise<void> {
|
|||||||
const storageAccountName = requireInput('storageAccountName');
|
const storageAccountName = requireInput('storageAccountName');
|
||||||
const containerName = requireInput('containerName');
|
const containerName = requireInput('containerName');
|
||||||
const prefix = tl.getInput('prefix', false)?.trim() || '';
|
const prefix = tl.getInput('prefix', false)?.trim() || '';
|
||||||
|
const maxResultsRaw = tl.getInput('maxResults', false)?.trim() || '1000';
|
||||||
|
const maxResults = Number.parseInt(maxResultsRaw, 10);
|
||||||
|
|
||||||
|
if (!Number.isInteger(maxResults) || maxResults <= 0) {
|
||||||
|
throw new Error(`Invalid maxResults value: ${maxResultsRaw}. Expected a positive integer.`);
|
||||||
|
}
|
||||||
|
|
||||||
console.log('Requesting storage access token from Microsoft Entra ID...');
|
console.log('Requesting storage access token from Microsoft Entra ID...');
|
||||||
const accessToken = await requestStorageAccessToken(endpointId);
|
const accessToken = await requestStorageAccessToken(endpointId);
|
||||||
|
|
||||||
const listUrl = buildListUrl(storageAccountName, containerName, prefix);
|
const listUrl = buildListUrl(storageAccountName, containerName, prefix, maxResults);
|
||||||
const blobNames = await listBlobs(listUrl, accessToken);
|
const blobNames = (await listBlobs(listUrl, accessToken)).slice(0, maxResults);
|
||||||
|
|
||||||
const serialized = JSON.stringify(blobNames);
|
const serialized = JSON.stringify(blobNames);
|
||||||
tl.setVariable('LIST_BLOBS_JSON', serialized);
|
tl.setVariable('LIST_BLOBS_JSON', serialized);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"version": {
|
"version": {
|
||||||
"Major": 1,
|
"Major": 1,
|
||||||
"Minor": 0,
|
"Minor": 0,
|
||||||
"Patch": 0
|
"Patch": 1
|
||||||
},
|
},
|
||||||
"instanceNameFormat": "List blobs: $(storageAccountName)/$(containerName)",
|
"instanceNameFormat": "List blobs: $(storageAccountName)/$(containerName)",
|
||||||
"inputs": [
|
"inputs": [
|
||||||
@@ -45,6 +45,14 @@
|
|||||||
"defaultValue": "",
|
"defaultValue": "",
|
||||||
"required": false,
|
"required": false,
|
||||||
"helpMarkDown": "Optional blob name prefix used to filter results."
|
"helpMarkDown": "Optional blob name prefix used to filter results."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "maxResults",
|
||||||
|
"type": "string",
|
||||||
|
"label": "Maximum Blob Count",
|
||||||
|
"defaultValue": "1000",
|
||||||
|
"required": false,
|
||||||
|
"helpMarkDown": "Maximum number of blobs to return. Default is 1000."
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"execution": {
|
"execution": {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"manifestVersion": 1,
|
"manifestVersion": 1,
|
||||||
"id": "sk-azure-devops-toolkit",
|
"id": "sk-azure-devops-toolkit",
|
||||||
"name": "SK Azure DevOps Toolkit",
|
"name": "SK Azure DevOps Toolkit",
|
||||||
"version": "1.0.3",
|
"version": "1.0.4",
|
||||||
"publisher": "skoszewski-lab",
|
"publisher": "skoszewski-lab",
|
||||||
"targets": [
|
"targets": [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user