Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return spec in backstage_entities data source #138

Merged
merged 9 commits into from
Aug 11, 2024
Merged

Return spec in backstage_entities data source #138

merged 9 commits into from
Aug 11, 2024

Conversation

tdabasinskas
Copy link
Owner

@tdabasinskas tdabasinskas commented Aug 2, 2024

The PR adds support for spec attribute for entities returned by backstage_entities data source and fixes #101.

It might not be ideal as it is returned as JSON string instead of a proper object. I wasn't able to achieve this with dynamic types so that's the reason I chose JSON. jsondecode function can be used to decode the object and get the specific values.

Usage example:

terraform {
  required_providers {
    backstage = {
      source = "tdabasinskas/backstage"
      version = "2.4.0-rc1"
    }
  }
}

provider "backstage" {
  base_url = "https://demo.backstage.io"
}

data "backstage_entities" "example" {
  filters = []
}

output "example" {
  value = jsondecode(data.backstage_entities.example.entities[0].spec)["profile"]["email"]
}

Copy link

codecov bot commented Aug 2, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 6 lines in your changes missing coverage. Please review.

Project coverage is 76.55%. Comparing base (64f54d2) to head (aa4803c).

Files Patch % Lines
backstage/data_source_entities.go 33.33% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #138      +/-   ##
==========================================
- Coverage   76.83%   76.55%   -0.28%     
==========================================
  Files          11       11              
  Lines        1390     1399       +9     
==========================================
+ Hits         1068     1071       +3     
- Misses        237      242       +5     
- Partials       85       86       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tdabasinskas tdabasinskas merged commit 6f77edc into main Aug 11, 2024
8 of 10 checks passed
@tdabasinskas tdabasinskas deleted the add_spec branch August 11, 2024 13:56
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.

return spec field for entities retrieved using backstage_entities data source
1 participant