diff --git a/.dockerignore b/.dockerignore index cce8f97..f341c68 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,10 @@ -dist-types +.git +.yarn/cache +.yarn/install-state.gz node_modules -packages/*/dist +packages/*/src packages/*/node_modules -plugins/*/dist -plugins/*/node_modules +plugins +*.local.yaml +github-integration.yaml +k8s-config.yaml diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index e5b1994..0000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -playwright.config.ts diff --git a/.github/workflows/build-and-push.yaml b/.github/workflows/build-and-push.yaml deleted file mode 100644 index 9bb12b8..0000000 --- a/.github/workflows/build-and-push.yaml +++ /dev/null @@ -1,51 +0,0 @@ -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/docker-image.yaml b/.github/workflows/docker-image.yaml new file mode 100644 index 0000000..b94e972 --- /dev/null +++ b/.github/workflows/docker-image.yaml @@ -0,0 +1,62 @@ +name: Build and Push Backstage Image + +on: + workflow_dispatch: + inputs: + branch: + description: "branch to build" + required: true + default: main + push: + branches: + - main + tags: + - 'v0.1.2' + +permissions: + id-token: write + contents: read + +jobs: + build: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + ref: main + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Install packages + run: NODE_OPTIONS="--max_old_space_size=4096" yarn install + + + - name: Bundle up + run: NODE_OPTIONS="--max_old_space_size=4096" yarn build:backend + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + role-to-assume: arn:aws:iam::209466391465:role/GitHubAction-AssumeRoleWithAction + role-session-name: GitHub_to_AWS_via_FederatedOIDC + aws-region: us-east-1 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, tag, and push the image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: ${{ secrets.REPO_NAME }} + IMAGE_TAG: ${{ github.sha }} + DOCKER_BUILDKIT: 1 + run: | + # Build a docker container and push it to ECR + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + echo "Pushing image to ECR..." + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + echo "name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT diff --git a/.gitignore b/.gitignore index fbf8139..d452ac2 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,3 @@ site # vscode database functionality support files *.session.sql - -# E2E test reports -e2e-test-report/ diff --git a/.yarnrc.yml b/.yarnrc.yml deleted file mode 100644 index 3186f3f..0000000 --- a/.yarnrc.yml +++ /dev/null @@ -1 +0,0 @@ -nodeLinker: node-modules diff --git a/Dockerfile b/Dockerfile index 6d4d598..6253238 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,94 +1,48 @@ -# Stage 1 - Create yarn install skeleton layer -FROM node:20.18.1 AS packages +# This dockerfile builds an image for the backend package. +# It should be executed with the root of the repo as docker context. +# +# Before building this image, be sure to have run the following commands in the repo root: +# +# yarn install +# yarn tsc +# yarn build:backend +# +# Once the commands have been run, you can build the image using `yarn build-image` -WORKDIR /app -COPY package.json yarn.lock ./ +#Test -COPY packages packages +FROM node:18-bullseye-slim -# 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 +# Install sqlite3 dependencies. You can skip this if you don't use sqlite3 in the image, +# in which case you should also move better-sqlite3 to "devDependencies" in package.json. 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' + apt-get install -y --no-install-recommends libsqlite3-dev python3 build-essential && \ + yarn config set python /usr/bin/python3 # 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`. +# 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"] +# Copy repo skeleton first, to avoid unnecessary docker cache invalidation. +# The skeleton contains the package.json of each package in the monorepo, +# and along with yarn.lock and the root package.json, that's enough to run yarn install. +COPY --chown=node:node yarn.lock package.json packages/backend/dist/skeleton.tar.gz ./ +RUN tar xzf skeleton.tar.gz && rm skeleton.tar.gz + +RUN --mount=type=cache,target=/home/node/.cache/yarn,sharing=locked,uid=1000,gid=1000 \ + yarn install --frozen-lockfile --production --network-timeout 300000 + +# Then copy the rest of the backend bundle, along with any other files we might want. +COPY --chown=node:node packages/backend/dist/bundle.tar.gz app-config*.yaml ./ +RUN tar xzf bundle.tar.gz && rm bundle.tar.gz + +CMD ["node", "packages/backend", "--config", "app-config.yaml", "--config", "app-config.production.yaml"] diff --git a/README.md b/README.md index 61707f6..8c7c437 100644 --- a/README.md +++ b/README.md @@ -1,116 +1,10 @@ -# EDP Backstage +# [Backstage](https://backstage.io) -The EDP bespoke version of backstage. +This is your newly scaffolded Backstage App, Good Luck! -With respect to the CNOE stack (where eDF originates from) it is comparable to https://github.com/cnoe-io/backstage-app +To start the app, run: -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 +```sh yarn install -yarn run start-backend -``` - -In the first terminal tab, run the frontend. - -```bash -yarn run start +yarn dev ``` diff --git a/app-config.production.yaml b/app-config.production.yaml index 8f0751c..df09dac 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/#adding-components-to-the-catalog for more details + # See https://backstage.io/docs/features/software-catalog/software-catalog-overview#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 0006a70..a61eb3e 100644 --- a/app-config.yaml +++ b/app-config.yaml @@ -1,13 +1,13 @@ app: - title: CNOE + title: Scaffolded Backstage App baseUrl: http://localhost:3000 organization: - name: CNOE + name: My Company backend: # Used for enabling authentication, secret is shared by all backend plugins - # See https://backstage.io/docs/auth/service-to-service-auth for + # See https://backstage.io/docs/tutorials/backend-to-backend-auth for # information on the format # auth: # keys: @@ -30,25 +30,30 @@ 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: - 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} + github: + - host: github.com + apps: + - $include: github-integration.yaml +# - 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} 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. - # endpoints: - # '/test': - # target: 'https://example.com' - # changeOrigin: true + # '/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 @@ -60,46 +65,39 @@ 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 # 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 + providers: {} 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 ] + - 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] + # Local example data, file locations are relative to the backend process, typically `packages/backend` + - type: file + target: ../../examples/entities.yaml + - type: file + target: /Users/mccloman/repos/backstage-templates/template1.yaml + - type: file + target: /Users/mccloman/repos/backstage-app/backstage/test-template.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 @@ -114,22 +112,4 @@ kubernetes: serviceLocatorMethod: type: 'multiTenant' 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 + - $include: k8s-config.yaml diff --git a/backstage.json b/backstage.json index c6aea75..bd61f69 100644 --- a/backstage.json +++ b/backstage.json @@ -1,3 +1,3 @@ { - "version": "1.38.1" + "version": "1.12.1" } diff --git a/catalog-info.yaml b/catalog-info.yaml index a968650..adbb41d 100644 --- a/catalog-info.yaml +++ b/catalog-info.yaml @@ -1,7 +1,7 @@ apiVersion: backstage.io/v1alpha1 kind: Component metadata: - name: backstage-idpbuilder + name: backstage description: An example of a Backstage application. # Example for optional annotations # annotations: diff --git a/cnoe-wrapper.sh b/cnoe-wrapper.sh deleted file mode 100644 index 4d5b490..0000000 --- a/cnoe-wrapper.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/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 deleted file mode 100644 index 624feac..0000000 --- a/examples/k8s-apply/skeleton/cm.yaml +++ /dev/null @@ -1,17 +0,0 @@ -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 deleted file mode 100644 index f88963d..0000000 --- a/examples/k8s-apply/template-manifest-object.yaml +++ /dev/null @@ -1,41 +0,0 @@ -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 deleted file mode 100644 index 312f557..0000000 --- a/examples/k8s-apply/template-manifest-string.yaml +++ /dev/null @@ -1,41 +0,0 @@ -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 deleted file mode 100644 index 3f097c3..0000000 --- a/examples/k8s-apply/template.yaml +++ /dev/null @@ -1,30 +0,0 @@ -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 new file mode 100644 index 0000000..d1b789a --- /dev/null +++ b/github-integration.yaml @@ -0,0 +1,9 @@ +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 new file mode 100644 index 0000000..91b3c97 --- /dev/null +++ b/k8s-config.yaml @@ -0,0 +1,16 @@ +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 529a62f..322929d 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "packages": ["packages/*", "plugins/*"], "npmClient": "yarn", - "version": "0.1.0", - "$schema": "node_modules/lerna/schemas/lerna-schema.json" + "useWorkspaces": true, + "version": "0.1.0" } diff --git a/package.json b/package.json index 7e09d0f..06ddb90 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "private": true, "engines": { - "node": "18 || 20" + "node": "16 || 18" }, "scripts": { "dev": "concurrently \"yarn start\" \"yarn start-backend\"", @@ -17,8 +17,6 @@ "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 .", @@ -31,19 +29,17 @@ ] }, "devDependencies": { - "@backstage/cli": "^0.32.0", - "@backstage/e2e-test-utils": "^0.1.1", - "@playwright/test": "^1.32.3", + "@backstage/cli": "^0.22.5", "@spotify/prettier-config": "^12.0.0", - "concurrently": "^8.0.0", - "lerna": "^7.3.0", + "concurrently": "^6.0.0", + "lerna": "^4.0.0", "node-gyp": "^9.0.0", "prettier": "^2.3.2", - "typescript": "~5.2.0" + "typescript": "~4.6.4" }, "resolutions": { - "@types/react": "^18", - "@types/react-dom": "^18" + "@types/react": "^17", + "@types/react-dom": "^17" }, "prettier": "@spotify/prettier-config", "lint-staged": { diff --git a/packages/app/.eslintignore b/packages/app/.eslintignore deleted file mode 100644 index a48cf0d..0000000 --- a/packages/app/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -public diff --git a/packages/app/cypress.json b/packages/app/cypress.json new file mode 100644 index 0000000..0cb845a --- /dev/null +++ b/packages/app/cypress.json @@ -0,0 +1,6 @@ +{ + "baseUrl": "http://localhost:3001", + "fixturesFolder": false, + "pluginsFile": false, + "retries": 3 +} diff --git a/packages/app/cypress/.eslintrc.json b/packages/app/cypress/.eslintrc.json new file mode 100644 index 0000000..a467608 --- /dev/null +++ b/packages/app/cypress/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "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 new file mode 100644 index 0000000..43fb2e3 --- /dev/null +++ b/packages/app/cypress/integration/app.js @@ -0,0 +1,6 @@ +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 deleted file mode 100644 index d45bc0d..0000000 --- a/packages/app/e2e-tests/app.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 aba7302..b6b7764 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -11,55 +11,59 @@ "build": "backstage-cli package build", "clean": "backstage-cli package clean", "test": "backstage-cli package test", - "lint": "backstage-cli package lint" + "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" }, "dependencies": { - "@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", + "@backstage/app-defaults": "^1.2.1", + "@backstage/catalog-model": "^1.2.1", + "@backstage/cli": "^0.22.5", + "@backstage/core-app-api": "^1.6.0", + "@backstage/core-components": "^0.12.5", + "@backstage/core-plugin-api": "^1.5.0", + "@backstage/integration-react": "^1.1.11", + "@backstage/plugin-api-docs": "^0.9.1", + "@backstage/plugin-catalog": "^1.9.0", + "@backstage/plugin-catalog-common": "^1.0.12", + "@backstage/plugin-catalog-graph": "^0.2.28", + "@backstage/plugin-catalog-import": "^0.9.6", + "@backstage/plugin-catalog-react": "^1.4.0", + "@backstage/plugin-github-actions": "^0.5.16", + "@backstage/plugin-kubernetes": "^0.7.9", + "@backstage/plugin-org": "^0.6.6", + "@backstage/plugin-permission-react": "^0.4.11", + "@backstage/plugin-scaffolder": "^1.12.0", + "@backstage/plugin-search": "^1.1.1", + "@backstage/plugin-search-react": "^1.5.1", + "@backstage/plugin-tech-radar": "^0.6.2", + "@backstage/plugin-techdocs": "^1.6.0", + "@backstage/plugin-techdocs-module-addons-contrib": "^1.0.11", + "@backstage/plugin-techdocs-react": "^1.1.4", + "@backstage/plugin-user-settings": "^0.7.1", + "@backstage/theme": "^0.2.18", + "@internal/plugin-workflows": "^0.1.0", "@material-ui/core": "^4.12.2", "@material-ui/icons": "^4.9.1", - "@roadiehq/backstage-plugin-argo-cd": "^2.5.1", "history": "^5.0.0", - "react": "^18.0.2", - "react-dom": "^18.0.2", - "react-router": "^6.3.0", + "react": "^17.0.2", + "react-dom": "^17.0.2", "react-router-dom": "^6.3.0", "react-use": "^17.2.4" }, "devDependencies": { - "@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", + "@backstage/test-utils": "^1.2.6", + "@testing-library/jest-dom": "^5.10.1", + "@testing-library/react": "^12.1.3", "@testing-library/user-event": "^14.0.0", + "@types/node": "^16.11.26", "@types/react-dom": "*", - "cross-env": "^7.0.0" + "cross-env": "^7.0.0", + "cypress": "^9.7.0", + "eslint-plugin-cypress": "^2.10.3", + "start-server-and-test": "^1.10.11" }, "browserslist": { "production": [ diff --git a/packages/app/public/index.html b/packages/app/public/index.html index fc758ee..c6083b3 100644 --- a/packages/app/public/index.html +++ b/packages/app/public/index.html @@ -8,6 +8,7 @@ name="description" content="Backstage is an open platform for building developer portals" /> +