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 resource gitlab_user_gpgkey #1181
Add resource gitlab_user_gpgkey #1181
Conversation
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.
Welcome @yan12125 👋
It looks like this is your first submission to the Terraform GitLab Provider! If you haven’t already done so, please make sure you have checked out our CONTRIBUTING.md guide to make sure your contribution has all the necessary elements in place for a successful approval.
Thanks again, and welcome to the community! 😃
Here are steps to reproduce:
resource "gitlab_user_gpgkey" "yan12125" {
key = <<KEY
-----BEGIN PGP PUBLIC KEY BLOCK-----
xxx
-----END PGP PUBLIC KEY BLOCK-----
KEY
}
The key recorded in terraform.tfstate is the same as my actual key, but somehow my code makes terraform treat them as different. |
@yan12125 The diff is because with your I suggest that you remove leading and trailing whitespaces from the key in the create function. |
Thanks! Now |
Added docs and tests - now ready for reviews :) |
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.
It already looks quite good! I've added a few nitpicks and other comments.
Back to you 🏓
Thanks! I applied some trivial changes. Others need some time :) |
This pull request has merge conflicts. Please rebase your branch onto |
Conflicts are resolved. Thank you! 😀 |
Rebased on top of master as upgrading go-gitlab conflicts with upgrades of other dependencies (#1184) |
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.
A few minor things and make sure to run make reviewable
before the next push, to re-generate the docs etc.
Back to you 🏓
Thanks for the reminder about
|
@yan12125 Can you change that code in the config.go file to use |
I can try it out. Is it better to make changes in this PR or another PR? |
@yan12125 let's do another PR, since you've asked ;) |
Here you go~ #1199 Regarding this PR, I rebased on top of the latest main branch and drop changes to go.mod/go.sum. |
* Using strings.TrimSpace() as GitLab and/or Terraform may add trailing newlines to field values. * Add tests for resource gitlab_user_gpgkey * Add tests for resource gitlab_user_gpgkey without user_id * Improve docs and add examples * Update internal/provider/resource_gitlab_user_gpgkey.go * Update internal/provider/resource_gitlab_user_gpgkey.go * Update internal/provider/resource_gitlab_user_gpgkey.go * Update internal/provider/resource_gitlab_user_gpgkey.go * Use simpler GetGPGKey & GetGPGKeyForUser APIs * Include the config in the test as suggested in #1008 * Rely only on ImportStateVerify and get rid of manual checks * Also use simpler GetGPGKey & GetGPGKeyForUser APIs for tests * Drop the check for the created_at field in GPG keys * Also test switching between the current user and a specific user * Fix the example and regenerate docs * Fix "ineffectual assignment" errors from golangci-lint * Run gofmt Closes https://github.com/gitlabhq/terraform-provider-gitlab/issues/1166 Co-authored-by: Timo Furrer <tuxtimo@gmail.com>
Great thanks! Rebased and squashed :) |
Test failures seem unrelated. Both 15.1.3-ce.0 and 15.1.3-ee.0 tests fail with:
Which appears the same issue as https://github.com/gitlabhq/terraform-provider-gitlab/issues/1039. |
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.
LGTM 🎉
@yan12125 I've re-triggered the tests and it's all looking good now. Nice work 🎉 🚢 |
Thank you very much for the time! |
This functionality has been released in v3.17.0 of the Terraform GitLab Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue. Thank you! |
Description
Somehow
terraform plan
always reports the field armored_public_key aschanged.
Closes https://github.com/gitlabhq/terraform-provider-gitlab/issues/1166
PR Checklist Acknowledgement
//lintignore
comments were copied from existing code. (Linter rules are meant to be enforced on new code.)