Add github_code_security_configuration resource - #3542
Conversation
|
👋 Hi, and thank you for this contribution! This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can. You can help us prioritize by joining the discussion on open issues and PRs, sharing details on the changes you need, and reviewing other contributions. 🤖 This is an automated message. |
Adds org- and enterprise-level management of GitHub Code Security Configurations, including /defaults and /attach sub-endpoints.
Covers org-level create/update and import, plus enterprise-level create/update/import using the <enterprise_slug>:<id> import format.
Docs regenerated with make generatedocs.
0eb3a73 to
232b4cd
Compare
There was a problem hiding this comment.
Pull request overview
These provider review instructions are being used. Adds organization- and enterprise-level GitHub Code Security Configuration management. Blocking reliability and test issues are noted inline.
Changes:
- Adds full CRUD and import support.
- Registers the resource and adds acceptance tests.
- Adds examples and generated documentation.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
github/resource_github_code_security_configuration.go |
Implements schema, CRUD, import, defaults, and attachment behavior. |
github/resource_github_code_security_configuration_test.go |
Adds organization and enterprise acceptance tests. |
github/provider.go |
Registers the resource. |
examples/resources/code_security_configuration/example_1.tf |
Demonstrates typical usage. |
templates/resources/code_security_configuration.md.tmpl |
Defines documentation content. |
docs/resources/code_security_configuration.md |
Adds generated resource documentation. |
- Migrate CRUD callbacks to CreateContext/ReadContext/UpdateContext/DeleteContext returning diag.Diagnostics, threading the provided context through all API calls - Replace stdlib log with structured tflog logging per DECISIONS.md - Treat 404 on delete as successful deletion - Replace go-github attach helpers with a nil-safe direct request path - Set computed fields directly in Create instead of chaining Read - Convert acceptance tests to ConfigStateChecks/statecheck per DECISIONS.md - Add acceptance coverage for default_for_new_repos (set/change/remove + empty-plan check) and attach_scope (set + idempotent plan) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Thanks for the Copilot review — really useful pass! I've addressed the feedback in 5e15072:
The one comment I didn't action is the
|
- Add every configuration attribute exposed by go-github v89: code_security, secret_protection, dependency_graph_autosubmit_action (+ options), dependabot_delegated_alert_dismissal, code_scanning_default_setup_options, code_scanning_delegated_alert_dismissal, code_scanning_options, secret_scanning_delegated_bypass (+ reviewers), secret_scanning_generic_secrets, secret_scanning_delegated_alert_dismissal, secret_scanning_extended_metadata. - New attributes are Optional-only: sent to the API and tracked in state only when configured, so GitHub keeps its own defaults for unmanaged settings. - Defer delegated bypass reviewers to a follow-up update on create; the API rejects them on the initial create request. - Remove attach_scope. It is a write-only action that cannot be read back and does not fit a declarative resource; attachment can be its own resource later. - Tests: t.Parallel() on the root and every subtest, Terraform-formatted HCL, pre-rendered configs, and a new subtest covering the nested option blocks with create -> update -> empty-plan steps. - Use comma-ok type assertions throughout so the strict lint config passes. - Docs: document the two attribute categories and option blocks, add declarative import examples, regenerate with tfplugindocs. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L2T8JF8uT6KcCtGKjnbvju
|
@deiga fair question, and the honest answer changed today because I pushed a revision (f78a022) to close the gaps. #2664 is stale: go-github v66, legacy CRUD, no docs, no response since January. Versus #3284, this PR now:
I removed I'm not attached to which PR lands. If you'd prefer #3284's two-resource shape, I'm happy to close this and contribute the missing attributes and |
Resolves #2412
Before the change?
After the change?
github_code_security_configurationresource that manages a configuration at either the organization level (default, using the providerowner) or the enterprise level (setenterprise_slug, which isForceNew).dependency_graph_autosubmit_action_options,code_scanning_default_setup_options,code_scanning_options,secret_scanning_delegated_bypass_optionswithreviewers) and the newerdependabot_delegated_alert_dismissalandsecret_scanning_extended_metadatasettings.default_for_new_reposthrough the/defaultsendpoints, with full read-back so drift is detected.tflog, 404 handling on read and delete,ConfigStateChecks/plancheck-based tests witht.Parallel(), tfplugindocs docs and examples.Design notes
Defaultand are always sent. Attributes added since are Optional-only: sent to the API and tracked in state only when present in configuration, so GitHub keeps its own value for anything the user has not chosen to manage. This follows the Optional-only direction from the feat: Add github_organization_security_configuration and github_enterprise_security_configuration resource #3284 review. The docs call out the two categories explicitly.secret_scanning_delegated_bypass_options.reviewerson the initial create request but accepts them on update, so create applies them in a follow-up update call.attach_scopewas removed. Attaching a configuration to repositories is a fire-and-forget action the API cannot read back, which does not fit a declarative resource. It can be added later as its own resource if there is demand.enterprise_slug, which removes roughly 500 lines of duplicated schema and CRUD while covering a superset of its attributes. Happy to align on whichever shape the maintainers prefer.Verification
go build,go vet,gofmt,golangci-lint(default config: 0 issues; strict config on new code: 0 issues in these files) andtfplugindocs validateare clean.default_for_new_reposset → change → remove → empty plan, and enterprise create → update → import.Pull request checklist
Does this introduce a breaking change?