Skip to content

Allow for more info to be retrued on catalog entities data source - #101

Merged
mmaikel merged 3 commits into
cortexapps:mainfrom
TomWKraken:allow-info-request-catalog-entities
Jun 29, 2026
Merged

Allow for more info to be retrued on catalog entities data source#101
mmaikel merged 3 commits into
cortexapps:mainfrom
TomWKraken:allow-info-request-catalog-entities

Conversation

@TomWKraken

Copy link
Copy Markdown
Contributor

Before this change, in order to use a catalog entities ownerhsip and Git information, a follow up call per entity was required. This change allows us to retrieve that information from the single paginated "Entities" data source.

The Git information was returned by default any way by the API call, so this change just surfaces that information.

The owners info was not previously retrieved and requires adding a param to the API call so this has been added as a toggle to the data source.

The following test code was used in order to verify the behaviour:

# Get all catalog entities
data "cortex_catalog_entities" "all_entities" {
  types          = ["service"]
  include_owners = true
}

locals {
  service_entity_tags = [
    for entity in data.cortex_catalog_entities.all_entities.entities :
    entity.tag if !strcontains(entity.tag, "//")
  ]

  _service_owner = {
    for entity in data.cortex_catalog_entities.all_entities.entities :
    entity.tag => try(entity.ownership.groups[0].group_name, null)
  }

  # service tag => owning team name (services without an owner are excluded)
  service_entity_owners = { for tag, team in local._service_owner : tag => team if team != null }

  # team name => list of service tags it owns
  team_to_services = { for tag, team in local.service_entity_owners : team => tag... }

  service_to_github = {
    for entity in data.cortex_catalog_entities.all_entities.entities :
    entity.tag => try(entity.git.repository, null)
  }
}

output "ownership_mapping" {
  value = local.service_entity_owners
}

# Output a single service object to see the structure of the data
output "service_object" {
  value = data.cortex_catalog_entities.all_entities.entities[0]
}

@TomWKraken
TomWKraken force-pushed the allow-info-request-catalog-entities branch from cb47623 to 3a00b92 Compare June 18, 2026 13:29
@mmaikel
mmaikel self-requested a review June 23, 2026 14:48

@mmaikel mmaikel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks solid to me.

I'd just suggest adding some test coverage on the provider mapping layer (internal/provider/) because the Read() flattening that builds ownership.groups[] from owners.teams[] is actually the new logic here. Not a big deal, though. Apart from that, a question about the individual owners being ignored.

Comment thread internal/cortex/catalog_entities_test.go
Comment thread docs/data-sources/catalog_entities.md
@mmaikel
mmaikel self-requested a review June 29, 2026 16:15

@mmaikel mmaikel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mmaikel
mmaikel merged commit d6fd4e7 into cortexapps:main Jun 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants