For mature, established git repositories, getting port.yml changes to main can be a challenge. There needs to be a way for developers to preview their port.yml changes in the Port.io Non-Prod organization by having it look for port.yml changes in a lower branch such as feature/port-gitops. This allows them to preview changes without going through a PR process.
I currently have this working with GitHub Ocean (ADO currently does not support branches in the same way). But there are quirks to the process.
  • Requires separate mappings for dev and prod (more tooling with Pulumi)
  • Dev mappings require defining the mappings for the default branch first, followed by the override mappings with a configured and maintained list of repos and the feature/port-gitops.
  • The duality causes the main branch changes to update and then the preview branch to update again. Next sync the same cycle happens over and over again. Instead, if the lower branch exists, it should ignore main.
  • I cannot just set the global branch in the dev org because that requires persisted branches in repos which will not fly.
  • kind: file
port:
entity:
mappings:
blueprint: '"environment"'
icon: if .this.icon then .this.icon else "Environment" end
identifier: .this.identifier
properties:
description: .this.properties.description
platform_id: .this.properties.platform_id
relations: {}
team: if .this.team then .this.team else [] end
title: .this.title
itemsToParse: .content | if type == "array" then . else [.] end | map(select(.blueprint == "environment"))
itemsToParseName: this
selector:
files:
- path: port.yml
query: 'true'
Followed by a copy with this added.
selector:
files:
- path: port.yml
repos:
- branch: feature/port-gitops
name: poc-port-ocean
- branch: feature/port-gitops
name: platform-identity