Skip to content

Commit daaea27

Browse files
authored
feat(x2a): change the project to be source-technology agnostic (#2953)
* feat(x2a): change the project to be source-technology agnostic Rephrasing all texts from being Chef-oriented to more generic variants. There is explicit mapping from free-form agentic findings to a new SourceTechnology enum (normalizeSourceTechnology.ts). Signed-off-by: Marek Libra <marek.libra@gmail.com> * Stick to 'existing automation' and prune source technologies * forgotten renames --------- Signed-off-by: Marek Libra <marek.libra@gmail.com>
1 parent 4418084 commit daaea27

36 files changed

Lines changed: 272 additions & 38 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-scaffolder-backend-module-x2a': patch
3+
'@red-hat-developer-hub/backstage-plugin-x2a-backend': patch
4+
'@red-hat-developer-hub/backstage-plugin-x2a-common': patch
5+
'@red-hat-developer-hub/backstage-plugin-x2a-node': patch
6+
'@red-hat-developer-hub/backstage-plugin-x2a': patch
7+
---
8+
9+
Changed the project to be source-technology agnostic. Rephrasing all texts from being Chef-oriented to more generic variants. There is explicit mapping from free-form agentic findings to the new SourceTechnology enum (normalizeSourceTechnology.ts).

workspaces/x2a/docs/csv-bulk-import.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The CSV bulk import lets the user create multiple conversion projects at once by
55
## How to Access
66

77
1. Open the Backstage instance and navigate to `/create`.
8-
2. Select the **Chef-to-Ansible Conversion Project** template (`chef-conversion-project-template`).
8+
2. Select the **Infrastructure Conversion Project** template (`x2a-conversion-project-template`).
99
3. On the first page, choose **CSV upload** as the input method.
1010
4. Upload the CSV file and proceed through the wizard.
1111

@@ -21,7 +21,7 @@ The file must be UTF-8 encoded with a header row. Column order does not matter,
2121
| ------------------ | --------------------------------------------------------------------------------------------------------- |
2222
| `name` | Unique project name |
2323
| `abbreviation` | Short project identifier, 1-5 alphanumeric characters matching `^([a-zA-Z][a-zA-Z0-9]*)(-[a-zA-Z0-9]+)*$` |
24-
| `sourceRepoUrl` | URL of the repository containing the Chef cookbook to convert |
24+
| `sourceRepoUrl` | URL of the source repository to convert |
2525
| `sourceRepoBranch` | Branch to read from in the source repository |
2626
| `targetRepoBranch` | Branch to write converted Ansible output to |
2727

workspaces/x2a/plugins/scaffolder-backend-module-x2a/templates/conversion-project-template.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
apiVersion: scaffolder.backstage.io/v1beta3
22
kind: Template
33
metadata:
4-
name: chef-conversion-project-template
5-
title: Chef-to-Ansible Conversion Project
6-
description: Initiate a conversion of a Chef cookbook or directory into a new Ansible Playbook repository.
4+
name: x2a-conversion-project-template
5+
title: Infrastructure Conversion Project
6+
description: Initiate a conversion of existing automation (e.g. Chef, Puppet, Salt, Powershell) into a new Ansible Playbook repository.
77
spec:
88
type: service
99

@@ -121,7 +121,7 @@ spec:
121121
sourceRepoUrl:
122122
title: Conversion source repository
123123
description: |
124-
The Owner should be your SCM (Source Code Management) username. The repository name should be a name that already exists in your SCM account and contains a Chef cookbook or directory to convert.
124+
The Owner should be your SCM (Source Code Management) username. The repository name should be a name that already exists in your SCM account and contains the existing automation (like Chef cookbook, Puppet module, Salt, Powershell DSC, etc.) to convert.
125125
type: string
126126
ui:field: RepoUrlPicker
127127
ui:options:

workspaces/x2a/plugins/x2a-backend/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ curl -X POST http://localhost:7007/api/x2a/projects \
209209
-H "Content-Type: application/json" \
210210
-H "Authorization: Bearer ${TOKEN}" \
211211
-d '{
212-
"name": "My Chef Migration",
212+
"name": "My source automation project migration",
213213
"description": "Test migration",
214214
"abbreviation": "TEST"
215215
}'
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import type { Knex } from 'knex';
18+
19+
/**
20+
* Adds the technology column to the modules table.
21+
*
22+
* @public
23+
*/
24+
export async function up(knex: Knex): Promise<void> {
25+
await knex.schema.alterTable('modules', table => {
26+
table.string('technology').nullable();
27+
});
28+
}
29+
30+
/**
31+
* Removes the technology column from the modules table.
32+
*
33+
* @public
34+
*/
35+
export async function down(knex: Knex): Promise<void> {
36+
await knex.schema.alterTable('modules', table => {
37+
table.dropColumn('technology');
38+
});
39+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
name,description,abbreviation,ownedByGroup,sourceRepoUrl,sourceRepoBranch,targetRepoUrl,targetRepoBranch
2-
my-examples,Convert chef-examples to Ansible,mex,,https://github.com/x2ansible/chef-examples,main,https://github.com/my-converted-projects/my-examples,target
2+
my-examples,Convert existing automation to Ansible,mex,,https://github.com/x2ansible/config-examples,main,https://github.com/my-converted-projects/my-examples,target

workspaces/x2a/plugins/x2a-backend/src/router/collectArtifactsActions.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ describe('collectArtifacts routes (actions & signatures)', () => {
9696
name: 'module-a',
9797
sourcePath: '/cookbooks/a',
9898
projectId,
99+
technology: 'chef',
99100
});
100101
expect(mockDeps.x2aDatabase.createModule).toHaveBeenCalledWith({
101102
name: 'module-b',
102103
sourcePath: '/cookbooks/b',
103104
projectId,
105+
technology: 'chef',
104106
});
105107
});
106108

