Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions workspaces/x2a/.changeset/large-signs-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@red-hat-developer-hub/backstage-plugin-scaffolder-backend-module-x2a': patch
'@red-hat-developer-hub/backstage-plugin-x2a-common': patch
'@red-hat-developer-hub/backstage-plugin-x2a': patch
---

Add GitLab support.
26 changes: 22 additions & 4 deletions workspaces/x2a/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ See the [backend plugin README](./plugins/x2a-backend/README.md) for detailed co

### Prerequisites

- Node.js >20
- Node.js >22
- Yarn package manager
- Kubernetes cluster access (optional, for Kubernetes features)

Expand All @@ -34,12 +34,28 @@ See the [backend plugin README](./plugins/x2a-backend/README.md) for detailed co
yarn install
```

2. Start the development environment with just the plugin loaded:
2. **Optional:** Update `app-config.yaml` based on your environment.
- **`auth:`**
- Configure authentication providers for sign-in and SCM access (GitHub, GitLab). See [Backstage auth docs](https://backstage.io/docs/auth/).
- Based on your options of auth-providers, mind updating the `conversion-project-template.yaml` for source and target repository URLs.
- **`x2a:`** - Provide LLM credentials, Ansible Automation Platform connection details, and Kubernetes resource limits. See [x2a-convertor technical details](https://github.com/x2ansible/x2a-convertor?tab=readme-ov-file#technical-details).

3. Start the development environment with just the plugin loaded:

**GitHub OAuth**: [Create a GitHub OAuth application](https://github.com/settings/developers).

**GitLab OAuth:** When [creating a GitLab OAuth application](https://gitlab.com/-/user_settings/applications), request these scopes:
- `read_api`, `read_user`, `read_repository`, `write_repository`
- `openid`, `profile`, `email`

```sh
export AUTH_GITHUB_CLIENT_ID=.... # Optional if "guest" user is not enough
export AUTH_GITHUB_CLIENT_SECRET=... # Optional if "guest" user is not enough

# For GitLab auth (create app at https://gitlab.com/-/user_settings/applications):
export AUTH_GITLAB_CLIENT_ID=...
export AUTH_GITLAB_CLIENT_SECRET=...

yarn dev
```

Expand All @@ -50,6 +66,8 @@ See the [backend plugin README](./plugins/x2a-backend/README.md) for detailed co
```sh
export AUTH_GITHUB_CLIENT_ID=.... # Optional if "guest" user is not enough
export AUTH_GITHUB_CLIENT_SECRET=... # Optional if "guest" user is not enough
export AUTH_GITLAB_CLIENT_ID=...
export AUTH_GITLAB_CLIENT_SECRET=...

