Skip to content

Commit

Permalink
feat: add backend module (#44)
Browse files Browse the repository at this point in the history
* feat: add backend module

* docs: update readme

* Bump version
  • Loading branch information
tim-stasse authored Oct 17, 2024
1 parent 5bdf2a4 commit 4bb71eb
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 32 deletions.
38 changes: 7 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,40 +35,16 @@ yarn add --cwd packages/backend @parfuemerie-douglas/scaffolder-backend-module-a
```

Configure the actions (you can check the
[docs](https://backstage.io/docs/features/software-templates/writing-custom-actions#registering-custom-actions)
[docs](https://backstage.io/docs/features/software-templates/writing-custom-actions#register-action-with-new-backend-system)
to see all options):

```typescript
// packages/backend/src/plugins/scaffolder.ts

import {
createAzurePipelineAction,
permitAzurePipelineAction,
runAzurePipelineAction,
} from "@parfuemerie-douglas/scaffolder-backend-module-azure-pipelines";

const actions = [
createAzurePipelineAction({ integrations }),
permitAzurePipelineAction({ integrations }),
runAzurePipelineAction({ integrations }),
...createBuiltInActions({
containerRunner,
catalogClient,
integrations,
config: env.config,
reader: env.reader,
}),
];

return await createRouter({
containerRunner,
catalogClient,
actions,
logger: env.logger,
config: env.config,
database: env.database,
reader: env.reader,
});
// packages/backend/src/index.ts
const backend = createBackend();

// ...

backend.add(import('@parfuemerie-douglas/scaffolder-backend-module-azure-pipelines'))
```

The Azure pipeline actions use an [Azure PAT (personal access
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@parfuemerie-douglas/scaffolder-backend-module-azure-pipelines",
"version": "1.2.0",
"version": "1.3.0",
"description": "A collection of Backstage scaffolder backend modules for Azure pipelines.",
"main": "dist/index.cjs.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -42,6 +42,7 @@
"homepage": "https://github.com/Parfuemerie-Douglas/scaffolder-backend-module-azure-pipelines#readme",
"dependencies": {
"@backstage/backend-common": "^0.23.3",
"@backstage/backend-plugin-api": "^0.7.0",
"@backstage/errors": "^1.2.4",
"@backstage/integration": "^1.13.0",
"@backstage/plugin-scaffolder-backend": "^1.23.0",
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
* limitations under the License.
*/

export { scaffolderModuleAzurePipelines as default } from './module';
export * from "./actions";
44 changes: 44 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';
import {
createBackendModule,
coreServices
} from '@backstage/backend-plugin-api';
import { ScmIntegrations } from '@backstage/integration';

import {
createAzurePipelineAction,
permitAzurePipelineAction,
runAzurePipelineAction
} from './actions';

export const scaffolderModuleAzurePipelines = createBackendModule({
pluginId: 'scaffolder',
moduleId: 'azure-pipelines',
register(env) {
env.registerInit({
deps: {
scaffolder: scaffolderActionsExtensionPoint,
logger: coreServices.logger,
config: coreServices.rootConfig,
discovery: coreServices.discovery,
reader: coreServices.urlReader,
},
async init({ scaffolder, config}) {

const integrations = ScmIntegrations.fromConfig(config);

scaffolder.addActions(
createAzurePipelineAction({
integrations,
}),
permitAzurePipelineAction({
integrations,
}),
runAzurePipelineAction({
integrations,
})
);
},
});
},
});

0 comments on commit 4bb71eb

Please sign in to comment.