Skip to content

feat: add github_user_ssh_signing_key - #2366

Open
simonostendorf wants to merge 10 commits into
integrations:mainfrom
simonostendorf:feat/github_user_ssh_signing_key
Open

simonostendorf wants to merge 10 commits into
integrations:mainfrom
simonostendorf:feat/github_user_ssh_signing_key

Conversation

@simonostendorf

@simonostendorf simonostendorf commented Aug 26, 2024 •

Copy link
Copy Markdown

Resolves #2365

Resolves #1917


Before the change?

  • managing ssh signing keys was not possible

After the change?

  • managing ssh signing keys is possible with github_user_ssh_signing_key resource
  • the resource is equal to the existing github_user_ssh_key resource that manages ssh auth keys

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@kfcampbell

Copy link
Copy Markdown
Contributor

@simonostendorf can you please link to the new doc you created in the github.erb file so it's discoverable?

@simonostendorf

Copy link
Copy Markdown
Author

@simonostendorf can you please link to the new doc you created in the github.erb file so it's discoverable?

@kfcampbell sorry forgot that. I added it now.

@simonostendorf
simonostendorf force-pushed the feat/github_user_ssh_signing_key branch 2 times, most recently from 875d76f to 1dde54f Compare September 15, 2024 08:06
@simonostendorf
simonostendorf force-pushed the feat/github_user_ssh_signing_key branch 2 times, most recently from f5d9e6d to 3860cf3 Compare September 22, 2024 16:20
@simonostendorf
simonostendorf force-pushed the feat/github_user_ssh_signing_key branch 2 times, most recently from 065e10e to efcc88e Compare September 28, 2024 15:22
@simonostendorf
simonostendorf force-pushed the feat/github_user_ssh_signing_key branch 2 times, most recently from 009fd4b to 4713629 Compare October 10, 2024 11:42
@quotidian-ennui

Copy link
Copy Markdown

#1917 should perhaps be formally linked to this PR as well since it appears equivalent to #2365

@simonostendorf
simonostendorf force-pushed the feat/github_user_ssh_signing_key branch from 4713629 to 8087453 Compare October 16, 2024 09:17
@simonostendorf
simonostendorf force-pushed the feat/github_user_ssh_signing_key branch from 8087453 to dd6de65 Compare May 28, 2025 05:38
@simonostendorf

Copy link
Copy Markdown
Author

@kfcampbell hey, can we get this merged?

@kilianpaquier

Copy link
Copy Markdown

Would love to see this merged

@github-project-automation github-project-automation Bot moved this from 🛑 Blocked/Awaiting Response to 🏗 In progress in 🧰 Octokit Active Jan 17, 2026
@deiga

deiga commented Jan 17, 2026

Copy link
Copy Markdown
Collaborator

Hey @simonostendorf
Sorry that you have needed to wait for so long. Could you rebase your branch and adjust your code to fit our newer standards?

@simonostendorf
simonostendorf force-pushed the feat/github_user_ssh_signing_key branch from dd6de65 to 171470e Compare January 18, 2026 05:46
@github-actions github-actions Bot added the Type: Feature New feature or request label Jan 18, 2026
@simonostendorf

Copy link
Copy Markdown
Author

Hey @simonostendorf Sorry that you have needed to wait for so long. Could you rebase your branch and adjust your code to fit our newer standards?

Should be implemented now

@simonostendorf
simonostendorf force-pushed the feat/github_user_ssh_signing_key branch 2 times, most recently from 78de3d9 to fcd48d3 Compare January 22, 2026 22:21
@simonostendorf
simonostendorf force-pushed the feat/github_user_ssh_signing_key branch from fcd48d3 to 07dd337 Compare February 4, 2026 21:18
@simonostendorf
simonostendorf force-pushed the feat/github_user_ssh_signing_key branch 2 times, most recently from a74c9d4 to d06ac7d Compare February 10, 2026 14:05
Comment thread github/resource_github_user_ssh_key.go Resolved
Comment thread github/resource_github_user_ssh_key.go Resolved
Comment thread github/resource_github_user_ssh_key.go Resolved
Comment thread github/resource_github_user_ssh_key.go Resolved
@simonostendorf
simonostendorf requested a review from deiga August 9, 2026 15:43

@stevehipwell stevehipwell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@simonostendorf it doesn't look like you're using hashicorp/terraform-plugin-docs to generate the docs page, this is required and CI will fail if it's not been implemented. Off the top of my head you need to add a template, the example naming needs fixing and you need to add the import examples. It also looks like you haven't followed other parts of the contribution guide such as the required linting?

Comment thread github/resource_github_user_ssh_key.go Resolved
Comment thread github/resource_github_user_ssh_key.go Resolved
@simonostendorf
simonostendorf force-pushed the feat/github_user_ssh_signing_key branch from d38c902 to 3d3c2e7 Compare September 8, 2026 03:41
@simonostendorf

