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

provider: Add jwt_issuer resource #231

Merged
merged 1 commit into from
Sep 26, 2024
Merged

provider: Add jwt_issuer resource #231

merged 1 commit into from
Sep 26, 2024

Conversation

pritesh-lahoti
Copy link
Contributor

@pritesh-lahoti pritesh-lahoti commented Sep 2, 2024

Aligning to the CC API changes, this PR deprecates the api_oidc_config resource in favor of the jwt_issuer resource.
As the existing TF resource was not in use, the team decided to make the changes in-place.
Refined and added exhaustive acceptance tests.

Commit checklist

  • Changelog
  • Doc gen (make generate)
  • Integration test(s)
  • Acceptance test(s)
  • Example(s)

Copy link
Collaborator

@fantapop fantapop left a comment

Choose a reason for hiding this comment

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

This looks good in general. I left some comments / questions.

docs/resources/jwt_issuer.md Outdated Show resolved Hide resolved
internal/provider/jwt_issuers.go Show resolved Hide resolved
internal/provider/jwt_issuers.go Outdated Show resolved Hide resolved
internal/provider/jwt_issuers_test.go Show resolved Hide resolved
internal/provider/jwt_issuers_test.go Outdated Show resolved Hide resolved
internal/provider/jwt_issuers_test.go Outdated Show resolved Hide resolved
@pritesh-lahoti pritesh-lahoti force-pushed the tf-jwt-issuers branch 4 times, most recently from a343c75 to a0742bf Compare September 23, 2024 06:26
Copy link
Collaborator

@fantapop fantapop left a comment

Choose a reason for hiding this comment

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

I left some questions and nits in there but mostly looks good. @mdlinville Can you look over the docs here?

docs/resources/jwt_issuer.md Outdated Show resolved Hide resolved
Optional: true,
Computed: true,
Description: "Indicates that the token_principal field is a regex value.",
Description: "Specifies how to map the fetched token identity to an identity in CockroachDB Cloud. In case of a regular expression for token_identity, this must contain a \\1 placeholder for the matched content.",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if there will be a problem understanding if the slashes in the placeholder token should be escaped or not? I noticed that in the docs they show up as \1 but in the actual source they need to use \\1. I'm not sure the best way to document this. Maybe @mdlinville can comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree.
@mdlinville did you have a recommendation here?

I'll keep the description here and within the API in sync.

Choose a reason for hiding this comment

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

I have no idea about this. If you need a second backslash to show up, don't you just escape it? I'm not familiar the nuts and bolts here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The question is how best to document what value the user should use. The current output will read as this:

...for token_identity, this must contain a \1 placeholder for the matched content.

But since the value in the string will need to be escaped, the user will actually use \\1. I was suggesting that maybe we should show \\1 instead. But asking you if you had guidance on how to make this distinction more clear to the user.

One potential way would be to link them to an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the field description to call this out. Open to suggestions.

internal/provider/jwt_issuers.go Show resolved Hide resolved
internal/provider/jwt_issuers.go Show resolved Hide resolved
internal/provider/jwt_issuers_test.go Show resolved Hide resolved
internal/provider/jwt_issuers_test.go Outdated Show resolved Hide resolved
@fantapop fantapop requested a review from mdlinville September 23, 2024 18:12
Copy link

@mdlinville mdlinville left a comment

Choose a reason for hiding this comment

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

Some small comments to improve the examples hopefully.

docs/resources/jwt_issuer.md Show resolved Hide resolved
docs/resources/jwt_issuer.md Outdated Show resolved Hide resolved
docs/resources/jwt_issuer.md Show resolved Hide resolved
docs/resources/jwt_issuer.md Outdated Show resolved Hide resolved
examples/resources/cockroach_jwt_issuer/resource.tf Outdated Show resolved Hide resolved
Aligning to the CC API changes, this PR deprecates the `api_oidc_config`
resource in favor of the `jwt_issuer` resource.
As the existing TF resource was not in use, the team decided to make
the changes in-place.
Refined and added exhaustive acceptance tests.
Removed is_regex field from the TF Provider.
@pritesh-lahoti
Copy link
Contributor Author

I'll be going ahead and merging the change to avoid any further merge conflicts.
I could take up any pending suggestions separately.

@pritesh-lahoti pritesh-lahoti merged commit 501c915 into main Sep 26, 2024
4 checks passed
@pritesh-lahoti pritesh-lahoti deleted the tf-jwt-issuers branch September 26, 2024 06: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.

4 participants