Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new backend for scaffolder-backend-argocd #1625

Merged
merged 15 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/healthy-rivers-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@roadiehq/scaffolder-backend-argocd': minor
---

Update to new backend system
24 changes: 24 additions & 0 deletions plugins/scaffolder-actions/scaffolder-backend-argocd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,33 @@ return await createRouter({
});
```

### New backend system

## From your Backstage root directory

```
cd packages/backend
yarn add @roadiehq/scaffolder-backend-argocd
```

```typescript
// packages/backend/src/index.ts
import { createBackend } from '@backstage/backend-defaults';
import { createBackendModule } from '@backstage/backend-plugin-api';

const backend = createBackend();
backend.add(import('@backstage/plugin-scaffolder-backend/alpha'));
backend.add(
import('@roadiehq/scaffolder-backend-argocd/new-backend'),
);
backend.start();

### From your software template yaml file

Under `spec.steps[]` insert the below. In the below we reference items in the `spec.paramters[]` section.

```

- id: create-argocd-resources
name: Create ArgoCD Resources
action: argocd:create-resources
Expand All @@ -67,6 +89,7 @@ Under `spec.steps[]` insert the below. In the below we reference items in the `s
repoUrl: ${{ steps.publish.output.remoteUrl }}
labelValue: ${{ parameters.name }}
path: "kubernetes/nonprod"

```

> If needed there is an optional parameter of `projectName` as well.
Expand All @@ -76,3 +99,4 @@ Under `spec.steps[]` insert the below. In the below we reference items in the `s
---

Roadie gives you a hassle-free, fully customisable SaaS Backstage. Find out more here: [https://roadie.io](https://roadie.io).
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@
"pluginId": "scaffolder-backend-argocd",
"pluginPackage": "@backstage/plugin-scaffolder-backend"
},
"exports": {
".": "./src/index.ts",
"./package.json": "./package.json",
"./new-backend": "./src/new-backend.ts"
htplbc marked this conversation as resolved.
Show resolved Hide resolved
},
"typesVersions": {
"*": {
"package.json": [
"package.json"
],
"new-backend": [
"src/new-backend.ts"
]
htplbc marked this conversation as resolved.
Show resolved Hide resolved
}
},
"repository": {
"type": "git",
"url": "github:RoadieHQ/roadie-backstage-plugins",
Expand All @@ -34,8 +49,10 @@
},
"dependencies": {
"@backstage/backend-common": "^0.24.0",
"@backstage/backend-plugin-api": "^0.8.0",
"@backstage/config": "^1.2.0",
"@backstage/plugin-scaffolder-backend": "^1.24.0",
"@backstage/plugin-scaffolder-node": "^0.4.9",
"@roadiehq/backstage-plugin-argo-cd-backend": "^3.2.2",
"@backstage/backend-test-utils": "^0.5.0",
"winston": "^3.2.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
* limitations under the License.
*/
export * from './actions';
export * from './new-backend';
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2024 Larder Software Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
createBackendModule,
coreServices,
} from '@backstage/backend-plugin-api';
import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha';
import { loggerToWinstonLogger } from '@backstage/backend-common';
import * as backendModuleUtils from './actions';

/**
* @public
* The Roadie Module for the Scaffolder Backend ArgoCD Actions
*/
export const scaffolderBackendArgoCD = createBackendModule({
pluginId: 'scaffolder',
moduleId: 'scaffolder-backend-argocd',
register({ registerInit }) {
registerInit({
deps: {
scaffolder: scaffolderActionsExtensionPoint,
config: coreServices.rootConfig,
logger: coreServices.logger,
},
async init({ scaffolder, config, logger }) {
scaffolder.addActions(
backendModuleUtils.createArgoCdResources(
config,
loggerToWinstonLogger(logger),
),
);
},
});
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright 2024 Larder Software Limited
karlhaworth marked this conversation as resolved.
Show resolved Hide resolved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
htplbc marked this conversation as resolved.
Show resolved Hide resolved
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { scaffolderBackendArgoCD as default } from './module';
Loading