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

New Data source data.boundary_user #468

Merged
merged 19 commits into from
Oct 17, 2023
Merged

Conversation

drewmullen
Copy link
Contributor

@drewmullen drewmullen commented Oct 2, 2023

closes: #464

Tests

I wrote tests that search for the global user and an org user (created by boundary_user). Important note: this new data source test will rely on the global admin being created with the same values as is currently used in test scaffolding. If you update the login_name or anything, these tests will fail as they're predicated on the current values.

$ make testacc TESTARGS='-run=TestAccUserDataSource_'

TF_ACC=1 go test ./... -v -run=TestAccUserDataSource_ -timeout 120m
?       github.com/hashicorp/terraform-provider-boundary        [no test files]
?       github.com/hashicorp/terraform-provider-boundary/plugins/kms    [no test files]
=== RUN   TestAccUserDataSource_basicOrgUser
--- PASS: TestAccUserDataSource_basicOrgUser (5.39s)
=== RUN   TestAccUserDataSource_globalAdminUser
--- PASS: TestAccUserDataSource_globalAdminUser (4.60s)
PASS
ok      github.com/hashicorp/terraform-provider-boundary/internal/provider      10.672s

Notes

  • login_name, scope, authorized_actions, and parent_account_id can be added to the resource boundary_user schema but I figured that should be a separate PR.
  • I included some .vscode files that are quite useful for debugging in vscode. I have a blog write-up here. These were incorporated into the aws provider developer docs. I can rip this out if you don't want it in the repo

@drewmullen drewmullen changed the title [Help Needed] New Data source data.boundary_user [WIP] New Data source data.boundary_user Oct 2, 2023
@drewmullen drewmullen changed the title [WIP] New Data source data.boundary_user New Data source data.boundary_user Oct 3, 2023
Copy link
Contributor

@louisruch louisruch left a comment

Choose a reason for hiding this comment

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

Going to continue looking after some of the Hashiconf events, but figured I could give the two immediate comments I noticed so long

.vscode/launch.json Show resolved Hide resolved
internal/provider/provider.go Outdated Show resolved Hide resolved
internal/provider/data_source_user.go Outdated Show resolved Hide resolved
internal/provider/data_source_user.go Outdated Show resolved Hide resolved
internal/provider/data_source_user.go Show resolved Hide resolved
@drewmullen
Copy link
Contributor Author

drewmullen commented Oct 11, 2023

I believe all requested changes have been resolved:

@louisruch @elimt

$ make testacc TESTARGS='-run=TestAccUserDataSource_'
TF_ACC=1 go test ./... -v -run=TestAccUserDataSource_ -timeout 120m
?       github.com/hashicorp/terraform-provider-boundary        [no test files]
?       github.com/hashicorp/terraform-provider-boundary/plugins/kms    [no test files]
=== RUN   TestAccUserDataSource_basicOrgUser
--- PASS: TestAccUserDataSource_basicOrgUser (5.65s)
=== RUN   TestAccUserDataSource_globalAdminUser
--- PASS: TestAccUserDataSource_globalAdminUser (4.56s)
PASS
ok      github.com/hashicorp/terraform-provider-boundary/internal/provider      13.480s

Please note - I had to write a template for the scope data source to prevent doc gen from clobbering the examples in the md

Copy link
Contributor

@louisruch louisruch left a comment

Choose a reason for hiding this comment

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

This is looking really good thanks for jumping onto this!

.gitignore Outdated Show resolved Hide resolved
internal/provider/data_source_user.go Outdated Show resolved Hide resolved
@louisruch
Copy link
Contributor

Oh sorry @drewmullen I think my comment might have been confusing. When I said lets remove .vscode for now, I meant lets remove the .vscode in the .gitignore file and therefore keep the setting and bring your debug config in as well

@drewmullen
Copy link
Contributor Author

OH LOL ok, sure. On a flight back from hashiconf today but I'll send those up this weekend

@drewmullen
Copy link
Contributor Author

I re-added the .vscode dir and updated the docs to include info on doc generation and using the, now baked in, debugger @louisruch

@louisruch
Copy link
Contributor

louisruch commented Oct 16, 2023

@drewmullen looks look gen-delta is failing. To fix it I believe you need to run make gen and push those changes, go.mod also has a minor diff so maybe go mod tidy as well.

@louisruch
Copy link
Contributor

@drewmullen looks like you still need to run make gen it seems there is an extra space.

@drewmullen
Copy link
Contributor Author

I did run it but it looks like it quietly fails:

make gen
go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
rendering website for provider "terraform-provider-boundary" (as "terraform-provider-boundary")
copying any existing content to tmp dir
exporting schema from Terraform
compiling provider "boundary"
using Terraform CLI binary from PATH if available, otherwise downloading latest Terraform CLI binary
running terraform init
getting provider schema
rendering missing docs
generating missing resource content
generating template for "boundary_storage_bucket"
generating template for "boundary_user"
generating template for "boundary_auth_method_oidc"
resource "boundary_scope" template exists, skipping
generating template for "boundary_credential_store_vault"
generating template for "boundary_managed_group"
generating template for "boundary_host_catalog_static"
generating template for "boundary_host_set"
generating template for "boundary_host_set_plugin"
resource "boundary_role" template exists, skipping
generating template for "boundary_account_password"
generating template for "boundary_credential_username_password"
generating template for "boundary_credential_store_static"
generating template for "boundary_host_catalog"
generating template for "boundary_account_ldap"
generating template for "boundary_credential_library_vault"
generating template for "boundary_auth_method_password"
generating template for "boundary_managed_group_ldap"
generating template for "boundary_credential_json"
generating template for "boundary_host_set_static"
generating template for "boundary_target"
generating template for "boundary_account"
generating template for "boundary_auth_method_ldap"
generating template for "boundary_host_catalog_plugin"
generating template for "boundary_credential_library_vault_ssh_certificate"
generating template for "boundary_credential_ssh_private_key"
resource "boundary_group" template exists, skipping
generating template for "boundary_host"
generating template for "boundary_host_static"
generating template for "boundary_worker"
generating template for "boundary_account_oidc"
generating template for "boundary_auth_method"
generating missing data source content
resource "boundary_user" template exists, skipping
resource "boundary_scope" template exists, skipping
generating missing provider content
provider "terraform-provider-boundary" template exists, skipping
rendering static website
cleaning rendered website dir
removing directory: "data-sources"
removing file: "index.md"
removing directory: "resources"
rendering templated website to static markdown
rendering "data-sources/scope.md.tmpl"
rendering "data-sources/user.md.tmpl"
rendering "index.md.tmpl"
rendering "resources/account.md.tmpl"
rendering "resources/account_ldap.md.tmpl"
rendering "resources/account_oidc.md.tmpl"
rendering "resources/account_password.md.tmpl"
rendering "resources/auth_method.md.tmpl"
rendering "resources/auth_method_ldap.md.tmpl"
rendering "resources/auth_method_oidc.md.tmpl"
rendering "resources/auth_method_password.md.tmpl"
rendering "resources/credential_json.md.tmpl"
rendering "resources/credential_library_vault.md.tmpl"
rendering "resources/credential_library_vault_ssh_certificate.md.tmpl"
rendering "resources/credential_ssh_private_key.md.tmpl"
rendering "resources/credential_store_static.md.tmpl"
rendering "resources/credential_store_vault.md.tmpl"
rendering "resources/credential_username_password.md.tmpl"
rendering "resources/group.md.tmpl"
rendering "resources/host.md.tmpl"
rendering "resources/host_catalog.md.tmpl"
rendering "resources/host_catalog_plugin.md.tmpl"
rendering "resources/host_catalog_static.md.tmpl"
rendering "resources/host_set.md.tmpl"
rendering "resources/host_set_plugin.md.tmpl"
rendering "resources/host_set_static.md.tmpl"
rendering "resources/host_static.md.tmpl"
rendering "resources/managed_group.md.tmpl"
rendering "resources/managed_group_ldap.md.tmpl"
rendering "resources/role.md.tmpl"
rendering "resources/scope.md.tmpl"
rendering "resources/storage_bucket.md.tmpl"
rendering "resources/target.md.tmpl"
rendering "resources/user.md.tmpl"
rendering "resources/worker.md.tmpl"
copywrite headers
make: copywrite: No such file or directory
make: *** [copywrite] Error 1

@louisruch
Copy link
Contributor

Looks like you need copywrite, try running make tools I believe that installs it

@drewmullen
Copy link
Contributor Author

same outcome:

$ make tools                                         
go generate -tags tools tools/tools.go
go install github.com/hashicorp/copywrite@v0.15.0
go: downloading github.com/hashicorp/copywrite v0.15.0
go: downloading github.com/hashicorp/addLicense v1.4.1
go: downloading github.com/jedib0t/go-pretty/v6 v6.4.4
go: downloading github.com/bradleyfalzon/ghinstallation/v2 v2.1.0
go: downloading github.com/cli/go-gh v1.0.0
go: downloading golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5
go: downloading golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab
go: downloading golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17
go: downloading golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
go: downloading golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d
go: downloading golang.org/x/net v0.0.0-20220923203811-8be639271d50
go: downloading github.com/golang-jwt/jwt/v4 v4.4.2

