Skip to content

Commit

Permalink
fix: missing backend:get-environment scaffolder action
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneswuerbach committed May 10, 2024
1 parent 407c72e commit ea24287
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
2 changes: 2 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,7 @@
"@backstage/plugin-permission-node": "^0.7.28",
"@backstage/plugin-proxy-backend": "^0.4.15",
"@backstage/plugin-scaffolder-backend": "^1.22.4",
"@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'),
}),
);
},
});
},
});
3 changes: 3 additions & 0 deletions packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ backend.add(import('@backstage/plugin-search-backend-module-techdocs/alpha'));
backend.add(import('@humanitec/backstage-plugin-backend'));
backend.add(import('@humanitec/backstage-plugin-scaffolder-backend-module'));

// backend:get-environment used in humanitec templates
backend.add(import('./actions/get-environment'));

backend.start();

0 comments on commit ea24287

Please sign in to comment.