-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add support for custom certificates #111
Conversation
The parameters are added to the provider config to support it: - ca_cert - client_cert - client_key You need to have all three passed for the configuration to be picked up, it will fail otherise. It also overrides the `tls` parameter (cfg.TLSConfig), if the latter is set. Tests are not passing (they were passing upstream either), but running it locally works fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are not passing (they were passing upstream either), but running it locally works fine.
Tests are actually passing for me (both before and after this change) when I run make acceptance
, but how much work would it be to add an acceptance test, that would test this feature works?
Oh, fair enough. I tried with |
Good point - I have never noticed. It needs to be eventually fixed. |
I mistakenly handled the tls argument inside the mysql driver instead of doing that in the provider. This commit adds another field, `tls_config_key`, that will be used to hold the key passed to `registerTLSConfig()`. It overwrites the `tls` option if set and all the relevate certificates are set as well. This is inline with the behaviour defined in the driver https://github.com/gallois/terraform-provider-mysql/blob/4396636ec23a483a9916fd7386cbfc9cc399a365/vendor/github.com/go-sql-driver/mysql/dsn.go#L48-L49
I'm struggling a bit to write an acceptance test for this one, especially because it requires dealing with the certificates both on the host and the container. And as I mentioned before, I'm not too familiar with how the code should work for that :) I updated the PR with the changes to address the comments and I'll create a separate one for the acceptance tests |
That's fine even without acceptance tests if that is complicated - but please at least manually test it. |
I have 1 more request: please add the structure to documentation so people can find it without searching the source code. |
I did manual tests in two different setups that I have, one with the With
Without
Any other way I can test it? Another question I have is, do I have to run anything to generate the documentation? I tried |
For security-related features, at least these things should be always tested:
It will be generated automatically. It is really helpful as it shows you didn't write it properly - you need a newline just before starting code block. And the last line of code block contains extra empty line, that's not necessary. |
👍
It does. The error is something like:
This is for the case where you are using certificates for another identity in the same endpoint.
Should fail in different ways, depending on the failure mode, one example
👍
Unfortunately, I get
when I try it |
Ah, so for that Besides that, I had some time to test this - I added comments to the code (just text + documentation) to reflect what I found. Especially (default) large timeout makes this time-consuming to debug and it would be useful to help users by telling them, how to lower it temporarily. So my comments are fixed, I'll merge it. |
Just pushed changes to address your comments. I'd ask you to just verify that I didn't mess up with the documentation formatting since I couldn't run it locally :) Thanks! |
@gallois thanks for your PR! Now, you should be able to run website locally. Building this with version 3.0.48 |
Thanks for your patience in reviewing it 🙏 |
The parameters are added to the provider config to support it:
You need to have all three passed for the configuration to be picked up, it will fail otherise. It also overrides the
tls
parameter (cfg.TLSConfig), if the latter is set.Tests are not passing (they were passing upstream either), but running it locally works fine.