terraform-provider-boundary icon indicating copy to clipboard operation
terraform-provider-boundary copied to clipboard

chore: Generate datasources based on OpenAPI specification

Open moduli opened this issue 1 year ago • 0 comments

NOTE: WIP

This PR is a continuation of the work started here: https://github.com/hashicorp/terraform-provider-boundary/pull/127

A new make target (make data-sources) was added to automatically generate data sources for the terraform provider. This target was also added to make gen to ensure that the desired changes are present.

Data sources are generated by processing Boundary's OpenAPI spec (it determines the version of the spec based on the boundary version specified in this repo's go.mod file).

Usage

# This generates data-sources files 
# This also generates examples that can be used when performing `make docs`
# Note: tests are created independently of this script
# Note: you have to manually update `provider.go` to include the new data sources
make data-sources

...

To Do

  • [x] Rebase original PR and address issues
  • [x] Automatically generate for all resources
  • [x] Add to make gen delta
  • [x] Review and fix tests added from original PR
  • [ ] Check if lookup id field should not be set to "Optional"
  • [x] Add tests for new data sources that were created
  • [x] Generate examples for use in docs
  • [ ] Do some data sources not make sense? auth tokens, sessions. should we skip creating those?
  • [ ] Manual testing

Maybe scope out the singular variant for now?

  • [ ] Figure out if we also want to include "singular" variants (i.e. data "boundary_auth_method" v.s. data "boundary_auth_methods")
    • [ ] resolve issues in the current "singular" template
    • [ ] fix logic: aliases, credential_libraries, policies - singular doesn’t make sense if you just remove s

moduli avatar May 09 '24 18:05 moduli