Copy link
Copy Markdown
Author

Thanks @stevehipwell, that was helpful, especially the pointer to tfplugindocs. Rebased onto main and pushed.

The docs page was not generated as I was told in feburary. Added the missing template and the import examples, and regenerated.

The rebase pulled in #3474, which made etag Optional + Computed with diff suppression across 28 resources. That conflicted with my commits from before. I resolved in favour of #3474 for github_user_ssh_key and applied the same block to github_user_ssh_signing_key, so the new resource follows the convention instead of the plain Computed etag I originally wrote.

Two things I did beyond your comments, happy to split either out if you prefer:

  • Converted github_user_ssh_key to the generated docs form as well. This PR already changes that resources schema, and I was patching its hand maintained attribute list by hand.
  • tools/tools.go now passes --provider-name github. tfplugindocs derives the provider short name from the provider directory name, so make generatedocs wipes docs/ and then fails in any clone not named terraform-provider-github. Unrelated to this feature, but it is a one line fix and it cost me a while to work out.

I also switched the github_user_ssh_key acceptance test from skipUnlessMode(t, individual) to skipUnauthenticated(t). The test is otherwise already modernised in this PR, and under the old precheck it never runs in the org test mode that the sweepers I added assume.

@stevehipwell stevehipwell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the quick response and detailed summary of the changes you made, it makes context shifting and re-reviewing much easier.

The main review point is could you please take a look at the tests for one of the updated resources and update the tests in this PR accordingly. Not the use of fewer test cases with more steps.

Thanks for pointing out what happened in #3474, that doesn't look right to me. But in a related point, could you make sure that you set the etag value to zero if the update fails (probably not needed for this resource, but it should be the pattern).

@simonostendorf
simonostendorf force-pushed the feat/github_user_ssh_signing_key branch from 3d3c2e7 to 1e10f4e Compare September 13, 2026 14:29
@simonostendorf

Copy link
Copy Markdown
Author

Thanks @stevehipwell, that all makes sense.

Rebased onto main and pushed.

Tests. Took github_actions_variable as the reference from RESOURCES.md and
rewrote both test files to match. The two near identical subtests are now one
default subtest with four steps: create, retitle, rekey, import. The two
rename steps assert ResourceActionReplace via ConfigPlanChecks, since both
attributes are ForceNew. Import is the last step of the happy path rather
than its own case, as you asked.

Also dropped PreCheck entirely and moved skipUnauthenticated(t) to the top
of the test function, matching the current pattern.

Test helper. newTestKey and newTestSigningKey are gone. Replaced by a
single mustNewSshPublicKey(t) in github/helpers_test.go, next to the
existing mustNewPEM, using t.Helper() and t.Fatalf on both error paths.
It now generates Ed25519 rather than RSA 1024 while I was in there. GitHub
rejects RSA keys below 2048 bits, so the old helper would not have survived a
real acceptance run.

On skipUnlessMode(t, individual) to skipUnauthenticated(t). You are
right that this resource is for the authenticated user, and that is exactly
why I changed it. individual is one specific auth mode, so the old precheck
skipped the test in the org modes, including the mode the sweepers I added in
this PR run under. The resource does not care which mode it is, only that
there is an authenticated user, so skipUnauthenticated is the accurate
condition. Happy to revert if you would rather keep the narrower gate.

Etag. The rebase also pulled in #3637, which replaced the #3474
Optional + DiffSuppressFunc block with CustomizeDiff: diffETag and a
plain Computed etag. I had applied the #3474 form to
github_user_ssh_signing_key in an earlier commit, so I have moved it over to
diffETag and regenerated the docs for both resources. The etag attribute is
now Read-Only rather than Optional on both pages.

On zeroing the etag when an update fails: there is nowhere to put it here.
Neither resource has an update function, because the GitHub API has no update
endpoint for user SSH keys or signing keys, so title and key are both
ForceNew. github_release looks like the only resource doing this today
(d.Set("etag", nil) as the first statement of update).

@regulad

regulad commented Nov 23, 2026

Copy link
Copy Markdown

Hello @simonostendorf and @stevehipwell,

I needed this myself, so I got it applying against main (9017b2e). Please feel free to pull it into this PR, as needed.

