Skip to content

Commit

Permalink
Merge pull request #29 from johanneswuerbach/main
Browse files Browse the repository at this point in the history
fix: missing backend:get-environment & github scaffolder actions
  • Loading branch information
johanneswuerbach authored May 10, 2024
2 parents 407c72e + b3fa668 commit e65b325
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
3 changes: 3 additions & 0 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"dependencies": {
"@backstage/backend-common": "^0.21.7",
"@backstage/backend-defaults": "^0.2.17",
"@backstage/backend-plugin-api": "^0.6.17",
"@backstage/backend-tasks": "^0.5.22",
"@backstage/config": "^1.2.0",
"@backstage/plugin-app-backend": "^0.3.65",
Expand All @@ -33,6 +34,8 @@
"@backstage/plugin-permission-node": "^0.7.28",
"@backstage/plugin-proxy-backend": "^0.4.15",
"@backstage/plugin-scaffolder-backend": "^1.22.4",
"@backstage/plugin-scaffolder-backend-module-github": "^0.2.7",
"@backstage/plugin-scaffolder-node": "^0.4.3",
"@backstage/plugin-search-backend": "^1.5.7",
"@backstage/plugin-search-backend-module-catalog": "^0.1.22",
"@backstage/plugin-search-backend-module-techdocs": "^0.1.22",
Expand Down
36 changes: 29 additions & 7 deletions packages/backend/src/actions/get-environment.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { createTemplateAction } from '@backstage/plugin-scaffolder-backend';
import {
createBackendModule,
coreServices,
} from '@backstage/backend-plugin-api';
import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';
import { createTemplateAction } from '@backstage/plugin-scaffolder-node';

interface EnvironmentAction {
orgId: string
awsRegion: string
cloudProvider: string
}

export function createGetEnvironmentAction({ orgId, awsRegion, cloudProvider }: EnvironmentAction) {
export function createGetEnvironmentAction({ orgId, cloudProvider }: EnvironmentAction) {
return createTemplateAction({
id: 'backend:get-environment',
schema: {
Expand All @@ -16,9 +20,6 @@ export function createGetEnvironmentAction({ orgId, awsRegion, cloudProvider }:
orgId: {
type: 'string'
},
awsRegion: {
type: 'string'
},
cloudProvider: {
type: 'string'
},
Expand All @@ -30,7 +31,6 @@ export function createGetEnvironmentAction({ orgId, awsRegion, cloudProvider }:
},
handler: async (ctx) => {
ctx.output('orgId', orgId);
ctx.output('awsRegion', awsRegion);
ctx.output('cloudProvider', cloudProvider);

let githubOIDCCustomization
Expand All @@ -44,3 +44,25 @@ export function createGetEnvironmentAction({ orgId, awsRegion, cloudProvider }:
},
});
}


export default createBackendModule({
moduleId: 'get-environment-scaffolder-module',
pluginId: 'scaffolder',
register({ registerInit }) {
registerInit({
deps: {
scaffolderActions: scaffolderActionsExtensionPoint,
config: coreServices.rootConfig,
},
async init({ scaffolderActions, config }) {
scaffolderActions.addActions(
createGetEnvironmentAction({
orgId: config.getString('humanitec.orgId'),
cloudProvider: config.getString('cloudProvider'),
}),
);
},
});
},
});
8 changes: 7 additions & 1 deletion packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const backend = createBackend();

backend.add(import('@backstage/plugin-app-backend/alpha'));
backend.add(import('@backstage/plugin-proxy-backend/alpha'));
backend.add(import('@backstage/plugin-scaffolder-backend/alpha'));
backend.add(import('@backstage/plugin-techdocs-backend/alpha'));

// auth plugin
Expand All @@ -38,8 +37,15 @@ backend.add(import('@backstage/plugin-search-backend/alpha'));
backend.add(import('@backstage/plugin-search-backend-module-catalog/alpha'));
backend.add(import('@backstage/plugin-search-backend-module-techdocs/alpha'));

// scaffolder plugin
backend.add(import('@backstage/plugin-scaffolder-backend/alpha'));
backend.add(import('@backstage/plugin-scaffolder-backend-module-github'));
// backend:get-environment used in humanitec templates
backend.add(import('./actions/get-environment'));

// humanitec
backend.add(import('@humanitec/backstage-plugin-backend'));
backend.add(import('@humanitec/backstage-plugin-scaffolder-backend-module'));


backend.start();

0 comments on commit e65b325

Please sign in to comment.