$ make gen           
go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
rendering website for provider "terraform-provider-boundary" (as "terraform-provider-boundary")
copying any existing content to tmp dir
exporting schema from Terraform
compiling provider "boundary"
using Terraform CLI binary from PATH if available, otherwise downloading latest Terraform CLI binary
running terraform init
getting provider schema
rendering missing docs
generating missing resource content
generating template for "boundary_credential_store_vault"
generating template for "boundary_credential_username_password"
generating template for "boundary_host_set"
generating template for "boundary_worker"
generating template for "boundary_managed_group_ldap"
generating template for "boundary_account"
resource "boundary_group" template exists, skipping
generating template for "boundary_host"
generating template for "boundary_host_catalog"
generating template for "boundary_host_catalog_plugin"
generating template for "boundary_managed_group"
generating template for "boundary_auth_method_oidc"
generating template for "boundary_auth_method_password"
generating template for "boundary_credential_library_vault_ssh_certificate"
resource "boundary_scope" template exists, skipping
generating template for "boundary_user"
generating template for "boundary_account_oidc"
generating template for "boundary_credential_library_vault"
generating template for "boundary_host_catalog_static"
generating template for "boundary_host_set_plugin"
resource "boundary_role" template exists, skipping
generating template for "boundary_storage_bucket"
generating template for "boundary_account_ldap"
generating template for "boundary_account_password"
generating template for "boundary_auth_method"
generating template for "boundary_credential_ssh_private_key"
generating template for "boundary_host_set_static"
generating template for "boundary_host_static"
generating template for "boundary_target"
generating template for "boundary_auth_method_ldap"
generating template for "boundary_credential_json"
generating template for "boundary_credential_store_static"
generating missing data source content
resource "boundary_scope" template exists, skipping
resource "boundary_user" template exists, skipping
generating missing provider content
provider "terraform-provider-boundary" template exists, skipping
rendering static website
cleaning rendered website dir
removing directory: "data-sources"
removing file: "index.md"
removing directory: "resources"
rendering templated website to static markdown
rendering "data-sources/scope.md.tmpl"
rendering "data-sources/user.md.tmpl"
rendering "index.md.tmpl"
rendering "resources/account.md.tmpl"
rendering "resources/account_ldap.md.tmpl"
rendering "resources/account_oidc.md.tmpl"
rendering "resources/account_password.md.tmpl"
rendering "resources/auth_method.md.tmpl"
rendering "resources/auth_method_ldap.md.tmpl"
rendering "resources/auth_method_oidc.md.tmpl"
rendering "resources/auth_method_password.md.tmpl"
rendering "resources/credential_json.md.tmpl"
rendering "resources/credential_library_vault.md.tmpl"
rendering "resources/credential_library_vault_ssh_certificate.md.tmpl"
rendering "resources/credential_ssh_private_key.md.tmpl"
rendering "resources/credential_store_static.md.tmpl"
rendering "resources/credential_store_vault.md.tmpl"
rendering "resources/credential_username_password.md.tmpl"
rendering "resources/group.md.tmpl"
rendering "resources/host.md.tmpl"
rendering "resources/host_catalog.md.tmpl"
rendering "resources/host_catalog_plugin.md.tmpl"
rendering "resources/host_catalog_static.md.tmpl"
rendering "resources/host_set.md.tmpl"
rendering "resources/host_set_plugin.md.tmpl"
rendering "resources/host_set_static.md.tmpl"
rendering "resources/host_static.md.tmpl"
rendering "resources/managed_group.md.tmpl"
rendering "resources/managed_group_ldap.md.tmpl"
rendering "resources/role.md.tmpl"
rendering "resources/scope.md.tmpl"
rendering "resources/storage_bucket.md.tmpl"
rendering "resources/target.md.tmpl"
rendering "resources/user.md.tmpl"
rendering "resources/worker.md.tmpl"
copywrite headers
make: copywrite: No such file or directory
make: *** [copywrite] Error 1

@drewmullen
Copy link
Contributor Author

wrong go path in my session. pushing final commit now

@louisruch
Copy link
Contributor

Ok running now 🤞

@drewmullen
Copy link
Contributor Author

to defend myself from future haters - it looks like copywrite was added a few days ago: 9d351f8#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52

@louisruch louisruch merged commit 0f2473a into hashicorp:main Oct 17, 2023
3 checks passed
@drewmullen drewmullen deleted the ds-user branch October 18, 2023 00:29
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.

New data source boundary_user
3 participants