text
stringlengths
0
662
region: us-east-1
```
```yaml
apiVersion: opencontext.com/v1alpha1
kind: Datacenter
metadata:
name: dc1
title: Datacenter 1
description: Datacenter 1
annotations:
pagerduty.com/service-id: 'TEST8XW'
spec:
type: other
otherType: dc1
owner: [it-team]
region: us-east
```
```yaml
apiVersion: opencontext.com/v1alpha1
kind: Datacenter
metadata:
name: gcp
title: GCP
description: Google Cloud Platform
annotations:
pagerduty.com/integration-key: 'e0efde5a1somethingorother'
spec:
type: cloud
owner: [cloud-team]
region: us-central1-c
```
```yaml
apiVersion: opencontext.com/v1alpha1
kind: Datacenter
metadata:
name: vendor
title: Vendor 1
description: Vendor 1's Datacenter
spec:
type: other
otherType: vendor
owner: [it-team]
region: us-east
```
---
sidebar_position: 3
---
# Entity Reference
Entities commonly have a need to reference other entities. For example, a聽CodeComponent聽entity may want to declare who its owner is by mentioning a Team or Person entity, and a Person entity may want to declare what Team entities it is a member of. This describes how to write those references in your yaml entity declaration files.
Each entity in OpenContext is uniquely identified by the triplet of its聽[kind,聽namespace, and聽name](common). But that's a lot to type out manually, and in a lot of circumstances, both the kind and the namespace are fixed, or possible to deduce, or could have sane default values.
Each reference can be expressed in one of two ways: as a compact string, or as a compound reference structure.
## **String References**
This is the most common alternative, that should be used in almost all circumstances.
The string is on the form聽`[<kind>:][<namespace>/]<name>`, that is, it is composed of between one and three parts in this specific order, without any additional encoding:
- Optionally, the kind, followed by a colon
- Optionally, the namespace, followed by a forward slash. This is only required when the namespace is not `default`
- The name
The name is always required. Depending on the context, you may be able to leave out the kind and/or namespace. If you do, it is contextual what values will be used, and the relevant documentation should specify which rule applies where. All strings are case insensitive.
```yaml
apiVersion: opencontext.com/v1alpha1
kind: AuxComponent
metadata:
name: crates-docs
title: Crates docs
description: Crates documentation
tags:
- java
spec:
type: document
lifecycle: production
owner: [person:sean]
service: crates
uri: https://example.com/docs
```
The field聽`spec.owner`聽is a reference. In this case, the string聽`person:sean`聽was given by the user. That means that the kind is聽`Person`, the namespace is left out, and the name is聽`sean`. In this context, the namespace was chosen to fall back to the value聽`default`聽by the code that parsed the reference, so the end result is that we expect to find another entity in the catalog that is of kind聽`Person`, namespace聽`default`聽(which, actually, also can be left out in its own yaml file because that's the default value there too), and name聽`sean`.
The entry in聽`spec.service` is also a reference. In this case, it doesn鈥檛 need to specify a kind since we know from the context that that's the only kind that's supported here. If namespace was to be specified then the value would change to `default/crates`.
## **Compound References**
This is a more verbose version of a reference, where each part of the kind-namespace-name triplet is expressed as a field in a structure. This format can be used where necessary, such as if either of the three elements contains colons or forward slashes. Avoid using it where possible, since it is harder to read and write for humans.
```yaml
apiVersion: opencontext.com/v1alpha1
kind: Service
metadata: