Relations
About 287 words
The catalog module emits these relations for every kind: Tailscale entity, each with its reverse on the other entity.
| From the Tailscale entity | To | Reverse | Comes from | Default kind of the target |
|---|---|---|---|---|
ownedBy | its owner | ownerOf | spec.owner | Group |
partOf | its system | hasPart | spec.system | System |
partOfPolicy | its policy | hasPolicyPart | spec.target | Tailscale |
appliesTo | each entity it's about | tailscaleAppliedBy | spec.appliesTo | Component |
ownedBy, ownerOf, partOf and hasPart are Backstage's own relation types. partOfPolicy, hasPolicyPart, appliesTo and tailscaleAppliedBy are the plugin's. Target references without a namespace take the Tailscale entity's namespace.
The policy entity has no spec.target, so it gets no partOfPolicy; it gets a hasPolicyPart from each of its parts.
What reads them
The backend doesn't use partOfPolicy to find a policy's parts; it reads spec.target directly. It uses tailscaleAppliedBy on a catalog entity to list, in the entity's Tailscale card, the Tailscale entities that name it in appliesTo.
For catalog grants and group members, the backend reads Backstage's own relations:
| Relation | On | Used for |
|---|---|---|
hasMember | Group | the members of a tailnet group |
memberOf | User | a User's groups, on the User's Tailscale card |
consumesApi | Component | which APIs a Component consumes |
apiProvidedBy | API | which Components provide an API |
providesApi | Component | the Services and tags a Component is reached as, on its Tailscale card |
dependsOn | Component | which kubernetes-cluster Resources a Component runs in |
In code
@spechtlabs/backstage-plugin-tailscale-common exports the relation names (RELATION_PART_OF_POLICY, RELATION_HAS_POLICY_PART, RELATION_APPLIES_TO, RELATION_APPLIED_BY) and tailscaleRelations(entity), which returns the relations above for one entity. Tooling that reads entities from files, such as backstage-tailscale-diff, uses it to add the relations the catalog would.