yarn start
```
Expand Down Expand Up @@ -192,7 +210,7 @@ The plugin uses the Kubernetes client library to interact with Kubernetes cluste

By default, it loads configuration from your local `~/.kube/config` file.

Additional methods are planed to be implemented later.
Additional methods are planned to be implemented later.

### Local Development Setup

Expand Down Expand Up @@ -224,7 +242,7 @@ Loaded Kubernetes configuration from ~/.kube/config

- `yarn test` - Run tests
- `yarn lint` - Run linter
- `prettier:fix` - Fix by prettier
- `yarn prettier:fix` - Fix code formatting
- `yarn build:all` - Build all packages
- `yarn clean` - Clean build artifacts

Expand Down
31 changes: 20 additions & 11 deletions workspaces/x2a/app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,19 @@ backend:
# workingDirectory: /tmp # Use this to configure a working directory for the scaffolder, defaults to the OS temp-dir

integrations:
github:
- host: github.com
# This is a Personal Access Token or PAT from GitHub. You can find out how to generate this token, and more information
# about setting up the GitHub integration here: https://backstage.io/docs/integrations/github/locations#configuration
token: ${GITHUB_TOKEN}
### Example for how to add your GitHub Enterprise instance using the API:
# - host: ghe.example.net
# apiBaseUrl: https://ghe.example.net/api/v3
# token: ${GHE_TOKEN}
# So far no need for integrations
# github:
# - host: github.com
# # This is a Personal Access Token or PAT from GitHub. You can find out how to generate this token, and more information
# # about setting up the GitHub integration here: https://backstage.io/docs/integrations/github/locations#configuration
# token: ${GITHUB_TOKEN}
# gitlab:
# - host: gitlab.cee.redhat.com
# token: ${GITLAB_TOKEN}
### Example for how to add your GitHub Enterprise instance using the API:
# - host: ghe.example.net
# apiBaseUrl: https://ghe.example.net/api/v3
# token: ${GHE_TOKEN}

proxy:
### Example for how to add a proxy endpoint for the frontend.
Expand All @@ -62,6 +66,10 @@ techdocs:
publisher:
type: 'local' # Alternatives - 'googleGcs' or 'awsS3'. Read documentation for using alternatives.

# Use redirect flow instead of popup; fixes "Missing session cookie" on refresh
# when the popup and main window have different cookie contexts
#enableExperimentalRedirectFlow: true

auth:
# see https://backstage.io/docs/auth/ to learn about auth providers
environment: development
Expand All @@ -70,12 +78,13 @@ auth:
guest: {}
gitlab:
development:
# Create an OAuth app on https://gitlab.com/-/user_settings/applications
clientId: ${AUTH_GITLAB_CLIENT_ID}
clientSecret: ${AUTH_GITLAB_CLIENT_SECRET}
audience: https://gitlab.com
signIn:
resolvers:
- resolver: emailMatchingUserEntityProfileEmail
# - resolver: usernameMatchingUserEntityName
- resolver: usernameMatchingUserEntityName
github:
development:
clientId: ${AUTH_GITHUB_CLIENT_ID}
Expand Down
3 changes: 2 additions & 1 deletion workspaces/x2a/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"@backstage/backend-defaults": "0.13.1",
"@backstage/backend-plugin-api": "1.5.0",
"@backstage-community/plugin-rbac-backend": "~7.4.0",
"@backstage/plugin-permission-react": "0.4.36"
"@backstage/plugin-permission-react": "0.4.36",
"@backstage/plugin-auth-backend-module-gitlab-provider": "0.3.9"
},
"prettier": "@backstage/cli/config/prettier",
"lint-staged": {
Expand Down
8 changes: 7 additions & 1 deletion workspaces/x2a/packages/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import {
X2APage,
x2aPluginTranslations,
} from '@red-hat-developer-hub/backstage-plugin-x2a';
import { githubAuthApiRef } from '@backstage/core-plugin-api';
import { githubAuthApiRef, gitlabAuthApiRef } from '@backstage/core-plugin-api';

const app = createApp({
apis,
Expand Down Expand Up @@ -90,6 +90,12 @@ const app = createApp({
message: 'Sign in using GitHub',
apiRef: githubAuthApiRef,
},
{
id: 'gitlab-auth-provider',
title: 'GitLab',
message: 'Sign in using GitLab',
apiRef: gitlabAuthApiRef,
},
]}
/>
),
Expand Down
2 changes: 2 additions & 0 deletions workspaces/x2a/packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@backstage/plugin-app-backend": "^0.5.8",
"@backstage/plugin-auth-backend": "^0.25.6",
"@backstage/plugin-auth-backend-module-github-provider": "^0.3.9",
"@backstage/plugin-auth-backend-module-gitlab-provider": "^0.3.9",
"@backstage/plugin-auth-backend-module-guest-provider": "^0.2.14",
"@backstage/plugin-auth-node": "^0.6.9",
"@backstage/plugin-catalog-backend": "^3.2.0",
Expand All @@ -40,6 +41,7 @@
"@backstage/plugin-proxy-backend": "^0.6.8",
"@backstage/plugin-scaffolder-backend": "^3.0.1",
"@backstage/plugin-scaffolder-backend-module-github": "^0.9.2",
"@backstage/plugin-scaffolder-backend-module-gitlab": "^0.11.3",
"@backstage/plugin-scaffolder-backend-module-notifications": "^0.1.16",
"@backstage/plugin-search-backend": "^2.0.8",
"@backstage/plugin-search-backend-module-catalog": "^0.3.10",
Expand Down
3 changes: 3 additions & 0 deletions workspaces/x2a/packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ backend.add(import('@backstage/plugin-proxy-backend'));
// scaffolder plugin
backend.add(import('@backstage/plugin-scaffolder-backend'));
backend.add(import('@backstage/plugin-scaffolder-backend-module-github'));
backend.add(import('@backstage/plugin-scaffolder-backend-module-gitlab'));
backend.add(
import('@backstage/plugin-scaffolder-backend-module-notifications'),
);
Expand All @@ -36,6 +37,8 @@ backend.add(import('@backstage/plugin-auth-backend'));
// See https://backstage.io/docs/backend-system/building-backends/migrating#the-auth-plugin
backend.add(import('@backstage/plugin-auth-backend-module-guest-provider'));
backend.add(import('@backstage/plugin-auth-backend-module-github-provider'));
backend.add(import('@backstage/plugin-auth-backend-module-gitlab-provider'));

// See https://backstage.io/docs/auth/guest/provider

// catalog plugin
Expand Down
Loading