-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(slack): Support new backend system (#56)
- Loading branch information
Showing
6 changed files
with
470 additions
and
8 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
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright SeatGeek | ||
* Licensed under the terms of the Apache-2.0 license. See LICENSE file in project root for terms. | ||
*/ | ||
import { loggerToWinstonLogger } from '@backstage/backend-common'; | ||
import { | ||
coreServices, | ||
createBackendModule, | ||
} from '@backstage/backend-plugin-api'; | ||
import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; | ||
import { WebClient } from '@slack/web-api'; | ||
|
||
import { SlackUserProcessor } from './SlackUserProcessor'; | ||
|
||
export const catalogModuleSlackUserProcessor = createBackendModule({ | ||
pluginId: 'catalog', // name of the plugin that the module is targeting | ||
moduleId: 'slack-catalog-backend', | ||
register(env) { | ||
env.registerInit({ | ||
deps: { | ||
catalog: catalogProcessingExtensionPoint, | ||
logger: coreServices.logger, | ||
config: coreServices.rootConfig, | ||
}, | ||
async init({ catalog, logger, config }) { | ||
// Log warning if no token is set | ||
const slackToken = config.getOptionalString('slackCatalog.token'); | ||
if (!slackToken) { | ||
logger.warn( | ||
'No token provided for SlackUserProcessor, skipping Slack user lookup', | ||
); | ||
return; | ||
} | ||
catalog.addProcessor( | ||
new SlackUserProcessor( | ||
new WebClient(slackToken), | ||
loggerToWinstonLogger(logger), | ||
), | ||
); | ||
}, | ||
}); | ||
}, | ||
}); |
Oops, something went wrong.