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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data source vault auth backends #1827

Merged
merged 22 commits into from
May 12, 2023

Conversation

mengesb
Copy link
Contributor

@mengesb mengesb commented Apr 21, 2023

Community Note

  • Please vote on this pull request by adding a 馃憤 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Closes #1793
Closes #1081

Release note for CHANGELOG:

FEATURES:
* Add new data source `vault_auth_backends`, test fixup by @fairclothjm

Output from acceptance testing:

$ vault server -dev >vault-server-dev.log 2>&1 &
$ export TESTARGS="--run TestDataSourceAuthBackends"
$ export VAULT_ADDR='http://127.0.0.1:8200'
$ export VAULT_TOKEN=REDACTED
$ GOPATH=$CWD make testacc
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test --run TestDataSourceAuthBackends -timeout 30m ./...
?       github.com/hashicorp/terraform-provider-vault   [no test files]
?       github.com/hashicorp/terraform-provider-vault/cmd/coverage      [no test files]
?       github.com/hashicorp/terraform-provider-vault/cmd/generate      [no test files]
?       github.com/hashicorp/terraform-provider-vault/generated [no test files]
ok      github.com/hashicorp/terraform-provider-vault/codegen   (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/datasources/transform/decode(cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/datasources/transform/encode(cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/alphabet(cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/role   (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/template(cached) [no tests to run]
?       github.com/hashicorp/terraform-provider-vault/helper    [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/consts   [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/identity/group   [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/identity/mfa     [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/pki      [no test files]
?       github.com/hashicorp/terraform-provider-vault/schema    [no test files]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/transformation  (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/internal/identity/entity  (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/internal/provider (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/testutil  (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/util      (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/vault     3.377s

mengesb and others added 12 commits March 7, 2023 11:34
Signed-off-by: Brian Menges <mengesb@gmail.com>
Signed-off-by: Brian Menges <mengesb@gmail.com>
Signed-off-by: Brian Menges <mengesb@gmail.com>
Signed-off-by: Brian Menges <mengesb@gmail.com>
Signed-off-by: Brian Menges <mengesb@gmail.com>
Signed-off-by: Brian Menges <mengesb@gmail.com>
Copy link
Contributor

@fairclothjm fairclothjm left a comment

Choose a reason for hiding this comment

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

Thanks @mengesb! Just a few small changes and this should be good to go!

mengesb and others added 2 commits May 11, 2023 13:36
quoted references deprecated

Co-authored-by: John-Michael Faircloth <fairclothjm@users.noreply.github.com>
Use consts

Co-authored-by: John-Michael Faircloth <fairclothjm@users.noreply.github.com>
@mengesb
Copy link
Contributor Author

mengesb commented May 11, 2023

Regarding use of consts @fairclothjm

https://github.com/hashicorp/terraform-provider-vault/blob/e55cfcd486a3cc13ca401954c0b6fb0adbb48948/internal/consts/consts.go#LL160C1-L161C1

Should I update the accessors as well? I'm assuming I should leave paths alone given that's unique, or would you like that added to consts? (and I wouldn't be me if I didn't also mention that data.auth_backend doesn't make use of consts)

@fairclothjm
Copy link
Contributor

@mengesb RE: consts

Yes, let's update all fields to use consts. If not already defined in https://github.com/hashicorp/terraform-provider-vault/blob/main/internal/consts/consts.go then we can add new entries.

data.auth_backend doesn't make use of consts

We are requiring that all new resources use consts.

Signed-off-by: Brian Menges <mengesb@gmail.com>
* Include consts
* Rename accessors to auth_method_accessors per consts
* Update tests to reflect changes using consts
* Update documentation

Signed-off-by: Brian Menges <mengesb@gmail.com>
@mengesb
Copy link
Contributor Author

mengesb commented May 11, 2023

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test --run TestDataSourceAuthBackends -timeout 30m ./...
?       github.com/hashicorp/terraform-provider-vault   [no test files]
?       github.com/hashicorp/terraform-provider-vault/cmd/coverage      [no test files]
?       github.com/hashicorp/terraform-provider-vault/cmd/generate      [no test files]
?       github.com/hashicorp/terraform-provider-vault/generated [no test files]
ok      github.com/hashicorp/terraform-provider-vault/codegen   (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/datasources/transform/decode  (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/datasources/transform/encode  (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/alphabet  (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/role      (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/template  (cached) [no tests to run]
?       github.com/hashicorp/terraform-provider-vault/helper    [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/consts   [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/identity/group   [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/identity/mfa     [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/pki      [no test files]
?       github.com/hashicorp/terraform-provider-vault/schema    [no test files]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/transformation     (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/internal/identity/entity  (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/internal/provider (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/testutil  (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/util      (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/vault     3.127s

@mengesb
Copy link
Contributor Author

mengesb commented May 11, 2023

Myriad of comments, commits, and overall byte sized goodness.

mengesb and others added 4 commits May 12, 2023 11:21
Co-authored-by: John-Michael Faircloth <fairclothjm@users.noreply.github.com>
Signed-off-by: Brian Menges <mengesb@gmail.com>
Signed-off-by: Brian Menges <mengesb@gmail.com>
Signed-off-by: Brian Menges <mengesb@gmail.com>
@mengesb
Copy link
Contributor Author

mengesb commented May 12, 2023

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test --run TestDataSourceAuthBackends -timeout 30m ./...
?       github.com/hashicorp/terraform-provider-vault   [no test files]
?       github.com/hashicorp/terraform-provider-vault/cmd/coverage      [no test files]
?       github.com/hashicorp/terraform-provider-vault/cmd/generate      [no test files]
?       github.com/hashicorp/terraform-provider-vault/generated [no test files]
ok      github.com/hashicorp/terraform-provider-vault/codegen   (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/datasources/transform/decode(cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/datasources/transform/encode(cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/alphabet(cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/role   (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/template(cached) [no tests to run]
?       github.com/hashicorp/terraform-provider-vault/helper    [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/consts   [no test files]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/transformation  (cached) [no tests to run]
?       github.com/hashicorp/terraform-provider-vault/internal/identity/group   [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/identity/mfa     [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/pki      [no test files]
ok      github.com/hashicorp/terraform-provider-vault/internal/identity/entity  (cached) [no tests to run]
?       github.com/hashicorp/terraform-provider-vault/schema    [no test files]
ok      github.com/hashicorp/terraform-provider-vault/internal/provider (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/testutil  (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/util      (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/vault     3.140s

@mengesb
Copy link
Contributor Author

mengesb commented May 12, 2023

OK

I updated the tests to uses consts, and also found my IDE warned me about a duplicate use of terraform-plugin-sdk/v2/helper/resource so I removed the renamed import and updated those references. I also added the new const FieldAccessors since there was no other plural accessor const.

Copy link
Contributor

@fairclothjm fairclothjm left a comment

Choose a reason for hiding this comment

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

One last nitpick and this PR can be merged

Signed-off-by: Brian Menges <mengesb@gmail.com>
Signed-off-by: Brian Menges <mengesb@gmail.com>
@mengesb
Copy link
Contributor Author

mengesb commented May 12, 2023

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test --run TestDataSourceAuthBackends -timeout 30m ./...
?       github.com/hashicorp/terraform-provider-vault   [no test files]
?       github.com/hashicorp/terraform-provider-vault/cmd/coverage      [no test files]
?       github.com/hashicorp/terraform-provider-vault/cmd/generate      [no test files]
?       github.com/hashicorp/terraform-provider-vault/generated [no test files]
ok      github.com/hashicorp/terraform-provider-vault/codegen   (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/datasources/transform/decode0.376s [no tests to run]
?       github.com/hashicorp/terraform-provider-vault/internal/consts   [no test files]
?       github.com/hashicorp/terraform-provider-vault/helper    [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/identity/group   [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/identity/mfa     [no test files]
?       github.com/hashicorp/terraform-provider-vault/internal/pki      [no test files]
?       github.com/hashicorp/terraform-provider-vault/schema    [no test files]
ok      github.com/hashicorp/terraform-provider-vault/generated/datasources/transform/encode0.686s [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/alphabet0.987s [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/role   1.305s [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/template1.593s [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/generated/resources/transform/transformation  1.401s [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/internal/identity/entity  (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/internal/provider (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/testutil  (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/util      (cached) [no tests to run]
ok      github.com/hashicorp/terraform-provider-vault/vault     3.175s

@mengesb
Copy link
Contributor Author

mengesb commented May 12, 2023

OK, we're all consts-ed; sort from data source removed so there's no implied order, and the type field documentation was amended to help explain it a little better. We bounced around on accessors due to consts, but we're back with accessors being a consts so I think we're good there.

Hope everything is looking 馃憤

Copy link
Contributor

@fairclothjm fairclothjm left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @mengesb !

@fairclothjm fairclothjm merged commit 9f27afe into hashicorp:main May 12, 2023
1 check passed
@fairclothjm fairclothjm added this to the 3.16.0 milestone May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Data source: vault_auth_backends FEATURE data "vault_auth_backends"
2 participants