diff --git a/.dockerignore b/.dockerignore index f341c68..cce8f97 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,10 +1,6 @@ -.git -.yarn/cache -.yarn/install-state.gz +dist-types node_modules -packages/*/src +packages/*/dist packages/*/node_modules -plugins -*.local.yaml -github-integration.yaml -k8s-config.yaml +plugins/*/dist +plugins/*/node_modules diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..e5b1994 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +playwright.config.ts diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml new file mode 100644 index 0000000..9bb12b8 --- /dev/null +++ b/.github/workflows/build-and-push.yaml @@ -0,0 +1,51 @@ +name: ci + +on: push + +jobs: + build: + runs-on: ubuntu-22.04 + + steps: + - + name: Repository meta + id: repository + run: | + registry=${{ github.server_url }} + registry=${registry##http*://} + echo "registry=${registry}" >> "$GITHUB_OUTPUT" + echo "registry=${registry}" + repository="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" + echo "repository=${repository}" >> "$GITHUB_OUTPUT" + echo "repository=${repository}" + - + name: Docker meta + uses: docker/metadata-action@v5 + id: docker + with: + images: ${{ steps.repository.outputs.registry }}/${{ steps.repository.outputs.repository }} + - + name: Login to registry + uses: docker/login-action@v3 + with: + registry: ${{ steps.repository.outputs.registry }} + username: ${{ secrets.PACKAGES_USER }} + password: ${{ secrets.PACKAGES_TOKEN }} + - + name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + buildkitd-flags: '--allow-insecure-entitlement network.host' + driver-opts: network=host + - + name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + allow: network.host + network: host + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.docker.outputs.tags }} diff --git a/.github/workflows/dependabot-automerge.yaml b/.github/workflows/dependabot-automerge.yaml deleted file mode 100644 index 321af57..0000000 --- a/.github/workflows/dependabot-automerge.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: Dependabot auto-merge - -on: - pull_request_target: - branches: [ main ] - types: [ opened ] - -permissions: - pull-requests: write - contents: write - -jobs: - enableAutoMerge: - runs-on: ubuntu-latest - if: github.event.pull_request.user.login == 'dependabot[bot]' - steps: - - name: Enable auto-merge for Dependabot PRs - run: gh pr merge --auto --merge "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - diff --git a/.gitignore b/.gitignore index 922f4c1..fbf8139 100644 --- a/.gitignore +++ b/.gitignore @@ -27,9 +27,6 @@ node_modules/ # Node version directives .nvmrc -# NPM config files -.npmrc - # dotenv environment variables file .env .env.test @@ -53,5 +50,5 @@ site # vscode database functionality support files *.session.sql -# JetBrains -.idea +# E2E test reports +e2e-test-report/ diff --git a/.yarnrc.yml b/.yarnrc.yml new file mode 100644 index 0000000..3186f3f --- /dev/null +++ b/.yarnrc.yml @@ -0,0 +1 @@ +nodeLinker: node-modules diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6d4d598 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,94 @@ +# Stage 1 - Create yarn install skeleton layer +FROM node:20.18.1 AS packages + +WORKDIR /app +COPY package.json yarn.lock ./ + +COPY packages packages + +# Comment this out if you don't have any internal plugins +COPY plugins plugins + +RUN find packages \! -name "package.json" -mindepth 2 -maxdepth 2 -exec rm -rf {} \+ + +# Stage 2 - Install dependencies and build packages +FROM node:20.18.1 AS build + +# Required for arm64 +RUN apt update -y +RUN apt install -y python3 make gcc build-essential bash + +USER node +WORKDIR /app + +COPY --from=packages --chown=node:node /app . + +RUN --mount=type=cache,target=/home/node/.cache/yarn,sharing=locked,uid=1000,gid=1000 \ + yarn install --network-timeout 600000 + +COPY --chown=node:node . . + +RUN yarn tsc +RUN yarn --cwd packages/backend build +# If you have not yet migrated to package roles, use the following command instead: +# RUN yarn --cwd packages/backend backstage-cli backend:bundle --build-dependencies + +RUN mkdir packages/backend/dist/skeleton packages/backend/dist/bundle \ + && tar xzf packages/backend/dist/skeleton.tar.gz -C packages/backend/dist/skeleton \ + && tar xzf packages/backend/dist/bundle.tar.gz -C packages/backend/dist/bundle + +# Stage 3 - Build the actual backend image and install production dependencies +FROM node:20.18.1 + +# Install isolate-vm dependencies, these are needed by the @backstage/plugin-scaffolder-backend. +# Install packages needed to get utility binaries +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update && \ + apt-get install -y --no-install-recommends python3 python3-pip python3-venv g++ build-essential ca-certificates curl + +RUN yarn config set python /usr/bin/python3 + +# Add kubectl for the kube apply plugin. +# Add mkdocs for the TechDocs plugin. +RUN if test "$(uname -m)" = "x86_64"; \ + then \ + curl -L -o /usr/local/bin/kubectl https://dl.k8s.io/release/v1.29.9/bin/linux/amd64/kubectl; \ + fi +RUN if test "$(uname -m)" != "x86_64"; \ + then \ + curl -L -o /usr/local/bin/kubectl https://dl.k8s.io/release/v1.29.9/bin/linux/arm64/kubectl; \ + fi +RUN chmod +x /usr/local/bin/kubectl + +ENV VIRTUAL_ENV=/opt/venv +RUN python3 -m venv $VIRTUAL_ENV +ENV PATH="$VIRTUAL_ENV/bin:$PATH" +RUN pip3 install 'mkdocs-techdocs-core==1.4.2' 'mkdocs-awesome-pages-plugin==2.10.1' + +# From here on we use the least-privileged `node` user to run the backend. +USER node + +# This should create the app dir as `node`. +# If it is instead created as `root` then the `tar` command below will +# fail: `can't create directory 'packages/': Permission denied`. +# If this occurs, then ensure BuildKit is enabled (`DOCKER_BUILDKIT=1`) +# so the app dir is correctly created as `node`. +WORKDIR /app + +# Copy the install dependencies from the build stage and context +COPY --from=build --chown=node:node /app/yarn.lock /app/package.json /app/packages/backend/dist/skeleton/ ./ + +RUN --mount=type=cache,target=/home/node/.cache/yarn,sharing=locked,uid=1000,gid=1000 \ + yarn install --production --network-timeout 600000 + +# Copy the built packages from the build stage +COPY --from=build --chown=node:node /app/packages/backend/dist/bundle/ ./ + +# Copy any other files that we need at runtime +COPY --chown=node:node app-config.yaml ./ + +# This switches many Node.js dependencies to production mode. +ENV NODE_ENV production + +CMD ["node", "packages/backend", "--config", "app-config.yaml"] diff --git a/LICENSE b/LICENSE deleted file mode 100644 index d645695..0000000 --- a/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/README.md b/README.md index 8c7c437..61707f6 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,116 @@ -# [Backstage](https://backstage.io) +# EDP Backstage -This is your newly scaffolded Backstage App, Good Luck! +The EDP bespoke version of backstage. -To start the app, run: +With respect to the CNOE stack (where eDF originates from) it is comparable to https://github.com/cnoe-io/backstage-app -```sh -yarn install -yarn dev +At the time writing CNOE-backstage-app is "version": "1.28.4" + +## Container Images + +Container images are pushed to the Cefor Container Registry and available [here](https://forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/DevFW-CICD/-/packages/container/backstage-edp/). + + +## Local Development + +Use of [**edpbuilder**](https://forgejo.edf-bootstrap.cx.fg1.ffm.osc.live/DevFW/edpbuilder.git) is recommended for local setup. + +### Create your local cluster + +Once edpbuilder is installed on your computer, create a stack that you are interested in. For example: + +> Hint: From here on this is the old CNOE README .... no guarantee that this works as described! + +### Update Backstage application config + +Once all ArgoCD applications are healthy, you need to update a few fields in the [app-config.yaml](./app-config.yaml) file. + +#### Update control plane URL + +The control plane port must be updated every time a cluster is created. Run the `kubectl cluster-info` command to get the control plane URL. Once you have your URL, update your `app-config.yaml` file at [this line](https://github.com/cnoe-io/backstage-app/blob/9ee3514e51c1a354b7fe85a90117faf8328bfa0b/app-config.yaml#L122). + +For example: + +```bash +$ kubectl cluster-info + +Kubernetes control plane is running at https://127.0.0.1:36463 +CoreDNS is running at https://127.0.0.1:36463/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy +``` + +For this particular example output, the `https://127.0.0.1:36463` above is the URL you need to use in your `app-config.yaml`. + +#### Update service account token + +Since tokens are generated each time the backstage service account is created, you need to update this value as well. The command to retrieve the service account token is: + +`kubectl -n backstage exec -it deploy/backstage -- cat /var/run/secrets/kubernetes.io/serviceaccount/token` + +Copy the token value and updated the app-config file at [this line](https://github.com/cnoe-io/backstage-app/blob/main/app-config.yaml#L127). + +For example: + +```bash +$ kubectl -n backstage exec -it deploy/backstage -- cat /var/run/secrets/kubernetes.io/serviceaccount/token + +eyJhbGciOiJSUzI1NiIsImtpZCI6IkRxbDRCSnNicjFwekFqdmxwNDc5MHJqeUlFSjhxNHU0LV95OC1s... +``` + +If you do not want to place the token value in your file, you can use environment variables instead: +1. Set [this line](https://github.com/cnoe-io/backstage-app/blob/main/app-config.yaml#L127) value to be `${BACKSTAGE_SA_TOKEN}`. +2. Then export the token value: + ```bash + export BACKSTAGE_SA_TOKEN=$(kubectl -n backstage exec -it deploy/backstage -- cat /var/run/secrets/kubernetes.io/serviceaccount/token) + ``` + +#### Update ArgoCD token + +ArgoCD admin passwords are generated on each fresh installation. You need to update the configuration file accordingly. To obtain your password, run: `./idpbuilder get secrets -p argocd`. Then update [this line](https://github.com/cnoe-io/backstage-app/blob/9ee3514e51c1a354b7fe85a90117faf8328bfa0b/app-config.yaml#L136) + +For example: + +```bash +$ ./idpbuilder get secrets -p argocd + +--------------------------- +Name: argocd-initial-admin-secret +Namespace: argocd +Data: + password : abc + username : admin +``` + +#### Update Gitea Credentials + +Gitea admin passwords are generated on each fresh installation as well. To obtain your password, run: `./idpbuilder get secrets -p argocd`. +Then update [this line](https://github.com/cnoe-io/backstage-app/blob/9ee3514e51c1a354b7fe85a90117faf8328bfa0b/app-config.yaml#L40) and [this line](https://github.com/cnoe-io/backstage-app/blob/9ee3514e51c1a354b7fe85a90117faf8328bfa0b/app-config.yaml#L44). + +For example: + +```bash +$ ./idpbuilder get secrets -p gitea + +--------------------------- +Name: gitea-credential +Namespace: gitea +Data: + password : abc + username : giteaAdmin +```` + +### Start Backstage processes + +Once the `app-config.yaml` file is updated, you are ready to start your backstage instance. For development purposes, using two terminal windows or tabs is recommended. You can also run them through your favorite IDE. + +In the first terminal tab, install dependencies and start the backend. + +```bash +yarn install +yarn run start-backend +``` + +In the first terminal tab, run the frontend. + +```bash +yarn run start ``` diff --git a/app-config.production.yaml b/app-config.production.yaml index df09dac..8f0751c 100644 --- a/app-config.production.yaml +++ b/app-config.production.yaml @@ -30,6 +30,6 @@ backend: catalog: # Overrides the default list locations from app-config.yaml as these contain example data. - # See https://backstage.io/docs/features/software-catalog/software-catalog-overview#adding-components-to-the-catalog for more details + # See https://backstage.io/docs/features/software-catalog/#adding-components-to-the-catalog for more details # on how to get entities into the catalog. locations: [] diff --git a/app-config.yaml b/app-config.yaml index f1860c4..0006a70 100644 --- a/app-config.yaml +++ b/app-config.yaml @@ -7,7 +7,7 @@ organization: backend: # Used for enabling authentication, secret is shared by all backend plugins - # See https://backstage.io/docs/tutorials/backend-to-backend-auth for + # See https://backstage.io/docs/auth/service-to-service-auth for # information on the format # auth: # keys: @@ -30,26 +30,25 @@ backend: database: client: better-sqlite3 connection: ':memory:' - cache: - store: memory # workingDirectory: /tmp # Use this to configure a working directory for the scaffolder, defaults to the OS temp-dir - -integrations: {} -# - 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/getting-started/configuration#setting-up-a-github-integration -# 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} +integrations: + gitea: + - baseUrl: https://cnoe.localtest.me:8443/gitea + host: cnoe.localtest.me:8443 + username: giteaAdmin + password: ${GITEA_PASSWORD} + - baseUrl: https://cnoe.localtest.me/gitea + host: cnoe.localtest.me + username: giteaAdmin + password: ${GITEA_PASSWORD} proxy: ### Example for how to add a proxy endpoint for the frontend. ### A typical reason to do this is to handle HTTPS and CORS for internal services. - # '/test': - # target: 'https://example.com' - # changeOrigin: true + # endpoints: + # '/test': + # target: 'https://example.com' + # changeOrigin: true # Reference documentation http://backstage.io/docs/features/techdocs/configuration # Note: After experimenting with basic setup, use CI/CD to generate docs @@ -61,25 +60,76 @@ techdocs: runIn: 'docker' # Alternatives - 'local' publisher: type: 'local' # Alternatives - 'googleGcs' or 'awsS3'. Read documentation for using alternatives. - auth: # see https://backstage.io/docs/auth/ to learn about auth providers - environment: local - providers: {} + environment: local # set this to development to enable SSO + session: + secret: abcdfkjalskdfjkla + providers: + guest: {} + keycloak-oidc: + development: + metadataUrl: https://cnoe.localtest.me:8443/keycloak/realms/cnoe/.well-known/openid-configuration + clientId: backstage + clientSecret: ${KEYCLOAK_CLIENT_SECRET} + prompt: auto scaffolder: # see https://backstage.io/docs/features/software-templates/configuration for software template options - + defaultAuthor: + name: backstage-scaffolder + email: noreply + defaultCommitMessage: "backstage scaffolder" catalog: import: entityFilename: catalog-info.yaml pullRequestBranchName: backstage-integration rules: - - allow: [Component, System, API, Resource, Location, Template] - locations: [] + - allow: [ Component, System, API, Resource, Location, Template ] + locations: + - type: url + target: https://cnoe.localtest.me:8443/gitea/giteaAdmin/idpbuilder-localdev-backstage-templates-entities/src/branch/main/catalog-info.yaml +# # Local example template +# - type: file +# target: ../../examples/template/template.yaml +# rules: +# - allow: [Template] +# +# # Local example organizational data +# - type: file +# target: ../../examples/org.yaml +# rules: +# - allow: [User, Group] + ## Uncomment these lines to add more example data + # - type: url + # target: https://github.com/backstage/backstage/blob/master/packages/catalog-model/examples/all.yaml + + ## Uncomment these lines to add an example org + # - type: url + # target: https://github.com/backstage/backstage/blob/master/packages/catalog-model/examples/acme-corp.yaml + # rules: + # - allow: [User, Group] kubernetes: serviceLocatorMethod: type: 'multiTenant' - clusterLocatorMethods: [] - + clusterLocatorMethods: + - type: 'config' + clusters: + - url: https://127.0.0.1:33277 # you may need to change this + name: local + authProvider: 'serviceAccount' + skipTLSVerify: true + # replace with your own service account token value. e.g. kubectl -n backstage exec -it deploy/backstage -- cat /var/run/secrets/kubernetes.io/serviceaccount/token + serviceAccountToken: eyJhbG...... +argocd: + appLocatorMethods: + - type: 'config' + instances: + - name: local + url: https://cnoe.localtest.me:8443/argocd + username: admin + # replace with your argocd password e.g. kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d + password: ${ARGOCD_ADMIN_PASSWORD} +argoWorkflows: + baseUrl: https://cnoe.localtest.me:8443/argo-workflows \ No newline at end of file diff --git a/backstage.json b/backstage.json index 6ba6f3d..c6aea75 100644 --- a/backstage.json +++ b/backstage.json @@ -1,3 +1,3 @@ { - "version": "1.16.0" + "version": "1.38.1" } diff --git a/catalog-info.yaml b/catalog-info.yaml index adbb41d..a968650 100644 --- a/catalog-info.yaml +++ b/catalog-info.yaml @@ -1,7 +1,7 @@ apiVersion: backstage.io/v1alpha1 kind: Component metadata: - name: backstage + name: backstage-idpbuilder description: An example of a Backstage application. # Example for optional annotations # annotations: diff --git a/cnoe-wrapper.sh b/cnoe-wrapper.sh new file mode 100644 index 0000000..4d5b490 --- /dev/null +++ b/cnoe-wrapper.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +SERVICE_ACCOUNT_DIR="/var/run/secrets/kubernetes.io/serviceaccount" +KUBERNETES_SERVICE_SCHEME=$(case $KUBERNETES_SERVICE_PORT in 80|8080|8081) echo "http";; *) echo "https"; esac) +KUBERNETES_SERVER_URL="$KUBERNETES_SERVICE_SCHEME"://"$KUBERNETES_SERVICE_HOST":"$KUBERNETES_SERVICE_PORT" +KUBERNETES_CLUSTER_CA_FILE="$SERVICE_ACCOUNT_DIR"/ca.crt +KUBERNETES_NAMESPACE=$(cat "$SERVICE_ACCOUNT_DIR"/namespace) +KUBERNETES_USER_TOKEN=$(cat "$SERVICE_ACCOUNT_DIR"/token) +KUBERNETES_CONTEXT="inCluster" + +rm -rf "$HOME"/.kube +mkdir -p "$HOME"/.kube +cat << EOF > "$HOME"/.kube/config +apiVersion: v1 +kind: Config +preferences: {} +current-context: $KUBERNETES_CONTEXT +clusters: +- cluster: + server: $KUBERNETES_SERVER_URL + certificate-authority: $KUBERNETES_CLUSTER_CA_FILE + name: inCluster +users: +- name: podServiceAccount + user: + token: $KUBERNETES_USER_TOKEN +contexts: +- context: + cluster: inCluster + user: podServiceAccount + namespace: $KUBERNETES_NAMESPACE + name: $KUBERNETES_CONTEXT +EOF + +cnoe-cli "$@" diff --git a/examples/k8s-apply/skeleton/cm.yaml b/examples/k8s-apply/skeleton/cm.yaml new file mode 100644 index 0000000..624feac --- /dev/null +++ b/examples/k8s-apply/skeleton/cm.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: game-demo +data: + # property-like keys; each key maps to a simple value + player_initial_lives: "3" + ui_properties_file_name: "user-interface.properties" + + # file-like keys + game.properties: | + enemy.types=aliens,monsters + player.maximum-lives=5 + user-interface.properties: | + color.good=purple + color.bad=yellow + allow.textmode=true diff --git a/examples/k8s-apply/template-manifest-object.yaml b/examples/k8s-apply/template-manifest-object.yaml new file mode 100644 index 0000000..f88963d --- /dev/null +++ b/examples/k8s-apply/template-manifest-object.yaml @@ -0,0 +1,41 @@ +apiVersion: scaffolder.backstage.io/v1beta3 +kind: Template +metadata: + name: deploy-resources-object + title: Deploy Resources using object + description: Deploy Resource to Kubernetes +spec: + owner: guest + type: service + # these are the steps which are rendered in the frontend with the form input + parameters: [] + steps: + - id: template + name: Generating component + action: fetch:template + input: + url: ./skeleton + - id: apply + name: apply-manifest + action: cnoe:kubernetes:apply + input: + namespaced: true + manifestObject: + apiVersion: v1 + kind: ConfigMap + metadata: + name: game-demo + data: + # property-like keys; each key maps to a simple value + player_initial_lives: "3" + ui_properties_file_name: "user-interface.properties" + + # file-like keys + game.properties: | + enemy.types=aliens,monsters + player.maximum-lives=5 + user-interface.properties: | + color.good=purple + color.bad=yellow + allow.textmode=true + clusterName: local diff --git a/examples/k8s-apply/template-manifest-string.yaml b/examples/k8s-apply/template-manifest-string.yaml new file mode 100644 index 0000000..312f557 --- /dev/null +++ b/examples/k8s-apply/template-manifest-string.yaml @@ -0,0 +1,41 @@ +apiVersion: scaffolder.backstage.io/v1beta3 +kind: Template +metadata: + name: deploy-resources-string + title: Deploy Resources using literal string + description: Deploy Resource to Kubernetes +spec: + owner: guest + type: service + # these are the steps which are rendered in the frontend with the form input + parameters: [] + steps: + - id: template + name: Generating component + action: fetch:template + input: + url: ./skeleton + - id: apply + name: apply-manifest + action: cnoe:kubernetes:apply + input: + namespaced: true + manifestString: | + apiVersion: v1 + kind: ConfigMap + metadata: + name: game-demo + data: + # property-like keys; each key maps to a simple value + player_initial_lives: "3" + ui_properties_file_name: "user-interface.properties" + + # file-like keys + game.properties: | + enemy.types=aliens,monsters + player.maximum-lives=5 + user-interface.properties: | + color.good=purple + color.bad=yellow + allow.textmode=true + clusterName: local diff --git a/examples/k8s-apply/template.yaml b/examples/k8s-apply/template.yaml new file mode 100644 index 0000000..3f097c3 --- /dev/null +++ b/examples/k8s-apply/template.yaml @@ -0,0 +1,30 @@ +apiVersion: scaffolder.backstage.io/v1beta3 +kind: Template +metadata: + name: deploy-resources + title: Deploy Resources + description: Deploy Resource to Kubernetes +spec: + owner: guest + type: service + # these are the steps which are rendered in the frontend with the form input + parameters: + - title: file name + properties: + path: + type: string + description: file name + default: cm.yaml + steps: + - id: template + name: Generating component + action: fetch:template + input: + url: ./skeleton + - id: apply + name: apply-manifest + action: cnoe:kubernetes:apply + input: + namespaced: true + manifestPath: cm.yaml + clusterName: local diff --git a/github-integration.yaml b/github-integration.yaml deleted file mode 100644 index d1b789a..0000000 --- a/github-integration.yaml +++ /dev/null @@ -1,9 +0,0 @@ -appId: 123456 -webhookUrl: https://somehwere -clientId: some.id -clientSecret: "" -webhookSecret: "" -privateKey: | - -----BEGIN RSA PRIVATE KEY----- - - -----END RSA PRIVATE KEY----- diff --git a/k8s-config.yaml b/k8s-config.yaml deleted file mode 100644 index 91b3c97..0000000 --- a/k8s-config.yaml +++ /dev/null @@ -1,16 +0,0 @@ -type: 'config' -clusters: - - url: https://3CEBA3CA7870A3E5BFE2CF3FA173EE56.gr7.us-west-2.eks.amazonaws.com:443 - name: canoe-packaging - authProvider: 'serviceAccount' - skipTLSVerify: false - skipMetricsLookup: true - serviceAccountToken: "" -# dashboardUrl: http://127.0.0.1:64713 # url copied from running the command: minikube service kubernetes-dashboard -n kubernetes-dashboard -# dashboardApp: standard - caData: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakNDQWVhZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJek1ERXlOVEl3TkRBMU5Wb1hEVE16TURFeU1qSXdOREExTlZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTlJvCnU5dkl6cjZmVEk4RThyR0Q2RHNoLzhyK0lkWmFHZGxsUytKbDN0Q2JteTVYUU15NnpOMU5acG1zRHpDTC9nUlIKS0s5WTVhUmRUWjFLdklkekRMQXdMeXpqODk5clJtYjB2aXUzR0ZQdDcxSWFYMEp1VmQwaTBrQit5Y01jSFo2QgpjOGhmMUErM1I2VVpCZDZsaUx0dG5pUjZwb29oYXdobG5DSEN4L1oyd014YWEvU21SUWxDMjhhTEhLZC9ZU0s2CndXS1VOQmVTMmpGZGc5bVVkcnJDREx5MkxqUTNUcUtPVW9PNEQ3bm9rVTh1NUFtejhldWFxdzR4U25ZMExucmsKWVk1MmhvOW5qRnZwOE5WQnE1VjRPUFVXaEhvQXE4TnZjZlVITkNSdWZkN09FZG85Y2t1Q1B3VzFiZWxNOW9oeApURFAvWFlsS09INFVQTDFHeUJFQ0F3RUFBYU5aTUZjd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0hRWURWUjBPQkJZRUZOeUgrRTZxb2VMTlVEVkl4ZXpTSjk3STRoZytNQlVHQTFVZEVRUU8KTUF5Q0NtdDFZbVZ5Ym1WMFpYTXdEUVlKS29aSWh2Y05BUUVMQlFBRGdnRUJBRDVoeStNaDBRdHJ6dG5vV0tFRgpTaFFsanE1cjJGYUZablAyYU9OWS9uaHNxdThjSmZkbWFyQUtsR1JkRTBocnVoaGprdE55ckdmcEZ5d1ErR0hhClR4d0N6NW9uUEhYaTRNZnBadEpaNzZYSERtT3BFR2diSTFhL0VCQUV2YkxHSVRWT3NTMmQ2MTFKTTF0bkJKRFgKNERFaVc5aXJ1Nm1wR2NaQ1JWYlhUT005cHV1V0NTQ1pPNktKZ29NZlVMbnpHT0diN0ludmtoajBJZThQQ0JGWQpWUmFvRm5NNE5HMUdHMnpuckcrNjFucFlBbGpGcjhQN2J4WmRsWWpPcjFGbFhydU1UeEdEZEpNYkNTcFViRmRUCkxOOVUxYlFNS3JBN3NsZEJCcTc0ZHlUZkNKZDFQaGdMSzZZbVZGdFo3Vmk4eFkwbjlpa2svZEpDWjM5aTFWR2wKK3NzPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg== -# caFile: '' # local path to CA file - customResources: - - group: 'argoproj.io' - apiVersion: 'v1alpha1' - plural: 'applications' diff --git a/lerna.json b/lerna.json index 322929d..529a62f 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "packages": ["packages/*", "plugins/*"], "npmClient": "yarn", - "useWorkspaces": true, - "version": "0.1.0" + "version": "0.1.0", + "$schema": "node_modules/lerna/schemas/lerna-schema.json" } diff --git a/package.json b/package.json index bffed22..7e09d0f 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "private": true, "engines": { - "node": "16 || 18" + "node": "18 || 20" }, "scripts": { "dev": "concurrently \"yarn start\" \"yarn start-backend\"", @@ -17,6 +17,8 @@ "clean": "backstage-cli repo clean", "test": "backstage-cli repo test", "test:all": "backstage-cli repo test --coverage", + "test:e2e": "playwright test", + "fix": "backstage-cli repo fix", "lint": "backstage-cli repo lint --since origin/main", "lint:all": "backstage-cli repo lint", "prettier:check": "prettier --check .", @@ -29,17 +31,19 @@ ] }, "devDependencies": { - "@backstage/cli": "^0.22.9", + "@backstage/cli": "^0.32.0", + "@backstage/e2e-test-utils": "^0.1.1", + "@playwright/test": "^1.32.3", "@spotify/prettier-config": "^12.0.0", - "concurrently": "^6.0.0", - "lerna": "^4.0.0", + "concurrently": "^8.0.0", + "lerna": "^7.3.0", "node-gyp": "^9.0.0", "prettier": "^2.3.2", - "typescript": "~4.6.4" + "typescript": "~5.2.0" }, "resolutions": { - "@types/react": "^17", - "@types/react-dom": "^17" + "@types/react": "^18", + "@types/react-dom": "^18" }, "prettier": "@spotify/prettier-config", "lint-staged": { diff --git a/packages/app/.eslintignore b/packages/app/.eslintignore new file mode 100644 index 0000000..a48cf0d --- /dev/null +++ b/packages/app/.eslintignore @@ -0,0 +1 @@ +public diff --git a/packages/app/cypress.json b/packages/app/cypress.json deleted file mode 100644 index 0cb845a..0000000 --- a/packages/app/cypress.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "baseUrl": "http://localhost:3001", - "fixturesFolder": false, - "pluginsFile": false, - "retries": 3 -} diff --git a/packages/app/cypress/.eslintrc.json b/packages/app/cypress/.eslintrc.json deleted file mode 100644 index a467608..0000000 --- a/packages/app/cypress/.eslintrc.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "plugins": ["cypress"], - "extends": ["plugin:cypress/recommended"], - "rules": { - "jest/expect-expect": [ - "error", - { - "assertFunctionNames": ["expect", "cy.contains"] - } - ] - } -} diff --git a/packages/app/cypress/integration/app.js b/packages/app/cypress/integration/app.js deleted file mode 100644 index 43fb2e3..0000000 --- a/packages/app/cypress/integration/app.js +++ /dev/null @@ -1,6 +0,0 @@ -describe('App', () => { - it('should render the catalog', () => { - cy.visit('/'); - cy.contains('My Company Catalog'); - }); -}); diff --git a/packages/app/e2e-tests/app.test.ts b/packages/app/e2e-tests/app.test.ts new file mode 100644 index 0000000..d45bc0d --- /dev/null +++ b/packages/app/e2e-tests/app.test.ts @@ -0,0 +1,23 @@ +/* + * Copyright 2020 The Backstage Authors + * + * 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 { test, expect } from '@playwright/test'; + +test('App should render the welcome page', async ({ page }) => { + await page.goto('/'); + + await expect(page.getByText('My Company Catalog')).toBeVisible(); +}); diff --git a/packages/app/package.json b/packages/app/package.json index 908bd8b..aba7302 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -11,69 +11,55 @@ "build": "backstage-cli package build", "clean": "backstage-cli package clean", "test": "backstage-cli package test", - "lint": "backstage-cli package lint", - "test:e2e": "cross-env PORT=3001 start-server-and-test start http://localhost:3001 cy:dev", - "test:e2e:ci": "cross-env PORT=3001 start-server-and-test start http://localhost:3001 cy:run", - "cy:dev": "cypress open", - "cy:run": "cypress run --browser chrome" + "lint": "backstage-cli package lint" }, "dependencies": { - "@backstage/app-defaults": "^1.4.1", - "@backstage/catalog-model": "^1.4.1", - "@backstage/cli": "^0.22.9", - "@backstage/core-app-api": "^1.9.0", - "@backstage/core-components": "^0.13.3", - "@backstage/core-plugin-api": "^1.5.3", - "@backstage/integration-react": "^1.1.15", - "@backstage/plugin-api-docs": "^0.9.6", - "@backstage/plugin-catalog": "^1.12.0", - "@backstage/plugin-catalog-common": "^1.0.15", - "@backstage/plugin-catalog-graph": "^0.2.32", - "@backstage/plugin-catalog-import": "^0.9.10", - "@backstage/plugin-catalog-react": "^1.8.0", - "@backstage/plugin-github-actions": "^0.6.1", - "@backstage/plugin-kubernetes": "^0.9.3", - "@backstage/plugin-org": "^0.6.10", - "@backstage/plugin-permission-react": "^0.4.14", - "@backstage/plugin-scaffolder": "^1.14.1", - "@backstage/plugin-scaffolder-react": "^1.5.1", - "@backstage/plugin-search": "^1.3.3", - "@backstage/plugin-search-react": "^1.6.3", - "@backstage/plugin-tech-radar": "^0.6.6", - "@backstage/plugin-techdocs": "^1.6.5", - "@backstage/plugin-techdocs-module-addons-contrib": "^1.0.15", - "@backstage/plugin-techdocs-react": "^1.1.8", - "@backstage/plugin-user-settings": "^0.7.5", - "@backstage/theme": "^0.4.1", - "@cnoe-io/plugin-apache-spark": "0.1.2", - "@cnoe-io/plugin-argo-workflows": "0.1.3", - "@cnoe-io/plugin-scaffolder-actions-frontend": "0.1.1", - "@internal/cnoe-ui-plugin": "^0.1.0", - "@internal/plugin-workflows": "^0.1.0", + "@backstage-community/plugin-github-actions": "^0.6.16", + "@backstage-community/plugin-tech-radar": "^0.7.4", + "@backstage/app-defaults": "^1.6.1", + "@backstage/catalog-model": "^1.7.3", + "@backstage/cli": "^0.32.0", + "@backstage/core-app-api": "^1.16.1", + "@backstage/core-components": "^0.17.1", + "@backstage/core-plugin-api": "^1.10.6", + "@backstage/integration-react": "^1.2.6", + "@backstage/plugin-api-docs": "^0.12.6", + "@backstage/plugin-catalog": "^1.29.0", + "@backstage/plugin-catalog-common": "^1.1.3", + "@backstage/plugin-catalog-graph": "^0.4.18", + "@backstage/plugin-catalog-import": "^0.12.13", + "@backstage/plugin-catalog-react": "^1.17.0", + "@backstage/plugin-home": "^0.8.7", + "@backstage/plugin-kubernetes": "^0.12.6", + "@backstage/plugin-org": "^0.6.38", + "@backstage/plugin-permission-react": "^0.4.33", + "@backstage/plugin-scaffolder": "^1.30.1", + "@backstage/plugin-search": "^1.4.25", + "@backstage/plugin-search-react": "^1.8.8", + "@backstage/plugin-techdocs": "^1.12.5", + "@backstage/plugin-techdocs-module-addons-contrib": "^1.1.23", + "@backstage/plugin-techdocs-react": "^1.2.16", + "@backstage/plugin-user-settings": "^0.8.21", + "@backstage/theme": "^0.6.5", "@material-ui/core": "^4.12.2", "@material-ui/icons": "^4.9.1", - "@rjsf/core": "^5.8.1", - "@rjsf/utils": "^5.8.1", - "@roadiehq/backstage-plugin-argo-cd": "^2.3.4", - "@types/fs-extra": "^11.0.1", - "fs-extra": "^11.1.1", + "@roadiehq/backstage-plugin-argo-cd": "^2.5.1", "history": "^5.0.0", - "react": "^17.0.2", - "react-dom": "^17.0.2", + "react": "^18.0.2", + "react-dom": "^18.0.2", + "react-router": "^6.3.0", "react-router-dom": "^6.3.0", "react-use": "^17.2.4" }, "devDependencies": { - "@backstage/test-utils": "^1.4.1", - "@testing-library/jest-dom": "^5.10.1", - "@testing-library/react": "^12.1.3", + "@backstage/test-utils": "^1.7.7", + "@playwright/test": "^1.32.3", + "@testing-library/dom": "^9.0.0", + "@testing-library/jest-dom": "^6.0.0", + "@testing-library/react": "^14.0.0", "@testing-library/user-event": "^14.0.0", - "@types/node": "^16.11.26", "@types/react-dom": "*", - "cross-env": "^7.0.0", - "cypress": "^9.7.0", - "eslint-plugin-cypress": "^2.10.3", - "start-server-and-test": "^1.10.11" + "cross-env": "^7.0.0" }, "browserslist": { "production": [ diff --git a/packages/app/public/index.html b/packages/app/public/index.html index c6083b3..fc758ee 100644 --- a/packages/app/public/index.html +++ b/packages/app/public/index.html @@ -8,7 +8,6 @@ name="description" content="Backstage is an open platform for building developer portals" /> -