immobiliare / backstage-plugin-gitlab

Backstage plugins to interact with GitLab
Apache License 2.0
116 stars 41 forks source link

GitlabFillerProcessorModule assumes that entities originating from gitlab repo are hosted in the same repo #625

Open chicobento opened 1 month ago

chicobento commented 1 month ago

Background

We have the following case: all backstage entity definitions are hosted in a gitlab monorepo, but the actual source code for the entities is hosted in another repo, or even another src code hosting tool. The entities are registered via a all.yaml in the monorepo. The GitlabFillerProcessorModule is adding the gitlab.com annotations assuming that the source code is hosted in the same repo, resulting in erroneous display of assets, i.e: the EntityGitlabReadmeCard is displaying the readme.md of the gitlab monorepo in the entity page, rather than the target source code repo.

Reproducing

Given that the following YAMLs are hosted in https://gitlab.acme.com/software-catalog: all.yaml

apiVersion: backstage.io/v1beta1
kind: Location
metadata:
  name: software-catalog-entities
  title: Software Catalog Entities
spec:
  targets:
  - ./my-entity.yaml

my-entity.yaml

apiVersion: backstage.io/v1beta1
kind: Component
metadata:
  name: my-entity
  title: my entity
  backstage.io/source-location: url:https://gitlab.acme.com/my-namespace/my-entity/-/blob/main/
spec:
  type: 
  owner: team

When https://gitlab.acme.com/software-catalog/all.yaml is registered in backstage Then I expect to see in my-entity page the Readme.md from https://gitlab.acme.com/my-namespace/my-entity/-/blob/main/

Suggested fix

The gitlabInstanceConfig inference should be changed to consider the backstage.io/source-location as the ultimate information to the actual hosting of the source code for the entity.

See: https://github.com/immobiliare/backstage-plugin-gitlab/blob/829e522cfef1281b1f98b6f5363f2f357056cce0/packages/gitlab-backend/src/processor/processor.ts#L50-L53

github-actions[bot] commented 14 hours ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.