From 5985d458ee3032cb9253186edc018af13fd4ae37 Mon Sep 17 00:00:00 2001 From: titanventura Date: Thu, 27 Jul 2023 23:46:37 +0530 Subject: [PATCH] Added azurite connection string option to techdocs azureBlobStorage publisher Signed-off-by: titanventura --- .changeset/pretty-otters-whisper.md | 69 +++++++++++++++++++ docs/features/techdocs/configuration.md | 5 ++ .../src/stages/publish/azureBlobStorage.ts | 25 +++++-- 3 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 .changeset/pretty-otters-whisper.md diff --git a/.changeset/pretty-otters-whisper.md b/.changeset/pretty-otters-whisper.md new file mode 100644 index 0000000000..91dd8344de --- /dev/null +++ b/.changeset/pretty-otters-whisper.md @@ -0,0 +1,69 @@ +--- +'@backstage/plugin-techdocs-node': minor +--- + +Add azurite support in techdocs through `techdocs.publisher.azureBlobStorage.azuriteConnectionString` + +These changes are **required** to `plugins/techdocs-node/src/stages/publish/azureBlobStorage.ts` and `docs/features/techdocs/configuration.md` + +```diff +diff --git a/docs/features/techdocs/configuration.md b/docs/features/techdocs/configuration.md +index 49ee9d7..a8d302c 100644 +--- a/docs/features/techdocs/configuration.md ++++ b/docs/features/techdocs/configuration.md +@@ -158,6 +158,11 @@ techdocs: + # (Required) Azure Blob Storage Container Name + containerName: 'techdocs-storage' + ++ # (Optional) Azurite connection string for local testing. ++ # Defaults to undefined ++ # if provided, takes higher priority, 'techdocs.publisher.azureBlobStorage.credentials' will become irrelevant ++ azuriteConnectionString: '' ++ + # (Required) An account name is required to write to a storage blob container. + # https://docs.microsoft.com/en-us/rest/api/storageservices/authorize-with-shared-key + credentials: +diff --git a/plugins/techdocs-node/src/stages/publish/azureBlobStorage.ts b/plugins/techdocs-node/src/stages/publish/azureBlobStorage.ts +index bcbc10a..5f19b80 100644 +--- a/plugins/techdocs-node/src/stages/publish/azureBlobStorage.ts ++++ b/plugins/techdocs-node/src/stages/publish/azureBlobStorage.ts +@@ -78,6 +78,26 @@ export class AzureBlobStoragePublish implements PublisherBase { + ); + } + ++ const legacyPathCasing = ++ config.getOptionalBoolean( ++ 'techdocs.legacyUseCaseSensitiveTripletPaths', ++ ) || false; ++ ++ // Give more priority for azurite, if configured, return the AzureBlobStoragePublish object here itself ++ const azuriteConnString = config.getOptionalString( ++ 'techdocs.publisher.azureBlobStorage.azuriteConnectionString', ++ ); ++ if (azuriteConnString) { ++ const storageClient = ++ BlobServiceClient.fromConnectionString(azuriteConnString); ++ return new AzureBlobStoragePublish({ ++ storageClient: storageClient, ++ containerName: containerName, ++ legacyPathCasing: legacyPathCasing, ++ logger: logger, ++ }); ++ } ++ + let accountName = ''; + try { + accountName = config.getString( +@@ -108,11 +128,6 @@ export class AzureBlobStoragePublish implements PublisherBase { + credential, + ); + +- const legacyPathCasing = +- config.getOptionalBoolean( +- 'techdocs.legacyUseCaseSensitiveTripletPaths', +- ) || false; +- + return new AzureBlobStoragePublish({ + storageClient: storageClient, + containerName: containerName, +``` diff --git a/docs/features/techdocs/configuration.md b/docs/features/techdocs/configuration.md index 49ee9d72c2..a8d302c35b 100644 --- a/docs/features/techdocs/configuration.md +++ b/docs/features/techdocs/configuration.md @@ -158,6 +158,11 @@ techdocs: # (Required) Azure Blob Storage Container Name containerName: 'techdocs-storage' + # (Optional) Azurite connection string for local testing. + # Defaults to undefined + # if provided, takes higher priority, 'techdocs.publisher.azureBlobStorage.credentials' will become irrelevant + azuriteConnectionString: '' + # (Required) An account name is required to write to a storage blob container. # https://docs.microsoft.com/en-us/rest/api/storageservices/authorize-with-shared-key credentials: diff --git a/plugins/techdocs-node/src/stages/publish/azureBlobStorage.ts b/plugins/techdocs-node/src/stages/publish/azureBlobStorage.ts index bcbc10a94d..5f19b8010f 100644 --- a/plugins/techdocs-node/src/stages/publish/azureBlobStorage.ts +++ b/plugins/techdocs-node/src/stages/publish/azureBlobStorage.ts @@ -78,6 +78,26 @@ export class AzureBlobStoragePublish implements PublisherBase { ); } + const legacyPathCasing = + config.getOptionalBoolean( + 'techdocs.legacyUseCaseSensitiveTripletPaths', + ) || false; + + // Give more priority for azurite, if configured, return the AzureBlobStoragePublish object here itself + const azuriteConnString = config.getOptionalString( + 'techdocs.publisher.azureBlobStorage.azuriteConnectionString', + ); + if (azuriteConnString) { + const storageClient = + BlobServiceClient.fromConnectionString(azuriteConnString); + return new AzureBlobStoragePublish({ + storageClient: storageClient, + containerName: containerName, + legacyPathCasing: legacyPathCasing, + logger: logger, + }); + } + let accountName = ''; try { accountName = config.getString( @@ -108,11 +128,6 @@ export class AzureBlobStoragePublish implements PublisherBase { credential, ); - const legacyPathCasing = - config.getOptionalBoolean( - 'techdocs.legacyUseCaseSensitiveTripletPaths', - ) || false; - return new AzureBlobStoragePublish({ storageClient: storageClient, containerName: containerName,