-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ivgo
committed
Feb 28, 2024
1 parent
0940010
commit d7091b6
Showing
11 changed files
with
212 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
'@spreadshirt/backstage-plugin-s3-viewer-backend': minor | ||
--- | ||
|
||
Add support to the [new backend system](https://backstage.io/docs/backend-system/). | ||
|
||
Follow the instructions in the [README.md](https://github.com/spreadshirt/backstage-plugin-s3/blob/main/plugins/s3-viewer-backend/README.md#new-backend-system) | ||
|
||
**DEPRECATION**: The method `setRefreshInterval` has been deprecated in favor of the usage of the configuration file to schedule the refresh. | ||
From now on, the schedule should be set using the `app-config.yaml` file. This method will be kept for some time as a fallback if the schedule | ||
has not been set via the configuration file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './S3Api'; | ||
export * from './S3Builder'; | ||
export { s3ViewerPlugin } from './plugin'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { | ||
BucketStatsProvider, | ||
BucketsProvider, | ||
CredentialsProvider, | ||
S3Api, | ||
s3ViewerExtensionPoint, | ||
} from '@spreadshirt/backstage-plugin-s3-viewer-node'; | ||
import { | ||
coreServices, | ||
createBackendPlugin, | ||
} from '@backstage/backend-plugin-api'; | ||
import { S3Builder } from './S3Builder'; | ||
|
||
export const s3ViewerPlugin = createBackendPlugin({ | ||
pluginId: 's3-viewer', | ||
register(env) { | ||
let s3Client: S3Api; | ||
let s3CredentialsProvider: CredentialsProvider; | ||
let s3BucketsProvider: BucketsProvider; | ||
let s3BucketStatsProvider: BucketStatsProvider; | ||
|
||
env.registerExtensionPoint(s3ViewerExtensionPoint, { | ||
setClient(client) { | ||
if (s3Client !== undefined) { | ||
throw new Error('A S3 client has been already set'); | ||
} | ||
s3Client = client; | ||
}, | ||
setCredentialsProvider(credentialsProvider) { | ||
if (s3CredentialsProvider !== undefined) { | ||
throw new Error('A credentials provider has been already set'); | ||
} | ||
s3CredentialsProvider = credentialsProvider; | ||
}, | ||
setBucketsProvider(bucketsProvider) { | ||
if (s3BucketsProvider !== undefined) { | ||
throw new Error('A buckets provider has been already set'); | ||
} | ||
s3BucketsProvider = bucketsProvider; | ||
}, | ||
setBucketStatsProvider(bucketStatsProvider) { | ||
if (s3BucketStatsProvider !== undefined) { | ||
throw new Error('A bucket stats provider has been already set'); | ||
} | ||
s3BucketStatsProvider = bucketStatsProvider; | ||
}, | ||
}); | ||
|
||
env.registerInit({ | ||
deps: { | ||
logger: coreServices.logger, | ||
config: coreServices.rootConfig, | ||
scheduler: coreServices.scheduler, | ||
discovery: coreServices.discovery, | ||
identity: coreServices.identity, | ||
permissions: coreServices.permissions, | ||
tokenManager: coreServices.tokenManager, | ||
httpRouter: coreServices.httpRouter, | ||
}, | ||
async init(deps) { | ||
let builder = S3Builder.createBuilder(deps); | ||
|
||
if (s3Client) { | ||
builder = builder.setClient(s3Client); | ||
} | ||
if (s3CredentialsProvider) { | ||
builder = builder.setCredentialsProvider(s3CredentialsProvider); | ||
} | ||
if (s3BucketsProvider) { | ||
builder = builder.setBucketsProvider(s3BucketsProvider); | ||
} | ||
if (s3BucketStatsProvider) { | ||
builder = builder.setBucketStatsProvider(s3BucketStatsProvider); | ||
} | ||
if (deps.config.getOptionalBoolean('s3.permissionMiddleware')) { | ||
builder = await builder.useMiddleware(); | ||
} | ||
|
||
const { router } = await builder.build(); | ||
deps.httpRouter.use(router); | ||
}, | ||
}); | ||
}, | ||
}); |
Oops, something went wrong.