Array
Array is a data type used to save lists of data.
Common usage
Use array properties to store multiple values for an entity, such as:
- Programming languages used in a repository.
- Container image tags available for a service.
- Monitoring tools configured for a service.
- Links to runbooks and dashboards.
Use relations when these values represent other entities in your catalog.
Multi source ingestion
By default, array properties use last-writer-wins behavior: each update replaces the full array.
Enable Multi source ingestion to let multiple data sources or API callers contribute to the same list without overwriting each other. This works for string and number item types only.
In the Data model or software catalog, turn on Multi source ingestion when creating the property.
In the API, set "union": true. This setting cannot be changed after creation.
Example
The service blueprint has multi source ingestion enabled on its vulnerabilities property. For a payments-api entity:
- Monday - the Snyk integration writes
{ "snyk": ["CVE-101", "CVE-102"] }. - Tuesday - Dependabot writes
{ "dependabot": ["CVE-102", "CVE-203"] }without removing Snyk's findings. - Wednesday - Alice edits the entity in the UI and adds
CVE-300. Port saves her changes underuser:alice.
A GET returns the merged, deduplicated array:
{ "vulnerabilities": ["CVE-101", "CVE-102", "CVE-203", "CVE-300"] }
Each writer only updates its own source key. CVE-102 appears once even though both scanners reported it.
Write and read values
Write (POST, PATCH, PUT) - send one source key per update:
{
"properties": {
"vulnerabilities": {
"scanner-a": ["CVE-2024-1", "CVE-2024-2"]
}
}
}
Use null instead of an array to clear a source's slice.
Source keys must match ^[A-Za-z0-9._:@/-]{1,128}$.
Read (GET, search) - Port returns the merged, deduplicated array:
{ "vulnerabilities": ["CVE-2024-1", "CVE-2024-2", "CVE-2024-3"] }
In the UI, you edit the assembled array directly. Port stores UI edits under user:{userId} automatically.
Calculation and aggregation properties read the assembled value.
Multi source ingestion works the same way for relations and owning teams: each writer owns a source key, and reads return the deduplicated combination of all sources.
Constraints
items.typemust bestringornumber.minItemsandmaxItemsare not supported withunion.- You cannot toggle
unionafter creation. Create a new property and migrate the data instead. - Sending a plain array, multiple source keys, or an invalid source key returns
422.
API definition
{
"myArrayProp": {
"title": "My array",
"icon": "My icon",
"description": "My array property",
"type": "array",
"default": [1, 2, 3]
}
}
Check out Port's API reference to learn more.
Terraform definition
The examples below use version 2.29.0 of the Terraform and Pulumi providers. Configure your provider first, then run one example at a time in its own project. Each example creates a blueprint; use distinct identifiers when you combine examples.
resource "port_blueprint" "myBlueprint" {
identifier = "myBlueprint"
title = "My blueprint"
properties = {
array_props = {
"myArrayProp" = {
title = "My array"
required = true
string_items = {}
}
}
}
}
To set the type of an array property, you need to use the <type>_items property type.
For example, to set an array of strings, you need to use the string_items property type.
resource "port_blueprint" "myBlueprint" {
identifier = "myBlueprint"
title = "My blueprint"
properties = {
array_props = {
"myArrayProp" = {
title = "My array"
required = true
string_items = {} # You can also set here default values
}
}
}
}
We currently support the following types of array items: string_items, number_items, boolean_items, object_items.
Pulumi definition
- Python
- TypeScript
- JavaScript
- Go
"""A Python Pulumi program"""
import pulumi
from port_pulumi import Blueprint,BlueprintPropertiesArgs,BlueprintPropertiesArrayPropsArgs
blueprint = Blueprint(
"myBlueprint",
identifier="myBlueprint",
title="My Blueprint",
properties=BlueprintPropertiesArgs(
array_props={
"myArrayProp": BlueprintPropertiesArrayPropsArgs(
title="My array", required=True, string_items={},
)
}
),
relations={}
)
import * as pulumi from "@pulumi/pulumi";
import * as port from "@port-labs/port";
export const blueprint = new port.Blueprint("myBlueprint", {
identifier: "myBlueprint",
title: "My Blueprint",
properties: {
arrayProps: {
myArrayProp: {
title: "My array",
required: true,
stringItems: {},
},
},
},
});
"use strict";
const pulumi = require("@pulumi/pulumi");
const port = require("@port-labs/port");
const entity = new port.Blueprint("myBlueprint", {
title: "My Blueprint",
identifier: "myBlueprint",
properties: {
arrayProps: {
myArrayProp: {
title: "My array",
required: true,
stringItems: {},
},
},
},
relations: {},
});
exports.title = entity.title;
package main
import (
"github.com/port-labs/pulumi-port/sdk/v2/go/port"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
blueprint, err := port.NewBlueprint(ctx, "myBlueprint", &port.BlueprintArgs{
Identifier: pulumi.String("myBlueprint"),
Title: pulumi.String("My Blueprint"),
Properties: port.BlueprintPropertiesArgs{
ArrayProps: port.BlueprintPropertiesArrayPropsMap{
"myArrayProp": port.BlueprintPropertiesArrayPropsArgs{
Title: pulumi.String("My array"),
Required: pulumi.Bool(true),
StringItems: port.BlueprintPropertiesArrayPropsStringItemsArgs{},
},
},
},
})
if err != nil {
return err
}
ctx.Export("blueprint", blueprint.Title)
return nil
})
}
Validate array
Array validations support the following operators:
minItemsmaxItemsuniqueItems
minItems and maxItems are not supported on array properties with multi source ingestion enabled.
Array validations follow the JSON schema model, refer to the JSON schema docs to learn about all of the available validations
- Basic
- Terraform
{
"myArrayProp": {
"title": "My array",
"icon": "My icon",
"description": "My array property",
"type": "array",
"minItems": 0,
"maxItems": 5,
"uniqueItems": false
}
}
resource "port_blueprint" "myBlueprint" {
identifier = "myBlueprint"
title = "My blueprint"
properties = {
array_props = {
"myArrayProp" = {
title = "My array"
required = true
string_items = {}
min_items = 0
max_items = 5
}
}
}
}