The nine commits apply as they are, apart from a conflict in resource_github_user_ssh_key.go in the first one, which I resolved. Two commits on top bring it up to date with main: go-github v92 (#3640) and the storeEtag check (#3693). It builds, the unit tests in github/ pass, and golangci-lint reports no new issues.


Drafted by Claude Opus 5.5 (claude-opus-5-5); reviewed by @regulad.

@robert-crandall

Copy link
Copy Markdown
Contributor

Thanks for putting this PR together and taking the time to contribute!

We're temporarily moving to an issue-first model (see CONTRIBUTING.md) where only collaborators can open PRs while we work through the backlog. Because of that, I'm going to close this PR for now.

I've linked it on #2365 so we don't lose your work or context when we pick that issue up. Feel free to add a 👍 or any extra notes there to help us prioritize it.

@github-project-automation github-project-automation Bot moved this from 🏗 In progress to ✅ Done in 🧰 Octokit Active Nov 25, 2026
@robert-crandall

Copy link
Copy Markdown
Contributor

Reopening this - sorry for the noise! I missed that this already had maintainer reviews and follow-up commits, so we're keeping active/reviewed PRs open while we triage them.

@stevehipwell

Copy link
Copy Markdown
Collaborator

@simonostendorf please could you rebase this PR?

@simonostendorf
simonostendorf force-pushed the feat/github_user_ssh_signing_key branch from 1e10f4e to 4cdc97d Compare November 28, 2026 11:29

@stevehipwell stevehipwell left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @simonostendorf, this is looking close to being ready to merge.

Comment thread github/resource_github_user_ssh_key.go Resolved
Comment thread github/resource_github_user_ssh_key.go Resolved
Comment thread github/resource_github_user_ssh_key.go Resolved
@github-project-automation github-project-automation Bot moved this from ✅ Done to 🏗 In progress in 🧰 Octokit Active Nov 30, 2026
feat: add docs for github_user_ssh_signing_key

fix: add github_user_ssh_signing_key to provider.go

fix: add github_user_ssh_signing_key to github.erb

fix: use tflog, context, test-structure

fix: use resource-prefix, sweeper, 404-handling, direct read

fix: key_id

feat: import

feat: adjust user_ssh_key to new structure

fix: typo

fix: dont overwrite key on create

fix: add new fields to website

fix: linting

fix(tests): correct imports

fix: int usage, keep url, state migration

fix: readd url

fix: docs, unneeded args, missing description

fix: use deleteResourceOn404AndSwallow304OtherwiseReturnError

fix: setting key_id, schemaVersion, website arguments
Reword both resource descriptions to the 'Resource to manage ...' form,
replace the forced type assertions flagged by the forcetypeassert linter
with checked ones, and set the etag attribute last.
Add the missing template for github_user_ssh_signing_key and convert the
github_user_ssh_key template to the generated form. Rename both example
directories to the names tfplugindocs detects and add import examples for
the import block and the CLI.
Use skipUnauthenticated instead of skipUnlessMode and run the signing key
subtests in parallel. Add the new sweepers to the default SWEEP list and
record both resources as aligned in RESOURCES.md.
tfplugindocs derives the provider short name from the provider directory
name, which breaks docs generation in any clone not named
terraform-provider-github.
Follow up on integrations#3474, which landed while this PR was open: give the new
signing key resource the same Optional + Computed etag with diff
suppression that the other 28 resources use.
Follow github_actions_variable, listed in RESOURCES.md as having fully
refactored tests. Collapse the separate create and import cases into one
default subtest with four steps: create, retitle, rekey, import. The two
rename steps assert ResourceActionReplace, since title and key are both
ForceNew.

Drop PreCheck and move skipUnauthenticated to the top of the test
function, matching the resource scoped skip pattern.

Replace newTestKey and newTestSigningKey with a single
mustNewSshPublicKey in helpers_test.go, using t.Helper and t.Fatalf
instead of discarding the errors. It generates Ed25519 rather than
RSA 1024, which GitHub rejects for being under 2048 bits.
integrations#3637 replaced the Optional plus DiffSuppressFunc etag from integrations#3474 with a
plain Computed attribute and CustomizeDiff: diffETag. Move the signing
key resource over, reverting the block added in 0bf03e6, and regenerate
the docs for both resources so etag is listed as read only.
Order the resource fields as described in ARCHITECTURE.md and place
StateUpgraders directly under SchemaVersion. Store the etag only when
storeEtag is enabled. Ignore the etag in the import tests.
@simonostendorf
simonostendorf force-pushed the feat/github_user_ssh_signing_key branch from 049c9cd to 2c8d98b Compare December 1, 2026 16:35
@simonostendorf

Copy link
Copy Markdown
Author

Thanks for the review. All points are addressed:

  • Resource fields in github_user_ssh_key and github_user_ssh_signing_key follow the documented order.
  • StateUpgraders sits directly under SchemaVersion.
  • The etag is set only when storeEtag is enabled, as in the other resources.
  • The import tests of both resources ignore etag, as github_team does.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add difference of auth and signing keys to github_user_ssh_key [FEAT]: Support SSH signing keys

8 participants