@backstage/plugin-techdocs-node 1.13.11-next.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @backstage/plugin-techdocs-node
|
|
2
2
|
|
|
3
|
+
## 1.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 63c459c: **BREAKING:** It's now possible to use the credentials from the `integrations.awsS3` config to authenticate with AWS S3. The new priority is:
|
|
8
|
+
|
|
9
|
+
1. `aws.accounts`
|
|
10
|
+
2. `techdocs.publisher.awsS3.credentials`
|
|
11
|
+
3. `integrations.awsS3`
|
|
12
|
+
4. Default credential chain
|
|
13
|
+
|
|
14
|
+
In case of multiple `integrations.awsS3` are present, the target integration is determined by the `accessKeyId` in `techdocs.publisher.awsS3.credentials` if provided. Otherwise, the default credential chain is used.
|
|
15
|
+
|
|
16
|
+
This means that depending on your setup, this feature may break your existing setup.
|
|
17
|
+
In general:
|
|
18
|
+
|
|
19
|
+
- if you are configuring `aws.accounts`, no action is required
|
|
20
|
+
- if you are configuring `techdocs.publisher.awsS3.credentials`, no action is required
|
|
21
|
+
- if you are configuring multiple integrations under `integrations.awsS3`, no action is required
|
|
22
|
+
- if you are configuring a single integration under `integrations.awsS3`, make sure that the integration has access to the bucket you are using for TechDocs
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- f0951aa: Updated the `defaultDockerImage` to reflect the latest TechDocs Container version of v1.2.8
|
|
27
|
+
- Updated dependencies
|
|
28
|
+
- @backstage/backend-plugin-api@1.6.1
|
|
29
|
+
- @backstage/integration@1.19.2
|
|
30
|
+
|
|
3
31
|
## 1.13.11-next.0
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -237,8 +237,10 @@ declare class TechdocsGenerator implements GeneratorBase {
|
|
|
237
237
|
/**
|
|
238
238
|
* The default docker image (and version) used to generate content. Public
|
|
239
239
|
* and static so that techdocs-node consumers can use the same version.
|
|
240
|
+
*
|
|
241
|
+
* See {@link https://hub.docker.com/r/spotify/techdocs/tags} for list of available versions.
|
|
240
242
|
*/
|
|
241
|
-
static readonly defaultDockerImage = "spotify/techdocs:v1.2.
|
|
243
|
+
static readonly defaultDockerImage = "spotify/techdocs:v1.2.8";
|
|
242
244
|
private readonly logger;
|
|
243
245
|
private readonly containerRunner?;
|
|
244
246
|
private readonly options;
|
|
@@ -15,8 +15,10 @@ class TechdocsGenerator {
|
|
|
15
15
|
/**
|
|
16
16
|
* The default docker image (and version) used to generate content. Public
|
|
17
17
|
* and static so that techdocs-node consumers can use the same version.
|
|
18
|
+
*
|
|
19
|
+
* See {@link https://hub.docker.com/r/spotify/techdocs/tags} for list of available versions.
|
|
18
20
|
*/
|
|
19
|
-
static defaultDockerImage = "spotify/techdocs:v1.2.
|
|
21
|
+
static defaultDockerImage = "spotify/techdocs:v1.2.8";
|
|
20
22
|
logger;
|
|
21
23
|
containerRunner;
|
|
22
24
|
options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"techdocs.cjs.js","sources":["../../../src/stages/generate/techdocs.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport path from 'path';\nimport {\n ScmIntegrationRegistry,\n ScmIntegrations,\n} from '@backstage/integration';\nimport {\n createOrUpdateMetadata,\n getMkdocsYml,\n patchIndexPreBuild,\n runCommand,\n storeEtagMetadata,\n validateMkdocsYaml,\n} from './helpers';\n\nimport {\n patchMkdocsYmlPreBuild,\n patchMkdocsYmlWithPlugins,\n} from './mkdocsPatchers';\nimport {\n GeneratorBase,\n GeneratorConfig,\n GeneratorOptions,\n GeneratorRunInType,\n GeneratorRunOptions,\n} from './types';\nimport { ForwardedError } from '@backstage/errors';\nimport { DockerContainerRunner } from './DockerContainerRunner';\nimport { LoggerService } from '@backstage/backend-plugin-api';\nimport { TechDocsContainerRunner } from './types';\n\n/**\n * Generates documentation files\n * @public\n */\nexport class TechdocsGenerator implements GeneratorBase {\n /**\n * The default docker image (and version) used to generate content. Public\n * and static so that techdocs-node consumers can use the same version.\n */\n public static readonly defaultDockerImage = 'spotify/techdocs:v1.2.6';\n private readonly logger: LoggerService;\n private readonly containerRunner?: TechDocsContainerRunner;\n private readonly options: GeneratorConfig;\n private readonly scmIntegrations: ScmIntegrationRegistry;\n\n /**\n * Returns a instance of TechDocs generator\n * @param config - A Backstage configuration\n * @param options - Options to configure the generator\n */\n static fromConfig(config: Config, options: GeneratorOptions) {\n const { containerRunner, logger } = options;\n const scmIntegrations = ScmIntegrations.fromConfig(config);\n return new TechdocsGenerator({\n logger,\n containerRunner,\n config,\n scmIntegrations,\n });\n }\n\n constructor(options: {\n logger: LoggerService;\n containerRunner?: TechDocsContainerRunner;\n config: Config;\n scmIntegrations: ScmIntegrationRegistry;\n }) {\n this.logger = options.logger;\n this.options = readGeneratorConfig(options.config, options.logger);\n this.containerRunner = options.containerRunner;\n this.scmIntegrations = options.scmIntegrations;\n }\n\n /** {@inheritDoc GeneratorBase.run} */\n public async run(options: GeneratorRunOptions): Promise<void> {\n const {\n inputDir,\n outputDir,\n parsedLocationAnnotation,\n etag,\n logger: childLogger,\n logStream,\n siteOptions,\n runAsDefaultUser,\n } = options;\n\n // Do some updates to mkdocs.yml before generating docs e.g. adding repo_url\n const { path: mkdocsYmlPath, content } = await getMkdocsYml(\n inputDir,\n siteOptions,\n );\n\n // validate the docs_dir first\n const docsDir = await validateMkdocsYaml(inputDir, content);\n\n if (parsedLocationAnnotation) {\n await patchMkdocsYmlPreBuild(\n mkdocsYmlPath,\n childLogger,\n parsedLocationAnnotation,\n this.scmIntegrations,\n );\n }\n\n if (this.options.legacyCopyReadmeMdToIndexMd) {\n await patchIndexPreBuild({ inputDir, logger: childLogger, docsDir });\n }\n\n // patch the list of mkdocs plugins\n const defaultPlugins = this.options.defaultPlugins ?? [];\n\n if (\n !this.options.omitTechdocsCoreMkdocsPlugin &&\n !defaultPlugins.includes('techdocs-core')\n ) {\n defaultPlugins.push('techdocs-core');\n }\n\n await patchMkdocsYmlWithPlugins(mkdocsYmlPath, childLogger, defaultPlugins);\n\n // Directories to bind on container\n const mountDirs = {\n [inputDir]: '/input',\n [outputDir]: '/output',\n };\n\n try {\n switch (this.options.runIn) {\n case 'local':\n await runCommand({\n command: 'mkdocs',\n args: ['build', '-d', outputDir, '-v'],\n options: {\n cwd: inputDir,\n },\n logStream,\n });\n childLogger.info(\n `Successfully generated docs from ${inputDir} into ${outputDir} using local mkdocs`,\n );\n break;\n case 'docker': {\n const containerRunner =\n this.containerRunner || new DockerContainerRunner();\n await containerRunner.runContainer({\n imageName:\n this.options.dockerImage ?? TechdocsGenerator.defaultDockerImage,\n args: ['build', '-d', '/output'],\n logStream,\n mountDirs,\n workingDir: '/input',\n // Set the home directory inside the container as something that applications can\n // write to, otherwise they will just fail trying to write to /\n envVars: { HOME: '/tmp' },\n pullImage: this.options.pullImage,\n defaultUser: runAsDefaultUser,\n });\n childLogger.info(\n `Successfully generated docs from ${inputDir} into ${outputDir} using techdocs-container`,\n );\n break;\n }\n default:\n throw new Error(\n `Invalid config value \"${this.options.runIn}\" provided in 'techdocs.generators.techdocs'.`,\n );\n }\n } catch (error) {\n this.logger.debug(\n `Failed to generate docs from ${inputDir} into ${outputDir}`,\n );\n throw new ForwardedError(\n `Failed to generate docs from ${inputDir} into ${outputDir}`,\n error,\n );\n }\n\n /**\n * Post Generate steps\n */\n\n // Add build timestamp and files to techdocs_metadata.json\n // Creates techdocs_metadata.json if file does not exist.\n await createOrUpdateMetadata(\n path.join(outputDir, 'techdocs_metadata.json'),\n childLogger,\n );\n\n // Add etag of the prepared tree to techdocs_metadata.json\n // Assumes that the file already exists.\n if (etag) {\n await storeEtagMetadata(\n path.join(outputDir, 'techdocs_metadata.json'),\n etag,\n );\n }\n }\n}\n\nexport function readGeneratorConfig(\n config: Config,\n logger: LoggerService,\n): GeneratorConfig {\n const legacyGeneratorType = config.getOptionalString(\n 'techdocs.generators.techdocs',\n ) as GeneratorRunInType;\n\n if (legacyGeneratorType) {\n logger.warn(\n `The 'techdocs.generators.techdocs' configuration key is deprecated and will be removed in the future. Please use 'techdocs.generator' instead. ` +\n `See here https://backstage.io/docs/features/techdocs/configuration`,\n );\n }\n\n return {\n runIn:\n legacyGeneratorType ??\n config.getOptionalString('techdocs.generator.runIn') ??\n 'docker',\n dockerImage: config.getOptionalString('techdocs.generator.dockerImage'),\n pullImage: config.getOptionalBoolean('techdocs.generator.pullImage'),\n omitTechdocsCoreMkdocsPlugin: config.getOptionalBoolean(\n 'techdocs.generator.mkdocs.omitTechdocsCorePlugin',\n ),\n legacyCopyReadmeMdToIndexMd: config.getOptionalBoolean(\n 'techdocs.generator.mkdocs.legacyCopyReadmeMdToIndexMd',\n ),\n defaultPlugins: config.getOptionalStringArray(\n 'techdocs.generator.mkdocs.defaultPlugins',\n ),\n };\n}\n"],"names":["ScmIntegrations","getMkdocsYml","validateMkdocsYaml","patchMkdocsYmlPreBuild","patchIndexPreBuild","patchMkdocsYmlWithPlugins","runCommand","DockerContainerRunner","ForwardedError","createOrUpdateMetadata","path","storeEtagMetadata"],"mappings":";;;;;;;;;;;;;AAmDO,MAAM,iBAAA,CAA2C;AAAA;AAAA;AAAA;AAAA;AAAA,EAKtD,OAAuB,kBAAA,GAAqB,yBAAA;AAAA,EAC3B,MAAA;AAAA,EACA,eAAA;AAAA,EACA,OAAA;AAAA,EAC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AEA,EAAA,IAAI,mBAAA,EAAqB;AACvB,IAAA,MAAA,CAAO,IAAA;AAAA,MACL,CAAA,iNAAA;AAAA,KAEF;AAAA,EACF;AAEA,EAAA,OAAO;AAAA,IACL,KAAA,EACE,mBAAA,IACA,MAAA,CAAO,iBAAA,CAAkB,0BAA0B,CAAA,IACnD,QAAA;AAAA,IACF,WAAA,EAAa,MAAA,CAAO,iBAAA,CAAkB,gCAAgC,CAAA;AAAA,IACtE,SAAA,EAAW,MAAA,CAAO,kBAAA,CAAmB,8BAA8B,CAAA;AAAA,IACnE,8BAA8B,MAAA,CAAO,kBAAA;AAAA,MACnC;AAAA,KACF;AAAA,IACA,6BAA6B,MAAA,CAAO,kBAAA;AAAA,MAClC;AAAA,KACF;AAAA,IACA,gBAAgB,MAAA,CAAO,sBAAA;AAAA,MACrB;AAAA;AACF,GACF;AACF;;;;;"}
|
|
1
|
+
{"version":3,"file":"techdocs.cjs.js","sources":["../../../src/stages/generate/techdocs.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config } from '@backstage/config';\nimport path from 'path';\nimport {\n ScmIntegrationRegistry,\n ScmIntegrations,\n} from '@backstage/integration';\nimport {\n createOrUpdateMetadata,\n getMkdocsYml,\n patchIndexPreBuild,\n runCommand,\n storeEtagMetadata,\n validateMkdocsYaml,\n} from './helpers';\n\nimport {\n patchMkdocsYmlPreBuild,\n patchMkdocsYmlWithPlugins,\n} from './mkdocsPatchers';\nimport {\n GeneratorBase,\n GeneratorConfig,\n GeneratorOptions,\n GeneratorRunInType,\n GeneratorRunOptions,\n} from './types';\nimport { ForwardedError } from '@backstage/errors';\nimport { DockerContainerRunner } from './DockerContainerRunner';\nimport { LoggerService } from '@backstage/backend-plugin-api';\nimport { TechDocsContainerRunner } from './types';\n\n/**\n * Generates documentation files\n * @public\n */\nexport class TechdocsGenerator implements GeneratorBase {\n /**\n * The default docker image (and version) used to generate content. Public\n * and static so that techdocs-node consumers can use the same version.\n *\n * See {@link https://hub.docker.com/r/spotify/techdocs/tags} for list of available versions.\n */\n public static readonly defaultDockerImage = 'spotify/techdocs:v1.2.8';\n private readonly logger: LoggerService;\n private readonly containerRunner?: TechDocsContainerRunner;\n private readonly options: GeneratorConfig;\n private readonly scmIntegrations: ScmIntegrationRegistry;\n\n /**\n * Returns a instance of TechDocs generator\n * @param config - A Backstage configuration\n * @param options - Options to configure the generator\n */\n static fromConfig(config: Config, options: GeneratorOptions) {\n const { containerRunner, logger } = options;\n const scmIntegrations = ScmIntegrations.fromConfig(config);\n return new TechdocsGenerator({\n logger,\n containerRunner,\n config,\n scmIntegrations,\n });\n }\n\n constructor(options: {\n logger: LoggerService;\n containerRunner?: TechDocsContainerRunner;\n config: Config;\n scmIntegrations: ScmIntegrationRegistry;\n }) {\n this.logger = options.logger;\n this.options = readGeneratorConfig(options.config, options.logger);\n this.containerRunner = options.containerRunner;\n this.scmIntegrations = options.scmIntegrations;\n }\n\n /** {@inheritDoc GeneratorBase.run} */\n public async run(options: GeneratorRunOptions): Promise<void> {\n const {\n inputDir,\n outputDir,\n parsedLocationAnnotation,\n etag,\n logger: childLogger,\n logStream,\n siteOptions,\n runAsDefaultUser,\n } = options;\n\n // Do some updates to mkdocs.yml before generating docs e.g. adding repo_url\n const { path: mkdocsYmlPath, content } = await getMkdocsYml(\n inputDir,\n siteOptions,\n );\n\n // validate the docs_dir first\n const docsDir = await validateMkdocsYaml(inputDir, content);\n\n if (parsedLocationAnnotation) {\n await patchMkdocsYmlPreBuild(\n mkdocsYmlPath,\n childLogger,\n parsedLocationAnnotation,\n this.scmIntegrations,\n );\n }\n\n if (this.options.legacyCopyReadmeMdToIndexMd) {\n await patchIndexPreBuild({ inputDir, logger: childLogger, docsDir });\n }\n\n // patch the list of mkdocs plugins\n const defaultPlugins = this.options.defaultPlugins ?? [];\n\n if (\n !this.options.omitTechdocsCoreMkdocsPlugin &&\n !defaultPlugins.includes('techdocs-core')\n ) {\n defaultPlugins.push('techdocs-core');\n }\n\n await patchMkdocsYmlWithPlugins(mkdocsYmlPath, childLogger, defaultPlugins);\n\n // Directories to bind on container\n const mountDirs = {\n [inputDir]: '/input',\n [outputDir]: '/output',\n };\n\n try {\n switch (this.options.runIn) {\n case 'local':\n await runCommand({\n command: 'mkdocs',\n args: ['build', '-d', outputDir, '-v'],\n options: {\n cwd: inputDir,\n },\n logStream,\n });\n childLogger.info(\n `Successfully generated docs from ${inputDir} into ${outputDir} using local mkdocs`,\n );\n break;\n case 'docker': {\n const containerRunner =\n this.containerRunner || new DockerContainerRunner();\n await containerRunner.runContainer({\n imageName:\n this.options.dockerImage ?? TechdocsGenerator.defaultDockerImage,\n args: ['build', '-d', '/output'],\n logStream,\n mountDirs,\n workingDir: '/input',\n // Set the home directory inside the container as something that applications can\n // write to, otherwise they will just fail trying to write to /\n envVars: { HOME: '/tmp' },\n pullImage: this.options.pullImage,\n defaultUser: runAsDefaultUser,\n });\n childLogger.info(\n `Successfully generated docs from ${inputDir} into ${outputDir} using techdocs-container`,\n );\n break;\n }\n default:\n throw new Error(\n `Invalid config value \"${this.options.runIn}\" provided in 'techdocs.generators.techdocs'.`,\n );\n }\n } catch (error) {\n this.logger.debug(\n `Failed to generate docs from ${inputDir} into ${outputDir}`,\n );\n throw new ForwardedError(\n `Failed to generate docs from ${inputDir} into ${outputDir}`,\n error,\n );\n }\n\n /**\n * Post Generate steps\n */\n\n // Add build timestamp and files to techdocs_metadata.json\n // Creates techdocs_metadata.json if file does not exist.\n await createOrUpdateMetadata(\n path.join(outputDir, 'techdocs_metadata.json'),\n childLogger,\n );\n\n // Add etag of the prepared tree to techdocs_metadata.json\n // Assumes that the file already exists.\n if (etag) {\n await storeEtagMetadata(\n path.join(outputDir, 'techdocs_metadata.json'),\n etag,\n );\n }\n }\n}\n\nexport function readGeneratorConfig(\n config: Config,\n logger: LoggerService,\n): GeneratorConfig {\n const legacyGeneratorType = config.getOptionalString(\n 'techdocs.generators.techdocs',\n ) as GeneratorRunInType;\n\n if (legacyGeneratorType) {\n logger.warn(\n `The 'techdocs.generators.techdocs' configuration key is deprecated and will be removed in the future. Please use 'techdocs.generator' instead. ` +\n `See here https://backstage.io/docs/features/techdocs/configuration`,\n );\n }\n\n return {\n runIn:\n legacyGeneratorType ??\n config.getOptionalString('techdocs.generator.runIn') ??\n 'docker',\n dockerImage: config.getOptionalString('techdocs.generator.dockerImage'),\n pullImage: config.getOptionalBoolean('techdocs.generator.pullImage'),\n omitTechdocsCoreMkdocsPlugin: config.getOptionalBoolean(\n 'techdocs.generator.mkdocs.omitTechdocsCorePlugin',\n ),\n legacyCopyReadmeMdToIndexMd: config.getOptionalBoolean(\n 'techdocs.generator.mkdocs.legacyCopyReadmeMdToIndexMd',\n ),\n defaultPlugins: config.getOptionalStringArray(\n 'techdocs.generator.mkdocs.defaultPlugins',\n ),\n };\n}\n"],"names":["ScmIntegrations","getMkdocsYml","validateMkdocsYaml","patchMkdocsYmlPreBuild","patchIndexPreBuild","patchMkdocsYmlWithPlugins","runCommand","DockerContainerRunner","ForwardedError","createOrUpdateMetadata","path","storeEtagMetadata"],"mappings":";;;;;;;;;;;;;AAmDO,MAAM,iBAAA,CAA2C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOtD,OAAuB,kBAAA,GAAqB,yBAAA;AAAA,EAC3B,MAAA;AAAA,EACA,eAAA;AAAA,EACA,OAAA;AAAA,EACA,eAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOjB,OAAO,UAAA,CAAW,MAAA,EAAgB,OAAA,EAA2B;AAC3D,IAAA,MAAM,EA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A,OAAO;AAAA,IACL,KAAA,EACE,mBAAA,IACA,MAAA,CAAO,iBAAA,CAAkB,0BAA0B,CAAA,IACnD,QAAA;AAAA,IACF,WAAA,EAAa,MAAA,CAAO,iBAAA,CAAkB,gCAAgC,CAAA;AAAA,IACtE,SAAA,EAAW,MAAA,CAAO,kBAAA,CAAmB,8BAA8B,CAAA;AAAA,IACnE,8BAA8B,MAAA,CAAO,kBAAA;AAAA,MACnC;AAAA,KACF;AAAA,IACA,6BAA6B,MAAA,CAAO,kBAAA;AAAA,MAClC;AAAA,KACF;AAAA,IACA,gBAAgB,MAAA,CAAO,sBAAA;AAAA,MACrB;AAAA;AACF,GACF;AACF;;;;;"}
|
|
@@ -12,6 +12,7 @@ var JSON5 = require('json5');
|
|
|
12
12
|
var createLimiter = require('p-limit');
|
|
13
13
|
var path = require('path');
|
|
14
14
|
var helpers = require('./helpers.cjs.js');
|
|
15
|
+
var integration = require('@backstage/integration');
|
|
15
16
|
|
|
16
17
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
17
18
|
|
|
@@ -74,8 +75,12 @@ class AwsS3Publish {
|
|
|
74
75
|
"techdocs.publisher.awsS3.credentials"
|
|
75
76
|
);
|
|
76
77
|
const credsManager = integrationAwsNode.DefaultAwsCredentialsManager.fromConfig(config);
|
|
78
|
+
const scmIntegrations = integration.ScmIntegrations.fromConfig(config);
|
|
79
|
+
const awsS3Integrations = scmIntegrations.awsS3.list();
|
|
77
80
|
const sdkCredentialProvider = await AwsS3Publish.buildCredentials(
|
|
78
81
|
credsManager,
|
|
82
|
+
logger,
|
|
83
|
+
awsS3Integrations,
|
|
79
84
|
accountId,
|
|
80
85
|
credentialsConfig,
|
|
81
86
|
region
|
|
@@ -131,17 +136,17 @@ class AwsS3Publish {
|
|
|
131
136
|
});
|
|
132
137
|
};
|
|
133
138
|
}
|
|
134
|
-
static async buildCredentials(credsManager, accountId,
|
|
139
|
+
static async buildCredentials(credsManager, logger, awsS3Integrations, accountId, credentialsConfig, region) {
|
|
135
140
|
if (accountId) {
|
|
136
141
|
return (await credsManager.getCredentialProvider({ accountId })).sdkCredentialProvider;
|
|
137
142
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const roleArn =
|
|
143
|
+
const explicitCredentials = await AwsS3Publish.getExplicitCredentials({
|
|
144
|
+
credsManager,
|
|
145
|
+
credentialsConfig,
|
|
146
|
+
awsS3Integrations,
|
|
147
|
+
logger
|
|
148
|
+
});
|
|
149
|
+
const roleArn = credentialsConfig?.getOptionalString("roleArn");
|
|
145
150
|
if (roleArn) {
|
|
146
151
|
return credentialProviders.fromTemporaryCredentials({
|
|
147
152
|
masterCredentials: explicitCredentials,
|
|
@@ -217,6 +222,51 @@ class AwsS3Publish {
|
|
|
217
222
|
(retriableError) => errorCode === retriableError || error.message.includes(retriableError)
|
|
218
223
|
);
|
|
219
224
|
}
|
|
225
|
+
static async getExplicitCredentials({
|
|
226
|
+
credentialsConfig,
|
|
227
|
+
awsS3Integrations,
|
|
228
|
+
credsManager,
|
|
229
|
+
logger
|
|
230
|
+
}) {
|
|
231
|
+
const accessKeyId = credentialsConfig?.getOptionalString("accessKeyId");
|
|
232
|
+
const secretAccessKey = credentialsConfig?.getOptionalString("secretAccessKey");
|
|
233
|
+
if (accessKeyId && secretAccessKey) {
|
|
234
|
+
return AwsS3Publish.buildStaticCredentials(accessKeyId, secretAccessKey);
|
|
235
|
+
}
|
|
236
|
+
if (awsS3Integrations.length > 0) {
|
|
237
|
+
if (awsS3Integrations.length === 1) {
|
|
238
|
+
const singleAwsS3IntegrationConfig = awsS3Integrations[0].config;
|
|
239
|
+
const singleAwsS3IntegrationAccessKeyId = singleAwsS3IntegrationConfig.accessKeyId;
|
|
240
|
+
const singleAwsS3IntegrationSecretAccessKey = singleAwsS3IntegrationConfig.secretAccessKey;
|
|
241
|
+
if (singleAwsS3IntegrationAccessKeyId && singleAwsS3IntegrationSecretAccessKey) {
|
|
242
|
+
return AwsS3Publish.buildStaticCredentials(
|
|
243
|
+
singleAwsS3IntegrationAccessKeyId,
|
|
244
|
+
singleAwsS3IntegrationSecretAccessKey
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
} else {
|
|
248
|
+
if (accessKeyId) {
|
|
249
|
+
const targetAwsS3IntegrationConfig = awsS3Integrations.find(
|
|
250
|
+
(c) => c.config.accessKeyId === accessKeyId
|
|
251
|
+
);
|
|
252
|
+
if (!targetAwsS3IntegrationConfig) {
|
|
253
|
+
logger.warn(
|
|
254
|
+
`No AWS S3 integration config under integrations.awsS3 found for access key id ${accessKeyId}.`
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
const targetAwsS3IntegrationAccessKeyId = targetAwsS3IntegrationConfig?.config.accessKeyId;
|
|
258
|
+
const targetAwsS3IntegrationSecretAccessKey = targetAwsS3IntegrationConfig?.config.secretAccessKey;
|
|
259
|
+
if (targetAwsS3IntegrationAccessKeyId && targetAwsS3IntegrationSecretAccessKey) {
|
|
260
|
+
return AwsS3Publish.buildStaticCredentials(
|
|
261
|
+
targetAwsS3IntegrationAccessKeyId,
|
|
262
|
+
targetAwsS3IntegrationSecretAccessKey
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return (await credsManager.getCredentialProvider()).sdkCredentialProvider;
|
|
269
|
+
}
|
|
220
270
|
/**
|
|
221
271
|
* Check if the defined bucket exists. Being able to connect means the configuration is good
|
|
222
272
|
* and the storage client will work.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"awsS3.cjs.js","sources":["../../../src/stages/publish/awsS3.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Entity, CompoundEntityRef } from '@backstage/catalog-model';\nimport { Config } from '@backstage/config';\nimport { assertError, ForwardedError } from '@backstage/errors';\n\n// Maximum size in bytes for a single upload part (5MB)\nconst MAX_SINGLE_UPLOAD_BYTES = 5 * 1024 * 1024;\n\nimport {\n AwsCredentialsManager,\n DefaultAwsCredentialsManager,\n} from '@backstage/integration-aws-node';\nimport {\n GetObjectCommand,\n CopyObjectCommand,\n DeleteObjectCommand,\n HeadBucketCommand,\n HeadObjectCommand,\n PutObjectCommand,\n PutObjectCommandInput,\n ListObjectsV2CommandOutput,\n ListObjectsV2Command,\n S3Client,\n S3ServiceException,\n} from '@aws-sdk/client-s3';\nimport { fromTemporaryCredentials } from '@aws-sdk/credential-providers';\nimport { NodeHttpHandler } from '@smithy/node-http-handler';\nimport { Upload } from '@aws-sdk/lib-storage';\nimport { AwsCredentialIdentityProvider } from '@aws-sdk/types';\nimport { HttpsProxyAgent } from 'hpagent';\nimport express from 'express';\nimport fs from 'fs-extra';\nimport JSON5 from 'json5';\nimport createLimiter from 'p-limit';\nimport path from 'path';\nimport { Readable } from 'stream';\nimport {\n bulkStorageOperation,\n getCloudPathForLocalPath,\n getFileTreeRecursively,\n getHeadersForFileExtension,\n getStaleFiles,\n isValidContentPath,\n lowerCaseEntityTriplet,\n lowerCaseEntityTripletInStoragePath,\n normalizeExternalStorageRootPath,\n} from './helpers';\nimport {\n PublisherBase,\n PublishRequest,\n PublishResponse,\n ReadinessResponse,\n TechDocsMetadata,\n} from './types';\nimport { LoggerService } from '@backstage/backend-plugin-api';\n\nconst streamToBuffer = (stream: Readable): Promise<Buffer> => {\n return new Promise((resolve, reject) => {\n try {\n const chunks: any[] = [];\n stream.on('data', chunk => chunks.push(chunk));\n stream.on('error', (e: Error) =>\n reject(new ForwardedError('Unable to read stream', e)),\n );\n stream.on('end', () => resolve(Buffer.concat(chunks)));\n } catch (e) {\n throw new ForwardedError('Unable to parse the response data', e);\n }\n });\n};\n\nexport class AwsS3Publish implements PublisherBase {\n public readonly storageClient: S3Client;\n private readonly bucketName: string;\n private readonly legacyPathCasing: boolean;\n private readonly logger: LoggerService;\n private readonly bucketRootPath: string;\n private readonly sse?: 'aws:kms' | 'AES256';\n private readonly maxAttempts: number;\n\n constructor(options: {\n storageClient: S3Client;\n bucketName: string;\n legacyPathCasing: boolean;\n logger: LoggerService;\n bucketRootPath: string;\n sse?: 'aws:kms' | 'AES256';\n maxAttempts: number;\n }) {\n this.storageClient = options.storageClient;\n this.bucketName = options.bucketName;\n this.legacyPathCasing = options.legacyPathCasing;\n this.logger = options.logger;\n this.bucketRootPath = options.bucketRootPath;\n this.sse = options.sse;\n this.maxAttempts = options.maxAttempts;\n }\n\n static async fromConfig(\n config: Config,\n logger: LoggerService,\n ): Promise<PublisherBase> {\n let bucketName = '';\n try {\n bucketName = config.getString('techdocs.publisher.awsS3.bucketName');\n } catch (error) {\n throw new Error(\n \"Since techdocs.publisher.type is set to 'awsS3' in your app config, \" +\n 'techdocs.publisher.awsS3.bucketName is required.',\n );\n }\n\n const bucketRootPath = normalizeExternalStorageRootPath(\n config.getOptionalString('techdocs.publisher.awsS3.bucketRootPath') || '',\n );\n\n const sse = config.getOptionalString('techdocs.publisher.awsS3.sse') as\n | 'aws:kms'\n | 'AES256'\n | undefined;\n\n // AWS Region is an optional config. If missing, default AWS env variable AWS_REGION\n // or AWS shared credentials file at ~/.aws/credentials will be used.\n const region = config.getOptionalString('techdocs.publisher.awsS3.region');\n\n // Credentials can optionally be configured by specifying the AWS account ID, which will retrieve credentials\n // for the account from the 'aws' section of the app config.\n // Credentials can also optionally be directly configured in the techdocs awsS3 config, but this method is\n // deprecated.\n // If no credentials are configured, the AWS SDK V3's default credential chain will be used.\n const accountId = config.getOptionalString(\n 'techdocs.publisher.awsS3.accountId',\n );\n const credentialsConfig = config.getOptionalConfig(\n 'techdocs.publisher.awsS3.credentials',\n );\n const credsManager = DefaultAwsCredentialsManager.fromConfig(config);\n const sdkCredentialProvider = await AwsS3Publish.buildCredentials(\n credsManager,\n accountId,\n credentialsConfig,\n region,\n );\n\n // AWS endpoint is an optional config. If missing, the default endpoint is built from\n // the configured region.\n const endpoint = config.getOptionalString(\n 'techdocs.publisher.awsS3.endpoint',\n );\n\n // AWS HTTPS proxy is an optional config. If missing, no proxy is used\n const httpsProxy = config.getOptionalString(\n 'techdocs.publisher.awsS3.httpsProxy',\n );\n\n // AWS forcePathStyle is an optional config. If missing, it defaults to false. Needs to be enabled for cases\n // where endpoint url points to locally hosted S3 compatible storage like Localstack\n const forcePathStyle = config.getOptionalBoolean(\n 'techdocs.publisher.awsS3.s3ForcePathStyle',\n );\n\n // AWS MAX ATTEMPTS is an optional config. If missing, default value of 5 is used\n const maxAttempts = config.getOptionalNumber(\n 'techdocs.publisher.awsS3.maxAttempts',\n );\n\n const storageClient = new S3Client({\n customUserAgent: 'backstage-aws-techdocs-s3-publisher',\n credentialDefaultProvider: () => sdkCredentialProvider,\n ...(region && { region }),\n ...(endpoint && { endpoint }),\n ...(forcePathStyle && { forcePathStyle }),\n // Enhanced retry configuration for better reliability\n maxAttempts: maxAttempts || 5,\n retryMode: 'adaptive',\n // Enhanced connection settings for large file uploads\n requestHandler: new NodeHttpHandler({\n ...(httpsProxy && {\n httpsAgent: new HttpsProxyAgent({ proxy: httpsProxy }),\n }),\n connectionTimeout: 60000,\n socketTimeout: 120000,\n }),\n });\n\n const legacyPathCasing =\n config.getOptionalBoolean(\n 'techdocs.legacyUseCaseSensitiveTripletPaths',\n ) || false;\n\n return new AwsS3Publish({\n storageClient,\n bucketName,\n bucketRootPath,\n legacyPathCasing,\n logger,\n sse,\n maxAttempts: maxAttempts || 5,\n });\n }\n\n private static buildStaticCredentials(\n accessKeyId: string,\n secretAccessKey: string,\n ): AwsCredentialIdentityProvider {\n return async () => {\n return Promise.resolve({\n accessKeyId,\n secretAccessKey,\n });\n };\n }\n\n private static async buildCredentials(\n credsManager: AwsCredentialsManager,\n accountId?: string,\n config?: Config,\n region?: string,\n ): Promise<AwsCredentialIdentityProvider> {\n // Pull credentials for the specified account ID from the 'aws' config section\n if (accountId) {\n return (await credsManager.getCredentialProvider({ accountId }))\n .sdkCredentialProvider;\n }\n\n // Fall back to the default credential chain if neither account ID\n // nor explicit credentials are provided\n if (!config) {\n return (await credsManager.getCredentialProvider()).sdkCredentialProvider;\n }\n\n // Pull credentials from the techdocs config section (deprecated)\n const accessKeyId = config.getOptionalString('accessKeyId');\n const secretAccessKey = config.getOptionalString('secretAccessKey');\n const explicitCredentials: AwsCredentialIdentityProvider =\n accessKeyId && secretAccessKey\n ? AwsS3Publish.buildStaticCredentials(accessKeyId, secretAccessKey)\n : (await credsManager.getCredentialProvider()).sdkCredentialProvider;\n\n const roleArn = config.getOptionalString('roleArn');\n if (roleArn) {\n return fromTemporaryCredentials({\n masterCredentials: explicitCredentials,\n params: {\n RoleSessionName: 'backstage-aws-techdocs-s3-publisher',\n RoleArn: roleArn,\n },\n clientConfig: { region },\n });\n }\n\n return explicitCredentials;\n }\n /**\n * Custom retry wrapper for S3 operations with detailed error handling.\n */\n public async retryOperation<TOutput>(\n operation: () => Promise<TOutput>,\n operationName: string,\n maxAttempts: number = 3,\n shouldRetry: (\n error: S3ServiceException,\n ) => boolean = this.defaultShouldRetry.bind(this),\n ): Promise<TOutput> {\n for (let attempt = 1; attempt < maxAttempts; attempt++) {\n try {\n return await operation();\n } catch (error) {\n const e = error as S3ServiceException;\n if (!shouldRetry(e)) {\n this.logger.error(`${operationName} failed: ${e.message}`);\n throw e;\n }\n\n this.logger.warn(`${operationName} failed, retrying...`, {\n attempt,\n maxAttempts,\n error: e.message,\n errorCode: e.name,\n httpStatusCode: e.$metadata?.httpStatusCode,\n });\n\n // Enhanced exponential backoff with jitter\n const baseDelay = operationName.startsWith('Upload-') ? 2000 : 1000;\n const backoffDelay = Math.min(\n baseDelay * Math.pow(2, attempt - 1),\n 30000,\n );\n const jitter = Math.random() * 1000;\n await new Promise(resolve =>\n setTimeout(resolve, backoffDelay + jitter),\n );\n }\n }\n return await operation();\n }\n\n /**\n * Determines if an S3 operation should be retried based on the error details.\n */\n private defaultShouldRetry(error: S3ServiceException): boolean {\n const httpStatusCode = error.$metadata?.httpStatusCode;\n const errorCode = error.name;\n\n // Truly transient errors that should always be retried\n const transientErrors = [\n 'NetworkingError',\n 'TimeoutError',\n 'ConnectionError',\n 'RequestTimeout',\n 'ServiceUnavailable',\n 'SlowDown',\n 'ThrottlingException',\n ];\n\n // Server errors are always considered transient\n if (httpStatusCode && httpStatusCode >= 500) {\n return true;\n }\n\n // Specific 4xx errors that are known to be transient\n if (httpStatusCode && httpStatusCode >= 400 && httpStatusCode < 500) {\n const retriable4xxErrors = [\n 'RequestTimeout',\n 'RequestTimeoutException',\n 'PriorRequestNotComplete',\n ];\n return retriable4xxErrors.includes(errorCode);\n }\n\n // Check against known transient errors\n return transientErrors.some(\n retriableError =>\n errorCode === retriableError || error.message.includes(retriableError),\n );\n }\n\n /**\n * Check if the defined bucket exists. Being able to connect means the configuration is good\n * and the storage client will work.\n */\n async getReadiness(): Promise<ReadinessResponse> {\n try {\n await this.storageClient.send(\n new HeadBucketCommand({ Bucket: this.bucketName }),\n );\n\n this.logger.info(\n `Successfully connected to the AWS S3 bucket ${this.bucketName}.`,\n );\n\n return { isAvailable: true };\n } catch (error) {\n this.logger.error(\n `Could not retrieve metadata about the AWS S3 bucket ${this.bucketName}. ` +\n 'Make sure the bucket exists. Also make sure that authentication is setup either by ' +\n 'explicitly defining credentials and region in techdocs.publisher.awsS3 in app config or ' +\n 'by using environment variables. Refer to https://backstage.io/docs/features/techdocs/using-cloud-storage',\n );\n this.logger.error(\n `from AWS client library`,\n error instanceof Error ? error : new Error(String(error)),\n );\n return {\n isAvailable: false,\n };\n }\n }\n /**\n * Upload all the files from the generated `directory` to the S3 bucket.\n * Directory structure used in the bucket is - entityNamespace/entityKind/entityName/index.html\n */\n async publish({\n entity,\n directory,\n }: PublishRequest): Promise<PublishResponse> {\n const objects: string[] = [];\n const useLegacyPathCasing = this.legacyPathCasing;\n const bucketRootPath = this.bucketRootPath;\n const sse = this.sse;\n\n // Track timing for performance monitoring\n const publishStartTime = Date.now();\n\n // First, try to retrieve a list of all individual files currently existing\n let existingFiles: string[] = [];\n try {\n const remoteFolder = getCloudPathForLocalPath(\n entity,\n undefined,\n useLegacyPathCasing,\n bucketRootPath,\n );\n const response = await this.retryOperation(\n async () => {\n const listCommand = new ListObjectsV2Command({\n Bucket: this.bucketName,\n Prefix: remoteFolder,\n });\n return this.storageClient.send(listCommand);\n },\n 'ListObjects',\n this.maxAttempts,\n );\n existingFiles = (response.Contents || [])\n .map(f => f.Key || '')\n .filter(f => !!f);\n } catch (e) {\n assertError(e);\n this.logger.error(\n `Unable to list files for Entity ${entity.metadata.name}: ${e.message}`,\n );\n }\n\n // Then, merge new files into the same folder\n let absoluteFilesToUpload;\n try {\n // Remove the absolute path prefix of the source directory\n // Path of all files to upload, relative to the root of the source directory\n // e.g. ['index.html', 'sub-page/index.html', 'assets/images/favicon.png']\n absoluteFilesToUpload = await getFileTreeRecursively(directory);\n\n await bulkStorageOperation(\n async absoluteFilePath => {\n const relativeFilePath = path.relative(directory, absoluteFilePath);\n const s3Key = getCloudPathForLocalPath(\n entity,\n relativeFilePath,\n useLegacyPathCasing,\n bucketRootPath,\n );\n // Create params without the Body because the body must be the\n // actual file contents (Buffer or Readable), not the path string.\n // For multipart uploads we attach a Readable stream to avoid\n // buffering large files in memory. For simple uploads we attach\n // a Buffer read from disk.\n const params: PutObjectCommandInput = {\n Bucket: this.bucketName,\n Key: s3Key,\n ...(sse && { ServerSideEncryption: sse }),\n };\n\n objects.push(params.Key!);\n // Get file stats before upload\n const stats = await fs.stat(absoluteFilePath);\n const fileSizeInBytes = stats.size;\n\n // Check if this is a large file that requires multipart upload\n if (fileSizeInBytes >= MAX_SINGLE_UPLOAD_BYTES) {\n // Try multipart upload for large files\n try {\n // Create stream and Upload inside retry closure so stream is\n // recreated on each retry attempt (streams are consumable once).\n await this.retryOperation(\n () => {\n // Create a fresh stream on each attempt\n const fileStream = fs.createReadStream(absoluteFilePath);\n const uploadParams = { ...params, Body: fileStream };\n\n const upload = new Upload({\n client: this.storageClient,\n params: uploadParams,\n partSize: MAX_SINGLE_UPLOAD_BYTES,\n queueSize: 3,\n leavePartsOnError: false,\n });\n return upload.done();\n },\n `Upload-${params.Key}`,\n this.maxAttempts,\n );\n return;\n } catch (multipartError) {\n const s3Error = multipartError as any;\n const errorName = s3Error?.name || 'Unknown';\n\n // For specific multipart errors, attempt simple upload fallback\n if (errorName === 'InvalidPart' || errorName === 'NoSuchUpload') {\n this.logger.warn(\n `Multipart upload failed for ${params.Key}, attempting simple upload fallback.`,\n );\n } else {\n // Non-recoverable multipart error, throw it\n this.logger.error(\n `Multipart upload failed for ${params.Key}: ${\n multipartError instanceof Error\n ? multipartError.message\n : String(multipartError)\n }`,\n );\n throw multipartError;\n }\n }\n }\n\n // Use simple upload for small files or as fallback from multipart\n try {\n const fileContent = await fs.readFile(absoluteFilePath);\n const putParams = { ...params, Body: fileContent };\n await this.retryOperation(\n () => this.storageClient.send(new PutObjectCommand(putParams)),\n `Upload-${params.Key}`,\n this.maxAttempts,\n );\n\n if (fileSizeInBytes >= MAX_SINGLE_UPLOAD_BYTES) {\n this.logger.info(\n `Simple upload fallback succeeded for ${params.Key}`,\n );\n }\n } catch (error) {\n this.logger.error(\n `Upload failed for ${params.Key}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n throw error;\n }\n },\n absoluteFilesToUpload,\n { concurrencyLimit: 10 },\n );\n\n this.logger.info(\n `Successfully uploaded all the generated files for Entity ${entity.metadata.name}. Total number of files: ${absoluteFilesToUpload.length}`,\n );\n } catch (e) {\n const errorMessage = `Unable to upload file(s) to AWS S3. ${e}`;\n this.logger.error(errorMessage);\n throw new Error(errorMessage);\n }\n\n // Last, try to remove the files that were *only* present previously\n try {\n const relativeFilesToUpload = absoluteFilesToUpload.map(\n absoluteFilePath =>\n getCloudPathForLocalPath(\n entity,\n path.relative(directory, absoluteFilePath),\n useLegacyPathCasing,\n bucketRootPath,\n ),\n );\n const staleFiles = getStaleFiles(relativeFilesToUpload, existingFiles);\n\n await bulkStorageOperation(\n async relativeFilePath => {\n return this.retryOperation(\n async () => {\n const deleteCommand = new DeleteObjectCommand({\n Bucket: this.bucketName,\n Key: relativeFilePath,\n });\n return this.storageClient.send(deleteCommand);\n },\n 'DeleteObject',\n this.maxAttempts,\n );\n },\n staleFiles,\n { concurrencyLimit: 10 },\n );\n this.logger.info(\n `Successfully deleted stale files for Entity ${entity.metadata.name}. Total number of files: ${staleFiles.length}`,\n );\n } catch (error) {\n const errorMessage = `Unable to delete file(s) from AWS S3. ${error}`;\n this.logger.error(errorMessage);\n }\n const publishEndTime = Date.now();\n const publishDurationMs = publishEndTime - publishStartTime;\n this.logger.info(\n `Successfully published ${objects.length} files for ${\n entity.metadata.name\n } in ${Math.round(publishDurationMs / 1000)}s`,\n );\n return { objects };\n }\n\n async fetchTechDocsMetadata(\n entityName: CompoundEntityRef,\n ): Promise<TechDocsMetadata> {\n try {\n return await new Promise<TechDocsMetadata>(async (resolve, reject) => {\n const entityTriplet = `${entityName.namespace}/${entityName.kind}/${entityName.name}`;\n const entityDir = this.legacyPathCasing\n ? entityTriplet\n : lowerCaseEntityTriplet(entityTriplet);\n\n const entityRootDir = path.posix.join(this.bucketRootPath, entityDir);\n if (!isValidContentPath(this.bucketRootPath, entityRootDir)) {\n this.logger.error(\n `Invalid content path found while fetching TechDocs metadata: ${entityRootDir}`,\n );\n throw new Error(`Metadata Not Found`);\n }\n\n try {\n const resp = await this.retryOperation(\n async () => {\n const getCommand = new GetObjectCommand({\n Bucket: this.bucketName,\n Key: `${entityRootDir}/techdocs_metadata.json`,\n });\n return this.storageClient.send(getCommand);\n },\n 'GetTechDocsMetadata',\n this.maxAttempts,\n );\n\n const techdocsMetadataJson = await streamToBuffer(\n resp.Body as Readable,\n );\n if (!techdocsMetadataJson) {\n throw new Error(\n `Unable to parse the techdocs metadata file ${entityRootDir}/techdocs_metadata.json.`,\n );\n }\n\n const techdocsMetadata = JSON5.parse(\n techdocsMetadataJson.toString('utf-8'),\n );\n\n resolve(techdocsMetadata);\n } catch (err) {\n assertError(err);\n this.logger.error(err.message);\n reject(new Error(err.message));\n }\n });\n } catch (e) {\n throw new ForwardedError('TechDocs metadata fetch failed', e);\n }\n }\n\n /**\n * Express route middleware to serve static files on a route in techdocs-backend.\n */\n docsRouter(): express.Handler {\n return async (req, res) => {\n const decodedUri = decodeURI(req.path.replace(/^\\//, ''));\n\n // filePath example - /default/component/documented-component/index.html\n const filePathNoRoot = this.legacyPathCasing\n ? decodedUri\n : lowerCaseEntityTripletInStoragePath(decodedUri);\n\n // Prepend the root path to the relative file path\n const filePath = path.posix.join(this.bucketRootPath, filePathNoRoot);\n if (!isValidContentPath(this.bucketRootPath, filePath)) {\n this.logger.error(\n `Attempted to fetch TechDocs content for a file outside of the bucket root: ${filePathNoRoot}`,\n );\n res.status(404).send('File Not Found');\n return;\n }\n\n // Files with different extensions (CSS, HTML) need to be served with different headers\n const fileExtension = path.extname(filePath);\n const responseHeaders = getHeadersForFileExtension(fileExtension);\n\n try {\n const resp = await this.storageClient.send(\n new GetObjectCommand({ Bucket: this.bucketName, Key: filePath }),\n );\n\n // Inject response headers\n for (const [headerKey, headerValue] of Object.entries(\n responseHeaders,\n )) {\n res.setHeader(headerKey, headerValue);\n }\n\n (resp.Body as Readable)\n .on('error', err => {\n this.logger.warn(\n `TechDocs S3 router failed to serve static files from bucket ${this.bucketName} at key ${filePath}: ${err.message}`,\n );\n if (!res.headersSent) {\n res.status(404).send('File Not Found');\n } else {\n res.destroy();\n }\n })\n .pipe(res);\n } catch (err) {\n assertError(err);\n this.logger.warn(\n `TechDocs S3 router failed to serve static files from bucket ${this.bucketName} at key ${filePath}: ${err.message}`,\n );\n res.status(404).send('File Not Found');\n }\n };\n }\n\n /**\n * A helper function which checks if index.html of an Entity's docs site is available. This\n * can be used to verify if there are any pre-generated docs available to serve.\n */\n async hasDocsBeenGenerated(entity: Entity): Promise<boolean> {\n try {\n const entityTriplet = `${entity.metadata.namespace}/${entity.kind}/${entity.metadata.name}`;\n const entityDir = this.legacyPathCasing\n ? entityTriplet\n : lowerCaseEntityTriplet(entityTriplet);\n\n const entityRootDir = path.posix.join(this.bucketRootPath, entityDir);\n if (!isValidContentPath(this.bucketRootPath, entityRootDir)) {\n this.logger.error(\n `Invalid content path found while checking if docs have been generated: ${entityRootDir}`,\n );\n return Promise.resolve(false);\n }\n\n await this.storageClient.send(\n new HeadObjectCommand({\n Bucket: this.bucketName,\n Key: `${entityRootDir}/index.html`,\n }),\n );\n return Promise.resolve(true);\n } catch (e) {\n return Promise.resolve(false);\n }\n }\n\n async migrateDocsCase({\n removeOriginal = false,\n concurrency = 25,\n }): Promise<void> {\n // Iterate through every file in the root of the publisher.\n const allObjects = await this.getAllObjectsFromBucket();\n const limiter = createLimiter(concurrency);\n await Promise.all(\n allObjects.map(f =>\n limiter(async file => {\n let newPath;\n try {\n newPath = lowerCaseEntityTripletInStoragePath(file);\n } catch (e) {\n assertError(e);\n this.logger.warn(e.message);\n return;\n }\n\n // If all parts are already lowercase, ignore.\n if (file === newPath) {\n return;\n }\n\n try {\n this.logger.debug(`Migrating ${file}`);\n await this.storageClient.send(\n new CopyObjectCommand({\n Bucket: this.bucketName,\n CopySource: [this.bucketName, file].join('/'),\n Key: newPath,\n }),\n );\n\n if (removeOriginal) {\n await this.storageClient.send(\n new DeleteObjectCommand({\n Bucket: this.bucketName,\n Key: file,\n }),\n );\n }\n } catch (e) {\n assertError(e);\n this.logger.warn(`Unable to migrate ${file}: ${e.message}`);\n }\n }, f),\n ),\n );\n }\n\n /**\n * Returns a list of all object keys from the configured bucket.\n */\n protected async getAllObjectsFromBucket(\n { prefix } = { prefix: '' },\n ): Promise<string[]> {\n const objects: string[] = [];\n let nextContinuation: string | undefined;\n let allObjects: ListObjectsV2CommandOutput;\n // Iterate through every file in the root of the publisher.\n do {\n const currentToken = nextContinuation;\n allObjects = await this.retryOperation(\n async () => {\n const listCommand = new ListObjectsV2Command({\n Bucket: this.bucketName,\n ContinuationToken: currentToken,\n ...(prefix ? { Prefix: prefix } : {}),\n });\n return this.storageClient.send(listCommand);\n },\n 'GetAllObjects',\n this.maxAttempts,\n );\n objects.push(\n ...(allObjects.Contents || []).map(f => f.Key || '').filter(f => !!f),\n );\n nextContinuation = allObjects.NextContinuationToken;\n } while (nextContinuation);\n\n return objects;\n }\n}\n"],"names":["ForwardedError","normalizeExternalStorageRootPath","DefaultAwsCredentialsManager","S3Client","NodeHttpHandler","HttpsProxyAgent","fromTemporaryCredentials","HeadBucketCommand","getCloudPathForLocalPath","ListObjectsV2Command","assertError","getFileTreeRecursively","bulkStorageOperation","path","fs","Upload","PutObjectCommand","getStaleFiles","DeleteObjectCommand","lowerCaseEntityTriplet","isValidContentPath","GetObjectCommand","JSON5","lowerCaseEntityTripletInStoragePath","getHeadersForFileExtension","HeadObjectCommand","createLimiter","CopyObjectCommand"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,uBAAA,GAA0B,IAAI,IAAA,GAAO,IAAA;AAkD3C,MAAM,cAAA,GAAiB,CAAC,MAAA,KAAsC;AAC5D,EAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,OAAA,EAAS,MAAA,KAAW;AACtC,IAAA,IAAI;AACF,MAAA,MAAM,SAAgB,EAAC;AACvB,MAAA,MAAA,CAAO,GAAG,MAAA,EAAQ,CAAA,KAAA,KAAS,MAAA,CAAO,IAAA,CAAK,KAAK,CAAC,CAAA;AAC7C,MAAA,MAAA,CAAO,EAAA;AAAA,QAAG,OAAA;AAAA,QAAS,CAAC,CAAA,KAClB,MAAA,CAAO,IAAIA,qB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AA,EACT;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"awsS3.cjs.js","sources":["../../../src/stages/publish/awsS3.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Entity, CompoundEntityRef } from '@backstage/catalog-model';\nimport { Config } from '@backstage/config';\nimport { assertError, ForwardedError } from '@backstage/errors';\n\n// Maximum size in bytes for a single upload part (5MB)\nconst MAX_SINGLE_UPLOAD_BYTES = 5 * 1024 * 1024;\n\nimport {\n AwsCredentialsManager,\n DefaultAwsCredentialsManager,\n} from '@backstage/integration-aws-node';\nimport {\n GetObjectCommand,\n CopyObjectCommand,\n DeleteObjectCommand,\n HeadBucketCommand,\n HeadObjectCommand,\n PutObjectCommand,\n PutObjectCommandInput,\n ListObjectsV2CommandOutput,\n ListObjectsV2Command,\n S3Client,\n S3ServiceException,\n} from '@aws-sdk/client-s3';\nimport { fromTemporaryCredentials } from '@aws-sdk/credential-providers';\nimport { NodeHttpHandler } from '@smithy/node-http-handler';\nimport { Upload } from '@aws-sdk/lib-storage';\nimport { AwsCredentialIdentityProvider } from '@aws-sdk/types';\nimport { HttpsProxyAgent } from 'hpagent';\nimport express from 'express';\nimport fs from 'fs-extra';\nimport JSON5 from 'json5';\nimport createLimiter from 'p-limit';\nimport path from 'path';\nimport { Readable } from 'stream';\nimport {\n bulkStorageOperation,\n getCloudPathForLocalPath,\n getFileTreeRecursively,\n getHeadersForFileExtension,\n getStaleFiles,\n isValidContentPath,\n lowerCaseEntityTriplet,\n lowerCaseEntityTripletInStoragePath,\n normalizeExternalStorageRootPath,\n} from './helpers';\nimport {\n PublisherBase,\n PublishRequest,\n PublishResponse,\n ReadinessResponse,\n TechDocsMetadata,\n} from './types';\nimport { LoggerService } from '@backstage/backend-plugin-api';\nimport { AwsS3Integration, ScmIntegrations } from '@backstage/integration';\n\nconst streamToBuffer = (stream: Readable): Promise<Buffer> => {\n return new Promise((resolve, reject) => {\n try {\n const chunks: any[] = [];\n stream.on('data', chunk => chunks.push(chunk));\n stream.on('error', (e: Error) =>\n reject(new ForwardedError('Unable to read stream', e)),\n );\n stream.on('end', () => resolve(Buffer.concat(chunks)));\n } catch (e) {\n throw new ForwardedError('Unable to parse the response data', e);\n }\n });\n};\n\nexport class AwsS3Publish implements PublisherBase {\n public readonly storageClient: S3Client;\n private readonly bucketName: string;\n private readonly legacyPathCasing: boolean;\n private readonly logger: LoggerService;\n private readonly bucketRootPath: string;\n private readonly sse?: 'aws:kms' | 'AES256';\n private readonly maxAttempts: number;\n\n constructor(options: {\n storageClient: S3Client;\n bucketName: string;\n legacyPathCasing: boolean;\n logger: LoggerService;\n bucketRootPath: string;\n sse?: 'aws:kms' | 'AES256';\n maxAttempts: number;\n }) {\n this.storageClient = options.storageClient;\n this.bucketName = options.bucketName;\n this.legacyPathCasing = options.legacyPathCasing;\n this.logger = options.logger;\n this.bucketRootPath = options.bucketRootPath;\n this.sse = options.sse;\n this.maxAttempts = options.maxAttempts;\n }\n\n static async fromConfig(\n config: Config,\n logger: LoggerService,\n ): Promise<PublisherBase> {\n let bucketName = '';\n try {\n bucketName = config.getString('techdocs.publisher.awsS3.bucketName');\n } catch (error) {\n throw new Error(\n \"Since techdocs.publisher.type is set to 'awsS3' in your app config, \" +\n 'techdocs.publisher.awsS3.bucketName is required.',\n );\n }\n\n const bucketRootPath = normalizeExternalStorageRootPath(\n config.getOptionalString('techdocs.publisher.awsS3.bucketRootPath') || '',\n );\n\n const sse = config.getOptionalString('techdocs.publisher.awsS3.sse') as\n | 'aws:kms'\n | 'AES256'\n | undefined;\n\n // AWS Region is an optional config. If missing, default AWS env variable AWS_REGION\n // or AWS shared credentials file at ~/.aws/credentials will be used.\n const region = config.getOptionalString('techdocs.publisher.awsS3.region');\n\n // Credentials can optionally be configured by specifying the AWS account ID, which will retrieve credentials\n // for the account from the 'aws' section of the app config.\n // Credentials can also optionally be directly configured in the techdocs awsS3 config, but this method is\n // deprecated.\n // If no credentials are configured, the AWS SDK V3's default credential chain will be used.\n const accountId = config.getOptionalString(\n 'techdocs.publisher.awsS3.accountId',\n );\n const credentialsConfig = config.getOptionalConfig(\n 'techdocs.publisher.awsS3.credentials',\n );\n\n const credsManager = DefaultAwsCredentialsManager.fromConfig(config);\n\n const scmIntegrations = ScmIntegrations.fromConfig(config);\n const awsS3Integrations = scmIntegrations.awsS3.list();\n\n const sdkCredentialProvider = await AwsS3Publish.buildCredentials(\n credsManager,\n logger,\n awsS3Integrations,\n accountId,\n credentialsConfig,\n region,\n );\n\n // AWS endpoint is an optional config. If missing, the default endpoint is built from\n // the configured region.\n const endpoint = config.getOptionalString(\n 'techdocs.publisher.awsS3.endpoint',\n );\n\n // AWS HTTPS proxy is an optional config. If missing, no proxy is used\n const httpsProxy = config.getOptionalString(\n 'techdocs.publisher.awsS3.httpsProxy',\n );\n\n // AWS forcePathStyle is an optional config. If missing, it defaults to false. Needs to be enabled for cases\n // where endpoint url points to locally hosted S3 compatible storage like Localstack\n const forcePathStyle = config.getOptionalBoolean(\n 'techdocs.publisher.awsS3.s3ForcePathStyle',\n );\n\n // AWS MAX ATTEMPTS is an optional config. If missing, default value of 5 is used\n const maxAttempts = config.getOptionalNumber(\n 'techdocs.publisher.awsS3.maxAttempts',\n );\n\n const storageClient = new S3Client({\n customUserAgent: 'backstage-aws-techdocs-s3-publisher',\n credentialDefaultProvider: () => sdkCredentialProvider,\n ...(region && { region }),\n ...(endpoint && { endpoint }),\n ...(forcePathStyle && { forcePathStyle }),\n // Enhanced retry configuration for better reliability\n maxAttempts: maxAttempts || 5,\n retryMode: 'adaptive',\n // Enhanced connection settings for large file uploads\n requestHandler: new NodeHttpHandler({\n ...(httpsProxy && {\n httpsAgent: new HttpsProxyAgent({ proxy: httpsProxy }),\n }),\n connectionTimeout: 60000,\n socketTimeout: 120000,\n }),\n });\n\n const legacyPathCasing =\n config.getOptionalBoolean(\n 'techdocs.legacyUseCaseSensitiveTripletPaths',\n ) || false;\n\n return new AwsS3Publish({\n storageClient,\n bucketName,\n bucketRootPath,\n legacyPathCasing,\n logger,\n sse,\n maxAttempts: maxAttempts || 5,\n });\n }\n\n private static buildStaticCredentials(\n accessKeyId: string,\n secretAccessKey: string,\n ): AwsCredentialIdentityProvider {\n return async () => {\n return Promise.resolve({\n accessKeyId,\n secretAccessKey,\n });\n };\n }\n\n private static async buildCredentials(\n credsManager: AwsCredentialsManager,\n logger: LoggerService,\n awsS3Integrations: AwsS3Integration[],\n accountId?: string,\n credentialsConfig?: Config,\n region?: string,\n ): Promise<AwsCredentialIdentityProvider> {\n // Pull credentials for the specified account ID from the 'aws' config section\n if (accountId) {\n return (await credsManager.getCredentialProvider({ accountId }))\n .sdkCredentialProvider;\n }\n\n const explicitCredentials = await AwsS3Publish.getExplicitCredentials({\n credsManager,\n credentialsConfig,\n awsS3Integrations,\n logger,\n });\n\n const roleArn = credentialsConfig?.getOptionalString('roleArn');\n if (roleArn) {\n return fromTemporaryCredentials({\n masterCredentials: explicitCredentials,\n params: {\n RoleSessionName: 'backstage-aws-techdocs-s3-publisher',\n RoleArn: roleArn,\n },\n clientConfig: { region },\n });\n }\n\n return explicitCredentials;\n }\n /**\n * Custom retry wrapper for S3 operations with detailed error handling.\n */\n public async retryOperation<TOutput>(\n operation: () => Promise<TOutput>,\n operationName: string,\n maxAttempts: number = 3,\n shouldRetry: (\n error: S3ServiceException,\n ) => boolean = this.defaultShouldRetry.bind(this),\n ): Promise<TOutput> {\n for (let attempt = 1; attempt < maxAttempts; attempt++) {\n try {\n return await operation();\n } catch (error) {\n const e = error as S3ServiceException;\n if (!shouldRetry(e)) {\n this.logger.error(`${operationName} failed: ${e.message}`);\n throw e;\n }\n\n this.logger.warn(`${operationName} failed, retrying...`, {\n attempt,\n maxAttempts,\n error: e.message,\n errorCode: e.name,\n httpStatusCode: e.$metadata?.httpStatusCode,\n });\n\n // Enhanced exponential backoff with jitter\n const baseDelay = operationName.startsWith('Upload-') ? 2000 : 1000;\n const backoffDelay = Math.min(\n baseDelay * Math.pow(2, attempt - 1),\n 30000,\n );\n const jitter = Math.random() * 1000;\n await new Promise(resolve =>\n setTimeout(resolve, backoffDelay + jitter),\n );\n }\n }\n return await operation();\n }\n\n /**\n * Determines if an S3 operation should be retried based on the error details.\n */\n private defaultShouldRetry(error: S3ServiceException): boolean {\n const httpStatusCode = error.$metadata?.httpStatusCode;\n const errorCode = error.name;\n\n // Truly transient errors that should always be retried\n const transientErrors = [\n 'NetworkingError',\n 'TimeoutError',\n 'ConnectionError',\n 'RequestTimeout',\n 'ServiceUnavailable',\n 'SlowDown',\n 'ThrottlingException',\n ];\n\n // Server errors are always considered transient\n if (httpStatusCode && httpStatusCode >= 500) {\n return true;\n }\n\n // Specific 4xx errors that are known to be transient\n if (httpStatusCode && httpStatusCode >= 400 && httpStatusCode < 500) {\n const retriable4xxErrors = [\n 'RequestTimeout',\n 'RequestTimeoutException',\n 'PriorRequestNotComplete',\n ];\n return retriable4xxErrors.includes(errorCode);\n }\n\n // Check against known transient errors\n return transientErrors.some(\n retriableError =>\n errorCode === retriableError || error.message.includes(retriableError),\n );\n }\n\n private static async getExplicitCredentials({\n credentialsConfig,\n awsS3Integrations,\n credsManager,\n logger,\n }: {\n credentialsConfig?: Config;\n awsS3Integrations: AwsS3Integration[];\n credsManager: AwsCredentialsManager;\n logger: LoggerService;\n }): Promise<AwsCredentialIdentityProvider> {\n const accessKeyId = credentialsConfig?.getOptionalString('accessKeyId');\n const secretAccessKey =\n credentialsConfig?.getOptionalString('secretAccessKey');\n\n if (accessKeyId && secretAccessKey) {\n return AwsS3Publish.buildStaticCredentials(accessKeyId, secretAccessKey);\n }\n\n if (awsS3Integrations.length > 0) {\n if (awsS3Integrations.length === 1) {\n const singleAwsS3IntegrationConfig = awsS3Integrations[0].config;\n\n const singleAwsS3IntegrationAccessKeyId =\n singleAwsS3IntegrationConfig.accessKeyId;\n\n const singleAwsS3IntegrationSecretAccessKey =\n singleAwsS3IntegrationConfig.secretAccessKey;\n\n if (\n singleAwsS3IntegrationAccessKeyId &&\n singleAwsS3IntegrationSecretAccessKey\n ) {\n return AwsS3Publish.buildStaticCredentials(\n singleAwsS3IntegrationAccessKeyId,\n singleAwsS3IntegrationSecretAccessKey,\n );\n }\n } else {\n if (accessKeyId) {\n const targetAwsS3IntegrationConfig = awsS3Integrations.find(\n c => c.config.accessKeyId === accessKeyId,\n );\n\n if (!targetAwsS3IntegrationConfig) {\n logger.warn(\n `No AWS S3 integration config under integrations.awsS3 found for access key id ${accessKeyId}.`,\n );\n }\n const targetAwsS3IntegrationAccessKeyId =\n targetAwsS3IntegrationConfig?.config.accessKeyId;\n const targetAwsS3IntegrationSecretAccessKey =\n targetAwsS3IntegrationConfig?.config.secretAccessKey;\n if (\n targetAwsS3IntegrationAccessKeyId &&\n targetAwsS3IntegrationSecretAccessKey\n ) {\n return AwsS3Publish.buildStaticCredentials(\n targetAwsS3IntegrationAccessKeyId,\n targetAwsS3IntegrationSecretAccessKey,\n );\n }\n }\n }\n }\n return (await credsManager.getCredentialProvider()).sdkCredentialProvider;\n }\n\n /**\n * Check if the defined bucket exists. Being able to connect means the configuration is good\n * and the storage client will work.\n */\n async getReadiness(): Promise<ReadinessResponse> {\n try {\n await this.storageClient.send(\n new HeadBucketCommand({ Bucket: this.bucketName }),\n );\n\n this.logger.info(\n `Successfully connected to the AWS S3 bucket ${this.bucketName}.`,\n );\n\n return { isAvailable: true };\n } catch (error) {\n this.logger.error(\n `Could not retrieve metadata about the AWS S3 bucket ${this.bucketName}. ` +\n 'Make sure the bucket exists. Also make sure that authentication is setup either by ' +\n 'explicitly defining credentials and region in techdocs.publisher.awsS3 in app config or ' +\n 'by using environment variables. Refer to https://backstage.io/docs/features/techdocs/using-cloud-storage',\n );\n this.logger.error(\n `from AWS client library`,\n error instanceof Error ? error : new Error(String(error)),\n );\n return {\n isAvailable: false,\n };\n }\n }\n /**\n * Upload all the files from the generated `directory` to the S3 bucket.\n * Directory structure used in the bucket is - entityNamespace/entityKind/entityName/index.html\n */\n async publish({\n entity,\n directory,\n }: PublishRequest): Promise<PublishResponse> {\n const objects: string[] = [];\n const useLegacyPathCasing = this.legacyPathCasing;\n const bucketRootPath = this.bucketRootPath;\n const sse = this.sse;\n\n // Track timing for performance monitoring\n const publishStartTime = Date.now();\n\n // First, try to retrieve a list of all individual files currently existing\n let existingFiles: string[] = [];\n try {\n const remoteFolder = getCloudPathForLocalPath(\n entity,\n undefined,\n useLegacyPathCasing,\n bucketRootPath,\n );\n const response = await this.retryOperation(\n async () => {\n const listCommand = new ListObjectsV2Command({\n Bucket: this.bucketName,\n Prefix: remoteFolder,\n });\n return this.storageClient.send(listCommand);\n },\n 'ListObjects',\n this.maxAttempts,\n );\n existingFiles = (response.Contents || [])\n .map(f => f.Key || '')\n .filter(f => !!f);\n } catch (e) {\n assertError(e);\n this.logger.error(\n `Unable to list files for Entity ${entity.metadata.name}: ${e.message}`,\n );\n }\n\n // Then, merge new files into the same folder\n let absoluteFilesToUpload;\n try {\n // Remove the absolute path prefix of the source directory\n // Path of all files to upload, relative to the root of the source directory\n // e.g. ['index.html', 'sub-page/index.html', 'assets/images/favicon.png']\n absoluteFilesToUpload = await getFileTreeRecursively(directory);\n\n await bulkStorageOperation(\n async absoluteFilePath => {\n const relativeFilePath = path.relative(directory, absoluteFilePath);\n const s3Key = getCloudPathForLocalPath(\n entity,\n relativeFilePath,\n useLegacyPathCasing,\n bucketRootPath,\n );\n // Create params without the Body because the body must be the\n // actual file contents (Buffer or Readable), not the path string.\n // For multipart uploads we attach a Readable stream to avoid\n // buffering large files in memory. For simple uploads we attach\n // a Buffer read from disk.\n const params: PutObjectCommandInput = {\n Bucket: this.bucketName,\n Key: s3Key,\n ...(sse && { ServerSideEncryption: sse }),\n };\n\n objects.push(params.Key!);\n // Get file stats before upload\n const stats = await fs.stat(absoluteFilePath);\n const fileSizeInBytes = stats.size;\n\n // Check if this is a large file that requires multipart upload\n if (fileSizeInBytes >= MAX_SINGLE_UPLOAD_BYTES) {\n // Try multipart upload for large files\n try {\n // Create stream and Upload inside retry closure so stream is\n // recreated on each retry attempt (streams are consumable once).\n await this.retryOperation(\n () => {\n // Create a fresh stream on each attempt\n const fileStream = fs.createReadStream(absoluteFilePath);\n const uploadParams = { ...params, Body: fileStream };\n\n const upload = new Upload({\n client: this.storageClient,\n params: uploadParams,\n partSize: MAX_SINGLE_UPLOAD_BYTES,\n queueSize: 3,\n leavePartsOnError: false,\n });\n return upload.done();\n },\n `Upload-${params.Key}`,\n this.maxAttempts,\n );\n return;\n } catch (multipartError) {\n const s3Error = multipartError as any;\n const errorName = s3Error?.name || 'Unknown';\n\n // For specific multipart errors, attempt simple upload fallback\n if (errorName === 'InvalidPart' || errorName === 'NoSuchUpload') {\n this.logger.warn(\n `Multipart upload failed for ${params.Key}, attempting simple upload fallback.`,\n );\n } else {\n // Non-recoverable multipart error, throw it\n this.logger.error(\n `Multipart upload failed for ${params.Key}: ${\n multipartError instanceof Error\n ? multipartError.message\n : String(multipartError)\n }`,\n );\n throw multipartError;\n }\n }\n }\n\n // Use simple upload for small files or as fallback from multipart\n try {\n const fileContent = await fs.readFile(absoluteFilePath);\n const putParams = { ...params, Body: fileContent };\n await this.retryOperation(\n () => this.storageClient.send(new PutObjectCommand(putParams)),\n `Upload-${params.Key}`,\n this.maxAttempts,\n );\n\n if (fileSizeInBytes >= MAX_SINGLE_UPLOAD_BYTES) {\n this.logger.info(\n `Simple upload fallback succeeded for ${params.Key}`,\n );\n }\n } catch (error) {\n this.logger.error(\n `Upload failed for ${params.Key}: ${\n error instanceof Error ? error.message : String(error)\n }`,\n );\n throw error;\n }\n },\n absoluteFilesToUpload,\n { concurrencyLimit: 10 },\n );\n\n this.logger.info(\n `Successfully uploaded all the generated files for Entity ${entity.metadata.name}. Total number of files: ${absoluteFilesToUpload.length}`,\n );\n } catch (e) {\n const errorMessage = `Unable to upload file(s) to AWS S3. ${e}`;\n this.logger.error(errorMessage);\n throw new Error(errorMessage);\n }\n\n // Last, try to remove the files that were *only* present previously\n try {\n const relativeFilesToUpload = absoluteFilesToUpload.map(\n absoluteFilePath =>\n getCloudPathForLocalPath(\n entity,\n path.relative(directory, absoluteFilePath),\n useLegacyPathCasing,\n bucketRootPath,\n ),\n );\n const staleFiles = getStaleFiles(relativeFilesToUpload, existingFiles);\n\n await bulkStorageOperation(\n async relativeFilePath => {\n return this.retryOperation(\n async () => {\n const deleteCommand = new DeleteObjectCommand({\n Bucket: this.bucketName,\n Key: relativeFilePath,\n });\n return this.storageClient.send(deleteCommand);\n },\n 'DeleteObject',\n this.maxAttempts,\n );\n },\n staleFiles,\n { concurrencyLimit: 10 },\n );\n this.logger.info(\n `Successfully deleted stale files for Entity ${entity.metadata.name}. Total number of files: ${staleFiles.length}`,\n );\n } catch (error) {\n const errorMessage = `Unable to delete file(s) from AWS S3. ${error}`;\n this.logger.error(errorMessage);\n }\n const publishEndTime = Date.now();\n const publishDurationMs = publishEndTime - publishStartTime;\n this.logger.info(\n `Successfully published ${objects.length} files for ${\n entity.metadata.name\n } in ${Math.round(publishDurationMs / 1000)}s`,\n );\n return { objects };\n }\n\n async fetchTechDocsMetadata(\n entityName: CompoundEntityRef,\n ): Promise<TechDocsMetadata> {\n try {\n return await new Promise<TechDocsMetadata>(async (resolve, reject) => {\n const entityTriplet = `${entityName.namespace}/${entityName.kind}/${entityName.name}`;\n const entityDir = this.legacyPathCasing\n ? entityTriplet\n : lowerCaseEntityTriplet(entityTriplet);\n\n const entityRootDir = path.posix.join(this.bucketRootPath, entityDir);\n if (!isValidContentPath(this.bucketRootPath, entityRootDir)) {\n this.logger.error(\n `Invalid content path found while fetching TechDocs metadata: ${entityRootDir}`,\n );\n throw new Error(`Metadata Not Found`);\n }\n\n try {\n const resp = await this.retryOperation(\n async () => {\n const getCommand = new GetObjectCommand({\n Bucket: this.bucketName,\n Key: `${entityRootDir}/techdocs_metadata.json`,\n });\n return this.storageClient.send(getCommand);\n },\n 'GetTechDocsMetadata',\n this.maxAttempts,\n );\n\n const techdocsMetadataJson = await streamToBuffer(\n resp.Body as Readable,\n );\n if (!techdocsMetadataJson) {\n throw new Error(\n `Unable to parse the techdocs metadata file ${entityRootDir}/techdocs_metadata.json.`,\n );\n }\n\n const techdocsMetadata = JSON5.parse(\n techdocsMetadataJson.toString('utf-8'),\n );\n\n resolve(techdocsMetadata);\n } catch (err) {\n assertError(err);\n this.logger.error(err.message);\n reject(new Error(err.message));\n }\n });\n } catch (e) {\n throw new ForwardedError('TechDocs metadata fetch failed', e);\n }\n }\n\n /**\n * Express route middleware to serve static files on a route in techdocs-backend.\n */\n docsRouter(): express.Handler {\n return async (req, res) => {\n const decodedUri = decodeURI(req.path.replace(/^\\//, ''));\n\n // filePath example - /default/component/documented-component/index.html\n const filePathNoRoot = this.legacyPathCasing\n ? decodedUri\n : lowerCaseEntityTripletInStoragePath(decodedUri);\n\n // Prepend the root path to the relative file path\n const filePath = path.posix.join(this.bucketRootPath, filePathNoRoot);\n if (!isValidContentPath(this.bucketRootPath, filePath)) {\n this.logger.error(\n `Attempted to fetch TechDocs content for a file outside of the bucket root: ${filePathNoRoot}`,\n );\n res.status(404).send('File Not Found');\n return;\n }\n\n // Files with different extensions (CSS, HTML) need to be served with different headers\n const fileExtension = path.extname(filePath);\n const responseHeaders = getHeadersForFileExtension(fileExtension);\n\n try {\n const resp = await this.storageClient.send(\n new GetObjectCommand({ Bucket: this.bucketName, Key: filePath }),\n );\n\n // Inject response headers\n for (const [headerKey, headerValue] of Object.entries(\n responseHeaders,\n )) {\n res.setHeader(headerKey, headerValue);\n }\n\n (resp.Body as Readable)\n .on('error', err => {\n this.logger.warn(\n `TechDocs S3 router failed to serve static files from bucket ${this.bucketName} at key ${filePath}: ${err.message}`,\n );\n if (!res.headersSent) {\n res.status(404).send('File Not Found');\n } else {\n res.destroy();\n }\n })\n .pipe(res);\n } catch (err) {\n assertError(err);\n this.logger.warn(\n `TechDocs S3 router failed to serve static files from bucket ${this.bucketName} at key ${filePath}: ${err.message}`,\n );\n res.status(404).send('File Not Found');\n }\n };\n }\n\n /**\n * A helper function which checks if index.html of an Entity's docs site is available. This\n * can be used to verify if there are any pre-generated docs available to serve.\n */\n async hasDocsBeenGenerated(entity: Entity): Promise<boolean> {\n try {\n const entityTriplet = `${entity.metadata.namespace}/${entity.kind}/${entity.metadata.name}`;\n const entityDir = this.legacyPathCasing\n ? entityTriplet\n : lowerCaseEntityTriplet(entityTriplet);\n\n const entityRootDir = path.posix.join(this.bucketRootPath, entityDir);\n if (!isValidContentPath(this.bucketRootPath, entityRootDir)) {\n this.logger.error(\n `Invalid content path found while checking if docs have been generated: ${entityRootDir}`,\n );\n return Promise.resolve(false);\n }\n\n await this.storageClient.send(\n new HeadObjectCommand({\n Bucket: this.bucketName,\n Key: `${entityRootDir}/index.html`,\n }),\n );\n return Promise.resolve(true);\n } catch (e) {\n return Promise.resolve(false);\n }\n }\n\n async migrateDocsCase({\n removeOriginal = false,\n concurrency = 25,\n }): Promise<void> {\n // Iterate through every file in the root of the publisher.\n const allObjects = await this.getAllObjectsFromBucket();\n const limiter = createLimiter(concurrency);\n await Promise.all(\n allObjects.map(f =>\n limiter(async file => {\n let newPath;\n try {\n newPath = lowerCaseEntityTripletInStoragePath(file);\n } catch (e) {\n assertError(e);\n this.logger.warn(e.message);\n return;\n }\n\n // If all parts are already lowercase, ignore.\n if (file === newPath) {\n return;\n }\n\n try {\n this.logger.debug(`Migrating ${file}`);\n await this.storageClient.send(\n new CopyObjectCommand({\n Bucket: this.bucketName,\n CopySource: [this.bucketName, file].join('/'),\n Key: newPath,\n }),\n );\n\n if (removeOriginal) {\n await this.storageClient.send(\n new DeleteObjectCommand({\n Bucket: this.bucketName,\n Key: file,\n }),\n );\n }\n } catch (e) {\n assertError(e);\n this.logger.warn(`Unable to migrate ${file}: ${e.message}`);\n }\n }, f),\n ),\n );\n }\n\n /**\n * Returns a list of all object keys from the configured bucket.\n */\n protected async getAllObjectsFromBucket(\n { prefix } = { prefix: '' },\n ): Promise<string[]> {\n const objects: string[] = [];\n let nextContinuation: string | undefined;\n let allObjects: ListObjectsV2CommandOutput;\n // Iterate through every file in the root of the publisher.\n do {\n const currentToken = nextContinuation;\n allObjects = await this.retryOperation(\n async () => {\n const listCommand = new ListObjectsV2Command({\n Bucket: this.bucketName,\n ContinuationToken: currentToken,\n ...(prefix ? { Prefix: prefix } : {}),\n });\n return this.storageClient.send(listCommand);\n },\n 'GetAllObjects',\n this.maxAttempts,\n );\n objects.push(\n ...(allObjects.Contents || []).map(f => f.Key || '').filter(f => !!f),\n );\n nextContinuation = allObjects.NextContinuationToken;\n } while (nextContinuation);\n\n return objects;\n }\n}\n"],"names":["ForwardedError","normalizeExternalStorageRootPath","DefaultAwsCredentialsManager","ScmIntegrations","S3Client","NodeHttpHandler","HttpsProxyAgent","fromTemporaryCredentials","HeadBucketCommand","getCloudPathForLocalPath","ListObjectsV2Command","assertError","getFileTreeRecursively","bulkStorageOperation","path","fs","Upload","PutObjectCommand","getStaleFiles","DeleteObjectCommand","lowerCaseEntityTriplet","isValidContentPath","GetObjectCommand","JSON5","lowerCaseEntityTripletInStoragePath","getHeadersForFileExtension","HeadObjectCommand","createLimiter","CopyObjectCommand"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,uBAAA,GAA0B,IAAI,IAAA,GAAO,IAAA;AAmD3C,MAAM,cAAA,GAAiB,CAAC,MAAA,KAAsC;AAC5D,EAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,OAAA,EAAS,MAAA,KAAW;AACtC,IAAA,IAAI;AACF,MAAA,MAAM,SAAgB,EAAC;AACvB,MAAA,MAAA,CAAO,GAAG,MAAA,EA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,QACN,GAAA,CAAI,UAAA,CAAW,QAAA,IAAY,IAAI,GAAA,CAAI,CAAA,CAAA,KAAK,CAAA,CAAE,GAAA,IAAO,EAAE,CAAA,CAAE,MAAA,CAAO,CAAA,CAAA,KAAK,CAAC,CAAC,CAAC;AAAA,OACtE;AACA,MAAA,gBAAA,GAAmB,UAAA,CAAW,qBAAA;AAAA,IAChC,CAAA,QAAS,gBAAA;AAET,IAAA,OAAO,OAAA;AAAA,EACT;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-techdocs-node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"description": "Common node.js functionalities for TechDocs, to be shared between techdocs-backend plugin and techdocs-cli",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "node-library",
|
|
@@ -53,14 +53,14 @@
|
|
|
53
53
|
"@aws-sdk/types": "^3.347.0",
|
|
54
54
|
"@azure/identity": "^4.0.0",
|
|
55
55
|
"@azure/storage-blob": "^12.5.0",
|
|
56
|
-
"@backstage/backend-plugin-api": "1.6.
|
|
57
|
-
"@backstage/catalog-model": "1.7.6",
|
|
58
|
-
"@backstage/config": "1.3.6",
|
|
59
|
-
"@backstage/errors": "1.2.7",
|
|
60
|
-
"@backstage/integration": "1.19.2
|
|
61
|
-
"@backstage/integration-aws-node": "0.1.19",
|
|
62
|
-
"@backstage/plugin-search-common": "1.2.21",
|
|
63
|
-
"@backstage/plugin-techdocs-common": "0.1.1",
|
|
56
|
+
"@backstage/backend-plugin-api": "^1.6.1",
|
|
57
|
+
"@backstage/catalog-model": "^1.7.6",
|
|
58
|
+
"@backstage/config": "^1.3.6",
|
|
59
|
+
"@backstage/errors": "^1.2.7",
|
|
60
|
+
"@backstage/integration": "^1.19.2",
|
|
61
|
+
"@backstage/integration-aws-node": "^0.1.19",
|
|
62
|
+
"@backstage/plugin-search-common": "^1.2.21",
|
|
63
|
+
"@backstage/plugin-techdocs-common": "^0.1.1",
|
|
64
64
|
"@google-cloud/storage": "^7.0.0",
|
|
65
65
|
"@smithy/node-http-handler": "^3.0.0",
|
|
66
66
|
"@trendyol-js/openstack-swift-sdk": "^0.0.7",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"winston": "^3.2.1"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@backstage/backend-test-utils": "1.10.3
|
|
82
|
-
"@backstage/cli": "0.35.2
|
|
81
|
+
"@backstage/backend-test-utils": "^1.10.3",
|
|
82
|
+
"@backstage/cli": "^0.35.2",
|
|
83
83
|
"@types/fs-extra": "^11.0.0",
|
|
84
84
|
"@types/js-yaml": "^4.0.0",
|
|
85
85
|
"@types/mime-types": "^2.1.0",
|