Skip to content

Commit d13af48

Browse files
authored
Merge branch 'main' into promote-scorecards/examples#benchmarking-owasp-top-10-for-code
2 parents 6018d97 + b7651e2 commit d13af48

File tree

4 files changed

+158
-16
lines changed

4 files changed

+158
-16
lines changed

docs/actions-and-automations/setup-backend/create-update-entity/create-update-entity.md

Lines changed: 108 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import Tabs from "@theme/Tabs"
2+
import TabItem from "@theme/TabItem"
3+
14
# Create/update entity
25

36
In some cases, we don't want to run complex logic via a workflow or pipeline, but rather want our backend to simply create or update an entity in our software catalog.
@@ -33,15 +36,15 @@ To use this backend type, you will need to define the following fields:
3336
| `team` | The team/s this entity will belong to. |
3437
| `icon` | The icon of the entity. |
3538
| `properties` | The properties of the entity, in `"key":"value"` pairs where the key is the property's identifier, and the value is its value. |
36-
| `relations` | The relations of the entity, in `"key":"value"` pairs where the key is the relation's identifier, and the value is the related entity's identifier. |
39+
| `relations` | The relations of the entity, in `"key":"value"` pairs where the key is the relation's identifier, and the value is the related entity's identifier (for single relations) or an array of identifiers (for "many" relations). |
3740

3841
### Use jq to map the entity
3942

4043
All fields in the `mapping` object can be mapped using `jq` expressions, by wrapping the value in double curly braces `{{ }}`.
4144

4245
For example, say we want to assign the initiator of the action to a new entity when it is created, we can take his email from the action run object and assign it to a property named `assignee`:
4346

