-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mta-plugins): Adds a suite of MTA Plugins (#1147)
* initial commit for adding MTA Plugins * add changeset * prettier fixes * add api report scripts * add missing report dependencies * add reports * package.json updates for api-report resolution * yarn dedupe * update yarn lock file * fixup! API reports * move to @backstage-community from @internal * add Release tags * add app-config.yaml file * yarn backstage-cli repo fix --publish * remove placeholder tests * ensure clean working dir * yarn install * yarn lint fixes * generate report changes * yarn dedupe * fix misformatted .gitignore to correctly ignore files * update git cache post ignore update * update changeset * fixup! remove not published packages from changeset Signed-off-by: Ian Bolton <[email protected]>
- Loading branch information
1 parent
33c5767
commit 1af9fb3
Showing
127 changed files
with
43,611 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
'@backstage-community/backstage-plugin-catalog-backend-module-mta-entity-provider': patch | ||
'@backstage-community/backstage-plugin-scaffolder-backend-module-mta': patch | ||
'@backstage-community/backstage-plugin-mta-frontend': patch | ||
'@backstage-community/backstage-plugin-mta-backend': patch | ||
--- | ||
|
||
Rename the package names to be included in @backstage-community |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "public", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.git | ||
.yarn/cache | ||
.yarn/install-state.gz | ||
node_modules | ||
packages/*/src | ||
packages/*/node_modules | ||
plugins | ||
*.local.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
playwright.config.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = { root: true, }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# macOS | ||
.DS_Store | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Coverage directory generated when running tests with coverage | ||
coverage | ||
|
||
# Dependencies | ||
node_modules/ | ||
|
||
# Yarn 3 files | ||
.pnp.* | ||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
|
||
# Node version directives | ||
.nvmrc | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# Build output | ||
dist | ||
dist-types | ||
|
||
# Temporary change files created by Vim | ||
*.swp | ||
|
||
# MkDocs build output | ||
site | ||
|
||
# Local configuration files | ||
*.local.yaml | ||
|
||
# Sensitive credentials | ||
*-credentials.yaml | ||
|
||
# vscode database functionality support files | ||
*.session.sql | ||
|
||
# E2E test reports | ||
e2e-test-report/ | ||
|
||
# Yarn install state | ||
.yarn/install-state.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dist | ||
dist-types | ||
coverage | ||
.vscode | ||
.eslintrc.js | ||
api-report.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
# Uses "npm pack" to create .tgz files containing the plugin static assets | ||
DYNAMIC_PLUGIN_ROOT_DIR=./deploy | ||
echo "" | ||
echo "Packaging up plugin static assets" | ||
echo "" | ||
|
||
# Force script to stop on error | ||
# set -e | ||
|
||
# Additional debugging info | ||
# set -x | ||
|
||
MTA_BACKEND_INTEGRITY_HASH=$(npm pack plugins/mta-backend/dist-dynamic --pack-destination $DYNAMIC_PLUGIN_ROOT_DIR --json | jq -r '.[0].integrity') | ||
echo "mta-backend plugin integrity Hash: $MTA_BACKEND_INTEGRITY_HASH" | ||
|
||
MTA_FRONTEND_INTEGRITY_HASH=$(npm pack plugins/mta-frontend/dist-dynamic --pack-destination $DYNAMIC_PLUGIN_ROOT_DIR --json | jq -r '.[0].integrity') | ||
echo "mta-frontend plugin integrity Hash: $MTA_FRONTEND_INTEGRITY_HASH" | ||
|
||
CATALOG_BACKEND_MODULE_INTEGRITY_HASH=$(npm pack plugins/catalog-backend-module-mta-entity-provider/dist-dynamic --pack-destination $DYNAMIC_PLUGIN_ROOT_DIR --json | jq -r '.[0].integrity') | ||
echo "Catalog module plugin integrity Hash: $CATALOG_BACKEND_MODULE_INTEGRITY_HASH" | ||
|
||
SCAFFOLDER_BACKEND_MODULE_INTEGRITY_HASH=$(npm pack plugins/scaffolder-backend-module-mta/dist-dynamic --pack-destination $DYNAMIC_PLUGIN_ROOT_DIR --json | jq -r '.[0].integrity') | ||
echo "Scaffolder module plugin integrity Hash: $SCAFFOLDER_BACKEND_MODULE_INTEGRITY_HASH" | ||
|
||
|
||
echo "" | ||
echo "Plugin .tgz files:" | ||
ls -l $DYNAMIC_PLUGIN_ROOT_DIR | ||
echo "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
# Create a new build configuration | ||
oc new-build httpd --name=plugin-registry --binary | ||
|
||
# Start a build from the contents of our deploy directory for the initial image | ||
oc start-build plugin-registry --from-dir=./deploy --wait | ||
|
||
# Create the plugin registry httpd instance | ||
oc new-app --image-stream=plugin-registry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# backstage-mta-plugins | ||
|
||
Welcome to the backstage-mta plugin! | ||
|
||
_These plugins were created through the Backstage CLI_ | ||
|
||
## Getting started | ||
|
||
There are four plugins available in this repository: | ||
|
||
- [MTA Backend Plugin](./plugins/mta-backend) | ||
- [MTA Frontend Plugin](./plugins/mta-frontend) | ||
- [Catalog MTA Entity Providwer Plugin](./plugins/catalog-backend-module-mta-entity-provider) | ||
- [Scaffolder MTA Plugin](./plugins/scaffolder-backend-module-mta) | ||
|
||
You can also serve each plugin in isolation by running `yarn start` in each plugins respective directory. | ||
This method of serving the plugin provides quicker iteration speed and a faster startup and hot reloads. | ||
It is only meant for local development, and the setup for it can be found inside the [/dev](/dev) directory. | ||
|
||
## Introduction | ||
|
||
These plugins are designed to work in unison to provide a means to create and analyze applications in MTA (Migration toolkit for Applications). Within this readme, you will find instructions on how to develop, test, and deploy these plugins. | ||
|
||
### MTA / Tackle prerequisites | ||
|
||
- To begin, you will need to have an MTA instance running in your cluster. For upstream MTA (Tackle), you can follow the instructions [here](https://github.com/konveyor/operator?tab=readme-ov-file#konveyor-operator-installation-on-k8s). | ||
|
||
- Create a Tackle instance in the cluster. This can be done by running the following command: | ||
|
||
``` | ||
kubectl apply -f https://raw.githubusercontent.com/konveyor/tackle2-operator/main/tackle-k8s.yaml | ||
``` | ||
|
||
- Once the tackle instance is running, you can create a Tackle CR to configure the tackle instance. You can apply the CR by running the following command: | ||
|
||
``` | ||
cat << EOF | kubectl apply -f - | ||
kind: Tackle | ||
apiVersion: tackle.konveyor.io/v1alpha1 | ||
metadata: | ||
name: tackle | ||
namespace: konveyor-tackle | ||
spec: | ||
feature_auth_required: false | ||
EOF | ||
``` | ||
|
||
- Obtain the URL for the tackle instance by running the following command: | ||
|
||
``` | ||
oc get routes | ||
``` | ||
|
||
You will need the URL for the tackle instance to configure the MTA plugin. This URL needs to be added to the app-config configmap [here](app-config-rhdh.example.yaml) under the `mta` key. Be sure to add the `http://` or `https://` prefix to the URL. | ||
|
||
- Additionally, The MTA plugin requires a keycloak instance to authenticate with the MTA instance. This can be created and configured simply by running the [Tackle create keycloak script](tackle-create-keycloak-client.sh) or the [MTA create keycloak script](mta-create-keycloak-client.sh). This will create a keycloak client for the MTA instance and provide the necessary configuration for the MTA plugin. The keycloak configuration also needs to be added to the app-config configmap [here](app-config-rhdh.example.yaml) under the `mta` key. | ||
|
||
### RHDH Operator | ||
|
||
- To begin setting up the RHDH operator for local development, you will need to clone the repository from [here](https://github.com/redhat-developer/rhdh-operator) and follow the instructions in the README.md file. This will allow you to deploy the RHDH operator to your local cluster. You will need to run `make deploy` after cloning the repo from the project root. This will ensure all CRDs are installed first. Then you will need to create the backstage rhdh CR. An example of the backstage CR can be found [here](./backstage-operator-cr.yaml). Note the referenced configmaps in the CR, as they will be needed for the plugins to function correctly. | ||
|
||
### Configmaps and Secrets | ||
|
||
- Two primary configmaps are required to get the MTA plugin loaded as a dynamic plugin within RHDH: | ||
|
||
- [App config](app-config-rhdh.example.yaml) - Rename this file to app-config-rhdh.yaml and update the values as needed. This configmap contains the configuration for the backstage instance. The keys are as follows: | ||
|
||
- `mta` - Contains the configuration for the MTA resources. | ||
|
||
- `url` - The URL for the MTA instance running in the cluster. | ||
- `providerAuth` - The keycloak authentication configuration for the MTA instance. | ||
- `realm` - The realm for the keycloak instance. | ||
- `clientId` - The client ID for the keycloak instance.A | ||
- `secret` - The client secret for the keycloak instance. | ||
|
||
- `dynamicPlugins` - Contains the configuration for the front end dynamic plugins. More info [here](https://github.com/janus-idp/backstage-showcase/blob/main/showcase-docs/dynamic-plugins.md#customizing-and-adding-entity-tabs) | ||
|
||
- [Dynamic plugins](dynamic-plugins.yaml) | ||
|
||
- `package` - The package name for the plugin. | ||
- `integrity` - The integrity hash for the plugin. | ||
- `disabled` - Whether the plugin is enabled or not. | ||
|
||
- A script is available for reference [here](01-stage-dynamic-plugins.sh) that will package up the plugins into the deploy directory and generate the integrity hashes for the plugins. When the time comes to deploy the plugins, you will also need to create a plugin-registry using the script [here](02-create-plugin-registry.sh). This will create a plugin registry that the RHDH operator will use to deploy the plugins. A detailed end to end guide can be found [here](https://github.com/gashcrumb/dynamic-plugins-getting-started/tree/main) | ||
|
||
## Compile for Dynamic plugin testing | ||
|
||
- Once you have made necessary modification to the configmap and secrets, you can compile the plugin by running the following commands in the plugin directory. | ||
|
||
``` | ||
./rebuild-script.sh | ||
``` | ||
|
||
This script will: | ||
|
||
- Delete the existing namespace for the plugin if it exists. | ||
- Run `yarn && yarn run tsc && yarn run build:all` to compile the plugin. | ||
- Export each plugin as a dynamic plugin to their own respective dist-dynamic directory using the janus-cli. | ||
- Run npm pack to create a tarball of each plugin into the dynamic plugin root directory ( ./deploy ). | ||
- Create a new namespace for the backstage instance. | ||
- Generate the integrity hash for each plugin and reference it within the dynamic-plugin configmap defined inline within the script. | ||
- Create the plugin registry for the dynamic plugins. | ||
- Apply the app-config and dynamic-plugins configmaps to the cluster. | ||
- Create the backstage instance using the RHDH operator. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: app-config-rhdh | ||
labels: | ||
# This needs to be set to the value of the 'EXT_CONF_SYNC_backstage' env var in the operator container, which is 'true' if unset | ||
rhdh.redhat.com/ext-config-sync: 'true' | ||
annotations: | ||
rhdh.redhat.com/backstage-name: 'developer-hub' | ||
data: | ||
app-config-rhdh.yaml: |- | ||
app: | ||
title: Red Hat Developer Hub - Migration Toolkit for Applications | ||
baseUrl: <BACKSTAGE_URL> | ||
backend: | ||
baseUrl: <BACKSTAGE_URL> | ||
cors: | ||
origin: <BACKSTAGE_URL> | ||
methods: [GET, HEAD, PATCH, POST, PUT, DELETE] | ||
credentials: true | ||
auth: | ||
dangerouslyDisableDefaultAuthPolicy: true | ||
mta: | ||
url: <MTA_URL> | ||
providerAuth: | ||
realm: tackle | ||
secret: backstage-provider-secret | ||
clientID: backstage-provider | ||
auth: | ||
dangerouslyDisableDefaultAuthPolicy: true | ||
providers: | ||
guest: | ||
dangerouslyAllowOutsideDevelopment: true | ||
dynamicPlugins: | ||
frontend: | ||
internal.backstage-plugin-mta-frontend: | ||
entityTabs: | ||
- path: /mta | ||
title: MTA | ||
mountPoint: entity.page.mta | ||
mountPoints: | ||
- mountPoint: entity.page.mta/cards | ||
importName: EntityMTAContent | ||
config: | ||
layout: | ||
gridColumn: | ||
lg: 'span 12' | ||
md: 'span 8' | ||
xs: 'span 6' | ||
if: | ||
allOf: | ||
- isKind: component | ||
- isType: service | ||
catalog: | ||
import: | ||
entityFilename: catalog-info.yaml | ||
pullRequestBranchName: backstage-integration | ||
rules: | ||
- allow: [Component, System, API, Resource, Location] | ||
locations: | ||
- type: url | ||
target: https://github.com/ibolton336/backstage-mta-plugins/blob/main/create-application-template.yaml | ||
rules: | ||
- allow: [Template] | ||
- type: file | ||
target: create-application-template.yaml | ||
rules: | ||
- allow: [Template] |
Oops, something went wrong.