@@ -164,6 +166,7 @@ describe('collectArtifacts routes (actions & signatures)', () => {
164166
name: 'new-module',
165167
sourcePath: '/cookbooks/new',
166168
projectId,
169+
technology: undefined,
167170
});
168171
expect(mockDeps.x2aDatabase.deleteModule).toHaveBeenCalledTimes(1);
169172
expect(mockDeps.x2aDatabase.deleteModule).toHaveBeenCalledWith({

workspaces/x2a/plugins/x2a-backend/src/router/modules.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ export function registerModuleRoutes(
305305
callbackUrl,
306306
moduleId,
307307
moduleName: module.name,
308+
sourceTechnology: module.technology,
308309
sourceRepo: {
309310
url: project.sourceRepoUrl,
310311
branch: project.sourceRepoBranch,

workspaces/x2a/plugins/x2a-backend/src/router/phaseActions.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,13 @@ describe('phaseActions', () => {
7474
name: 'cookbook-a',
7575
sourcePath: '/cookbooks/a',
7676
projectId,
77+
technology: 'chef',
7778
});
7879
expect(context.x2aDatabase.createModule).toHaveBeenCalledWith({
7980
name: 'cookbook-b',
8081
sourcePath: '/cookbooks/b',
8182
projectId,
83+
technology: 'chef',
8284
});
8385
});
8486

@@ -116,6 +118,7 @@ describe('phaseActions', () => {
116118
name: 'added',
117119
sourcePath: '/cookbooks/added',
118120
projectId,
121+
technology: undefined,
119122
});
120123
});
121124

workspaces/x2a/plugins/x2a-backend/src/router/phaseActions.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type {
1919
Artifact,
2020
MigrationPhase,
2121
} from '@red-hat-developer-hub/backstage-plugin-x2a-common';
22+
import { normalizeSourceTechnology } from '@red-hat-developer-hub/backstage-plugin-x2a-common';
2223

2324
import type { RouterDeps } from './types';
2425

@@ -86,11 +87,20 @@ class InitPhaseAction implements PhaseAction {
8687

8788
await Promise.all(
8889
toAdd.map(m => {
89-
logger.info(`Creating module "${m.name}" for project ${projectId}`);
90+
const technology = normalizeSourceTechnology(m.technology);
91+
if (m.technology && !technology) {
92+
logger.warn(
93+
`Unrecognized source technology "${m.technology}" for module "${m.name}" - storing as undefined`,
94+
);
95+
}
96+
logger.info(
97+
`Creating module "${m.name}" for project ${projectId} with technology ${technology}`,
98+
);
9099
return x2aDatabase.createModule({
91100
name: m.name,
92101
sourcePath: m.path,
93102
projectId,
103+
technology,
94104
});
95105
}),
96106
);

0 commit comments

Comments
 (0)