44-
```json
47+
```json showLineNumbers
4548
{
4649
"identifier": "someTaskEntity",
4750
"title": "Some Task",
@@ -55,3 +58,106 @@ For example, say we want to assign the initiator of the action to a new entity w
5558
:::tip Test your mapping
5659
You can use the `Test JQ` button in the bottom-left corner to test your mapping against the action's schema.
5760
:::
61+
62+
## Map entity relations
63+
64+
When creating or updating entities, you often need to establish relations with other entities. The mapping approach depends on whether you're dealing with single or multiple entity inputs.
65+
66+
67+
<Tabs groupId="relation-mapping" defaultValue="single" values={[
68+
{label: "Single Entity", value: "single"},
69+
{label: "Array Entity", value: "array"},
70+
{label: "Flexible Mapping", value: "flexible"}
71+
]}>
72+
73+
<TabItem value="single">
74+
75+
For a single entity relation, map the entity identifier directly:
76+
77+
```json showLineNumbers
78+
{
79+
"identifier": "myServiceEntity",
80+
"title": "My Service",
81+
"properties": {},
82+
"relations": {
83+
"domain": "{{ .inputs.domain }}"
84+
}
85+
}
86+
```
87+
88+
</TabItem>
89+
90+
<TabItem value="array">
91+
92+
When your action accepts [array entity inputs](/docs/actions-and-automations/create-self-service-experiences/setup-ui-for-action/user-inputs/entity.md#array), you need to extract the identifiers from the array using the `map(.identifier)` pattern:
93+
94+
```json showLineNumbers
95+
{
96+
"identifier": "myUserEntity",
97+
"title": "My User",
98+
"properties": {},
99+
"relations": {
100+
"skills": "{{ .inputs.skills | map(.identifier) }}"
101+
}
102+
}
103+
```
104+
105+
:::info Array entity inputs
106+
When users select multiple entities from an [entity array input](/docs/actions-and-automations/create-self-service-experiences/setup-ui-for-action/user-inputs/entity.md#array), the input contains an array of entity objects. Each object includes both `identifier` and `title` properties, but relations can only reference entity identifiers.
107+
:::
108+
109+
</TabItem>
110+
111+
<TabItem value="flexible">
112+
113+
For maximum flexibility, you can create a conditional mapping that handles both single entity and array entity inputs:
114+
115+
```json showLineNumbers
116+
{
117+
"identifier": "myProjectEntity",
118+
"title": "My Project",
119+
"properties": {},
120+
"relations": {
121+
"dependencies": "{{ .inputs.dependencies | if type == \"array\" then map(.identifier) else .identifier end }}"
122+
}
123+
}
124+
```
125+
126+
This pattern automatically:
127+
- Extracts identifiers from arrays when multiple entities are selected
128+
- Uses the identifier directly when a single entity is selected
129+
130+
</TabItem>
131+
132+
</Tabs>
133+
134+
135+
### Common use cases
136+
137+
Here are some typical scenarios for mapping array relations:
138+
139+
**Mapping skills to a user:**
140+
```json showLineNumbers
141+
"relations": {
142+
"skills": "{{ .inputs.selectedSkills | map(.identifier) }}"
143+
}
144+
```
145+
146+
**Mapping team members to a project:**
147+
```json showLineNumbers
148+
"relations": {
149+
"members": "{{ .inputs.teamMembers | map(.identifier) }}"
150+
}
151+
```
152+
153+
**Mapping dependencies between services:**
154+
```json showLineNumbers
155+
"relations": {
156+
"dependsOn": "{{ .inputs.dependencies | map(.identifier) }}"
157+
}
158+
```
159+
160+
161+
:::info Entity titles in relations
162+
Relations can only reference entity **identifiers**, not titles. Even though entity objects contain both `identifier` and `title` properties, you must always use `.identifier` when mapping to relations.
163+
:::

docs/api-reference/pages.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
Port API's `pages` endpoints will undergo a structural change in the near future. The new structure will be more intuitive and easier to use.
88

9+
Until the new structure is released, you can refer to the [Swagger API documentation](https://api.port.io/swagger/#Pages) for the available endpoints and their usage.
10+
911
Currently, the `pages` endpoints allow you to:
1012

1113
- **Create**, **update**, **delete**, and **get** pages.

docs/build-your-software-catalog/sync-data-to-catalog/git/azure-devops/mapping_extensions.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,38 @@ To do so, we will use the `file://` prefix with the path of the file to tell the
4545
url: .remoteUrl
4646
// highlight-next-line
4747
readme: file://README.md
48-
```
48+
```
49+
50+
## Link pipelines to repositories via selector
51+
You can configure your selector to include repository information in the pipeline entity mapping.
52+
This allows you to create a direct relationship between a pipeline and its source repository.
53+
54+
```yaml showLineNumbers
55+
- kind: pipeline
56+
selector:
57+
query: 'true'
58+
# highlight-next-line
59+
includeRepo: 'true'
60+
port:
61+
entity:
62+
mappings:
63+
identifier: .id | tostring
64+
title: .name
65+
blueprint: '"azureDevOpsPipeline"'
66+
properties:
67+
url: .url
68+
revision: .revision
69+
folder: .folder
70+
relations:
71+
project: .__projectId | gsub(" "; "")
72+
repository: >-
73+
if .__repository
74+
then .__repository.project.name + "/" + .__repository.name | gsub(" "; "")
75+
else null
76+
end
77+
```
78+
:::tip Recommendation
79+
Use this only when necessary, as including repository data requires an extra API call per pipeline, which increases the number of requests made and can impact your Azure DevOps API rate limits.
80+
81+
If you don’t require repo-level linkage, it’s more efficient to relate pipelines → projects instead.
82+
:::

docs/guides/all/visualize-service-k8s-runtime.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,32 +106,32 @@ We achieved this by adding a [mapping definition](https://github.com/port-labs/t
106106
apiVersion: apps/v1
107107
kind: Deployment
108108
metadata:
109-
name: awesomeapp
110-
labels:
109+
name: awesomeapp
110+
labels:
111111
app: nginx
112112
portWorkload: AwesomeWorkload
113113
spec:
114-
replicas: 2
115-
selector:
114+
replicas: 2
115+
selector:
116116
matchLabels:
117-
app: nginx
118-
template:
117+
app: nginx
118+
template:
119119
metadata:
120-
labels:
120+
labels:
121121
app: nginx
122122
spec:
123-
containers:
123+
containers:
124124
- name: nginx
125125
image: nginx:1.14.2
126126
resources:
127-
limits:
127+
limits:
128128
cpu: "200m"
129129
memory: "256Mi"
130-
requests:
131-
cpu: "100m"
132-
memory: "128Mi"
130+
requests:
131+
cpu: "100m"
132+
memory: "128Mi"
133133
ports:
134-
- containerPort: 80
134+
- containerPort: 80
135135
```
136136

137137
</details>

0 commit comments

Comments
 (0)