From 065c5e9506f34a0433398c6250b48fb2961f6e64 Mon Sep 17 00:00:00 2001 From: Josh Barker Date: Tue, 14 Sep 2021 16:26:08 +1000 Subject: [PATCH 1/3] feat: add conversation resolution variable on branch protection v3 --- .../resource_github_branch_protection_v3.go | 6 ++ ...source_github_branch_protection_v3_test.go | 76 +++++++++++++++++++ ...ource_github_branch_protection_v3_utils.go | 3 +- .../docs/r/branch_protection_v3.html.markdown | 1 + 4 files changed, 85 insertions(+), 1 deletion(-) diff --git a/github/resource_github_branch_protection_v3.go b/github/resource_github_branch_protection_v3.go index 15bc42e407..9ae08768d5 100644 --- a/github/resource_github_branch_protection_v3.go +++ b/github/resource_github_branch_protection_v3.go @@ -140,6 +140,11 @@ func resourceGithubBranchProtectionV3() *schema.Resource { Optional: true, Default: false, }, + "require_conversation_resolution": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, "etag": { Type: schema.TypeString, Computed: true, @@ -237,6 +242,7 @@ func resourceGithubBranchProtectionV3Read(d *schema.ResourceData, meta interface d.Set("repository", repoName) d.Set("branch", branch) d.Set("enforce_admins", githubProtection.GetEnforceAdmins().Enabled) + d.Set("require_conversation_resolution", githubProtection.GetRequiredConversationResolution().Enabled) if err := flattenAndSetRequiredStatusChecks(d, githubProtection); err != nil { return fmt.Errorf("Error setting required_status_checks: %v", err) diff --git a/github/resource_github_branch_protection_v3_test.go b/github/resource_github_branch_protection_v3_test.go index 2947430713..421cf81881 100644 --- a/github/resource_github_branch_protection_v3_test.go +++ b/github/resource_github_branch_protection_v3_test.go @@ -37,6 +37,81 @@ func TestAccGithubBranchProtectionV3_defaults(t *testing.T) { resource.TestCheckResourceAttr( "github_branch_protection_v3.test", "require_signed_commits", "false", ), + resource.TestCheckResourceAttr( + "github_branch_protection_v3.test", "require_conversation_resolution", "false", + ), + resource.TestCheckResourceAttr( + "github_branch_protection_v3.test", "required_status_checks.#", "0", + ), + resource.TestCheckResourceAttr( + "github_branch_protection_v3.test", "required_pull_request_reviews.#", "0", + ), + resource.TestCheckResourceAttr( + "github_branch_protection_v3.test", "push_restrictions.#", "0", + ), + ) + + testCase := func(t *testing.T, mode string) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { skipUnlessMode(t, mode) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: config, + Check: check, + }, + }, + }) + } + + t.Run("with an anonymous account", func(t *testing.T) { + t.Skip("anonymous account not supported for this operation") + }) + + t.Run("with an individual account", func(t *testing.T) { + t.Skip("individual account not supported for this operation") + }) + + t.Run("with an organization account", func(t *testing.T) { + testCase(t, organization) + }) + + }) +} + +func TestAccGithubBranchProtectionV3_conversation_resolution(t *testing.T) { + + randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum) + + t.Run("configures default settings when empty", func(t *testing.T) { + + config := fmt.Sprintf(` + + resource "github_repository" "test" { + name = "tf-acc-test-%s" + auto_init = true + } + + resource "github_branch_protection_v3" "test" { + + repository = github_repository.test.name + branch = "main" + + require_conversation_resolution = true + } + + `, randomID) + + check := resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr( + "github_branch_protection_v3.test", "branch", "main", + ), + resource.TestCheckResourceAttr( + "github_branch_protection_v3.test", "require_signed_commits", "false", + ), + resource.TestCheckResourceAttr( + "github_branch_protection_v3.test", "require_conversation_resolution", "true", + ), resource.TestCheckResourceAttr( "github_branch_protection_v3.test", "required_status_checks.#", "0", ), @@ -75,6 +150,7 @@ func TestAccGithubBranchProtectionV3_defaults(t *testing.T) { }) } + func TestAccGithubBranchProtectionV3_required_status_checks(t *testing.T) { randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlphaNum) diff --git a/github/resource_github_branch_protection_v3_utils.go b/github/resource_github_branch_protection_v3_utils.go index eee02d437d..bb06916f08 100644 --- a/github/resource_github_branch_protection_v3_utils.go +++ b/github/resource_github_branch_protection_v3_utils.go @@ -13,7 +13,8 @@ import ( func buildProtectionRequest(d *schema.ResourceData) (*github.ProtectionRequest, error) { req := &github.ProtectionRequest{ - EnforceAdmins: d.Get("enforce_admins").(bool), + EnforceAdmins: d.Get("enforce_admins").(bool), + RequiredConversationResolution: github.Bool(d.Get("require_conversation_resolution").(bool)), } rsc, err := expandRequiredStatusChecks(d) diff --git a/website/docs/r/branch_protection_v3.html.markdown b/website/docs/r/branch_protection_v3.html.markdown index d9418ac747..f6bc60d25d 100644 --- a/website/docs/r/branch_protection_v3.html.markdown +++ b/website/docs/r/branch_protection_v3.html.markdown @@ -78,6 +78,7 @@ The following arguments are supported: * `branch` - (Required) The Git branch to protect. * `enforce_admins` - (Optional) Boolean, setting this to `true` enforces status checks for repository administrators. * `require_signed_commits` - (Optional) Boolean, setting this to `true` requires all commits to be signed with GPG. +* `require_conversation_resolution` - (Optional) Boolean, setting this to `true` requires all conversations on code must be resolved before a pull request can be merged. * `required_status_checks` - (Optional) Enforce restrictions for required status checks. See [Required Status Checks](#required-status-checks) below for details. * `required_pull_request_reviews` - (Optional) Enforce restrictions for pull request reviews. See [Required Pull Request Reviews](#required-pull-request-reviews) below for details. * `restrictions` - (Optional) Enforce restrictions for the users and teams that may push to the branch. See [Restrictions](#restrictions) below for details. From 50273c0e6f85e30981d050b8c655c172eab6064c Mon Sep 17 00:00:00 2001 From: Josh Barker Date: Tue, 14 Sep 2021 16:27:16 +1000 Subject: [PATCH 2/3] chore: update githubv4 package --- .gitignore | 3 + go.mod | 2 +- go.sum | 9 +- vendor/github.com/shurcooL/githubv4/enum.go | 162 ++++++++- vendor/github.com/shurcooL/githubv4/input.go | 355 ++++++++++++++++++- vendor/modules.txt | 2 +- 6 files changed, 515 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 93aa5a4d10..ec2e74137b 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,6 @@ website/vendor # Test exclusions !command/test-fixtures/**/*.tfstate !command/test-fixtures/**/.terraform/ + +# do not commit secrets +.env diff --git a/go.mod b/go.mod index 61b1b7e17b..302b9bb39c 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/hashicorp/hcl/v2 v2.3.0 // indirect github.com/hashicorp/terraform-config-inspect v0.0.0-20191212124732-c6ae6269b9d7 // indirect github.com/hashicorp/terraform-plugin-sdk v1.7.0 - github.com/shurcooL/githubv4 v0.0.0-20201206200315-234843c633fa + github.com/shurcooL/githubv4 v0.0.0-20210725200734-83ba7b4c9228 github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f // indirect golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d diff --git a/go.sum b/go.sum index 4767938ca9..16fa5a0c12 100644 --- a/go.sum +++ b/go.sum @@ -153,15 +153,10 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Z github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-github/v38 v36.0.0 h1:ndCzM616/oijwufI7nBRa+5eZHLldT+4yIB68ib5ogs= -github.com/google/go-github/v38 v36.0.0/go.mod h1:LFlKC047IOqiglRGNqNb9s/iAPTnnjtlshm+bxp+kwk= -github.com/google/go-github/v38 v37.0.0 h1:rCspN8/6kB1BAJWZfuafvHhyfIo5fkAulaP/3bOQ/tM= -github.com/google/go-github/v38 v37.0.0/go.mod h1:LM7in3NmXDrX58GbEHy7FtNLbI2JijX93RnMKvWG3m4= github.com/google/go-github/v38 v38.1.0 h1:C6h1FkaITcBFK7gAmq4eFzt6gbhEhk7L5z6R3Uva+po= github.com/google/go-github/v38 v38.1.0/go.mod h1:cStvrz/7nFr0FoENgG6GLbp53WaelXucT+BBz/3VKx4= github.com/google/go-github/v39 v39.0.0 h1:pygGA5ySwxEez1N39GnDauD0PaWWuGgayudyZAc941s= @@ -369,8 +364,8 @@ github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shirou/gopsutil v0.0.0-20190901111213-e4ec7b275ada/go.mod h1:WWnYX4lzhCH5h/3YBfyVA3VbLYjlMZZAQcW9ojMexNc= github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= -github.com/shurcooL/githubv4 v0.0.0-20201206200315-234843c633fa h1:jozR3igKlnYCj9IVHOVump59bp07oIRoLQ/CcjMYIUA= -github.com/shurcooL/githubv4 v0.0.0-20201206200315-234843c633fa/go.mod h1:hAF0iLZy4td2EX+/8Tw+4nodhlMrwN3HupfaXj3zkGo= +github.com/shurcooL/githubv4 v0.0.0-20210725200734-83ba7b4c9228 h1:N5B+JgvM/DVYIxreItPJMM3yWrNO/GB2q4nESrtBisM= +github.com/shurcooL/githubv4 v0.0.0-20210725200734-83ba7b4c9228/go.mod h1:hAF0iLZy4td2EX+/8Tw+4nodhlMrwN3HupfaXj3zkGo= github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e h1:MZM7FHLqUHYI0Y/mQAt3d2aYa0SiNms/hFqC9qJYolM= github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041 h1:llrF3Fs4018ePo4+G/HV/uQUqEI1HMDjCeOf2V6puPc= diff --git a/vendor/github.com/shurcooL/githubv4/enum.go b/vendor/github.com/shurcooL/githubv4/enum.go index c8674a99cf..485aacfcdf 100644 --- a/vendor/github.com/shurcooL/githubv4/enum.go +++ b/vendor/github.com/shurcooL/githubv4/enum.go @@ -53,6 +53,8 @@ const ( CheckStatusStateQueued CheckStatusState = "QUEUED" // The check suite or run has been queued. CheckStatusStateInProgress CheckStatusState = "IN_PROGRESS" // The check suite or run is in progress. CheckStatusStateCompleted CheckStatusState = "COMPLETED" // The check suite or run has been completed. + CheckStatusStateWaiting CheckStatusState = "WAITING" // The check suite or run is in waiting state. + CheckStatusStatePending CheckStatusState = "PENDING" // The check suite or run is in pending state. CheckStatusStateRequested CheckStatusState = "REQUESTED" // The check suite or run has been requested. ) @@ -104,6 +106,18 @@ const ( CommitContributionOrderFieldCommitCount CommitContributionOrderField = "COMMIT_COUNT" // Order commit contributions by how many commits they represent. ) +// ContributionLevel represents varying levels of contributions from none to many. +type ContributionLevel string + +// Varying levels of contributions from none to many. +const ( + ContributionLevelNone ContributionLevel = "NONE" // No contributions occurred. + ContributionLevelFirstQuartile ContributionLevel = "FIRST_QUARTILE" // Lowest 25% of days of contributions. + ContributionLevelSecondQuartile ContributionLevel = "SECOND_QUARTILE" // Second lowest 25% of days of contributions. More contributions than the first quartile. + ContributionLevelThirdQuartile ContributionLevel = "THIRD_QUARTILE" // Second highest 25% of days of contributions. More contributions than second quartile, less than the fourth quartile. + ContributionLevelFourthQuartile ContributionLevel = "FOURTH_QUARTILE" // Highest 25% of days of contributions. More contributions than the third quartile. +) + // DefaultRepositoryPermissionField represents the possible default permissions for repositories. type DefaultRepositoryPermissionField string @@ -123,6 +137,24 @@ const ( DeploymentOrderFieldCreatedAt DeploymentOrderField = "CREATED_AT" // Order collection by creation time. ) +// DeploymentProtectionRuleType represents the possible protection rule types. +type DeploymentProtectionRuleType string + +// The possible protection rule types. +const ( + DeploymentProtectionRuleTypeRequiredReviewers DeploymentProtectionRuleType = "REQUIRED_REVIEWERS" // Required reviewers. + DeploymentProtectionRuleTypeWaitTimer DeploymentProtectionRuleType = "WAIT_TIMER" // Wait timer. +) + +// DeploymentReviewState represents the possible states for a deployment review. +type DeploymentReviewState string + +// The possible states for a deployment review. +const ( + DeploymentReviewStateApproved DeploymentReviewState = "APPROVED" // The deployment was approved. + DeploymentReviewStateRejected DeploymentReviewState = "REJECTED" // The deployment was rejected. +) + // DeploymentState represents the possible states in which a deployment can be. type DeploymentState string @@ -152,6 +184,7 @@ const ( DeploymentStatusStateError DeploymentStatusState = "ERROR" // The deployment experienced an error. DeploymentStatusStateQueued DeploymentStatusState = "QUEUED" // The deployment is queued. DeploymentStatusStateInProgress DeploymentStatusState = "IN_PROGRESS" // The deployment is in progress. + DeploymentStatusStateWaiting DeploymentStatusState = "WAITING" // The deployment is waiting. ) // DiffSide represents the possible sides of a diff. @@ -163,6 +196,15 @@ const ( DiffSideRight DiffSide = "RIGHT" // The right side of the diff. ) +// DiscussionOrderField represents properties by which discussion connections can be ordered. +type DiscussionOrderField string + +// Properties by which discussion connections can be ordered. +const ( + DiscussionOrderFieldCreatedAt DiscussionOrderField = "CREATED_AT" // Order discussions by creation time. + DiscussionOrderFieldUpdatedAt DiscussionOrderField = "UPDATED_AT" // Order discussions by most recent modification time. +) + // EnterpriseAdministratorInvitationOrderField represents properties by which enterprise administrator invitation connections can be ordered. type EnterpriseAdministratorInvitationOrderField string @@ -370,7 +412,7 @@ const ( GitSignatureStateNotSigningKey GitSignatureState = "NOT_SIGNING_KEY" // The usage flags for the key that signed this don't allow signing. GitSignatureStateExpiredKey GitSignatureState = "EXPIRED_KEY" // Signing key expired. GitSignatureStateOcspPending GitSignatureState = "OCSP_PENDING" // Valid signature, pending certificate revocation checking. - GitSignatureStateOcspError GitSignatureState = "OCSP_ERROR" // Valid siganture, though certificate revocation check failed. + GitSignatureStateOcspError GitSignatureState = "OCSP_ERROR" // Valid signature, though certificate revocation check failed. GitSignatureStateBadCert GitSignatureState = "BAD_CERT" // The signing certificate or its chain could not be verified. GitSignatureStateOcspRevoked GitSignatureState = "OCSP_REVOKED" // One or more certificates in chain has been revoked. ) @@ -403,6 +445,15 @@ const ( IpAllowListEntryOrderFieldAllowListValue IpAllowListEntryOrderField = "ALLOW_LIST_VALUE" // Order IP allow list entries by the allow list value. ) +// IpAllowListForInstalledAppsEnabledSettingValue represents the possible values for the IP allow list configuration for installed GitHub Apps setting. +type IpAllowListForInstalledAppsEnabledSettingValue string + +// The possible values for the IP allow list configuration for installed GitHub Apps setting. +const ( + IpAllowListForInstalledAppsEnabledSettingValueEnabled IpAllowListForInstalledAppsEnabledSettingValue = "ENABLED" // The setting is enabled for the owner. + IpAllowListForInstalledAppsEnabledSettingValueDisabled IpAllowListForInstalledAppsEnabledSettingValue = "DISABLED" // The setting is disabled for the owner. +) + // IssueCommentOrderField represents properties by which issue comment connections can be ordered. type IssueCommentOrderField string @@ -525,6 +576,15 @@ const ( MilestoneStateClosed MilestoneState = "CLOSED" // A milestone that has been closed. ) +// NotificationRestrictionSettingValue represents the possible values for the notification restriction setting. +type NotificationRestrictionSettingValue string + +// The possible values for the notification restriction setting. +const ( + NotificationRestrictionSettingValueEnabled NotificationRestrictionSettingValue = "ENABLED" // The setting is enabled for the owner. + NotificationRestrictionSettingValueDisabled NotificationRestrictionSettingValue = "DISABLED" // The setting is disabled for the owner. +) + // OauthApplicationCreateAuditEntryState represents the state of an OAuth Application when it was created. type OauthApplicationCreateAuditEntryState string @@ -768,6 +828,31 @@ const ( PinnableItemTypeTeam PinnableItemType = "TEAM" // A team. ) +// PinnedDiscussionGradient represents preconfigured gradients that may be used to style discussions pinned within a repository. +type PinnedDiscussionGradient string + +// Preconfigured gradients that may be used to style discussions pinned within a repository. +const ( + PinnedDiscussionGradientRedOrange PinnedDiscussionGradient = "RED_ORANGE" // A gradient of red to orange. + PinnedDiscussionGradientBlueMint PinnedDiscussionGradient = "BLUE_MINT" // A gradient of blue to mint. + PinnedDiscussionGradientBluePurple PinnedDiscussionGradient = "BLUE_PURPLE" // A gradient of blue to purple. + PinnedDiscussionGradientPinkBlue PinnedDiscussionGradient = "PINK_BLUE" // A gradient of pink to blue. + PinnedDiscussionGradientPurpleCoral PinnedDiscussionGradient = "PURPLE_CORAL" // A gradient of purple to coral. +) + +// PinnedDiscussionPattern represents preconfigured background patterns that may be used to style discussions pinned within a repository. +type PinnedDiscussionPattern string + +// Preconfigured background patterns that may be used to style discussions pinned within a repository. +const ( + PinnedDiscussionPatternDotFill PinnedDiscussionPattern = "DOT_FILL" // A solid dot pattern. + PinnedDiscussionPatternPlus PinnedDiscussionPattern = "PLUS" // A plus sign pattern. + PinnedDiscussionPatternZap PinnedDiscussionPattern = "ZAP" // A lightning bolt pattern. + PinnedDiscussionPatternChevronUp PinnedDiscussionPattern = "CHEVRON_UP" // An upward-facing chevron pattern. + PinnedDiscussionPatternDot PinnedDiscussionPattern = "DOT" // A hollow dot pattern. + PinnedDiscussionPatternHeartFill PinnedDiscussionPattern = "HEART_FILL" // A heart pattern. +) + // ProjectCardArchivedState represents the possible archived states of a project card. type ProjectCardArchivedState string @@ -910,6 +995,10 @@ const ( PullRequestTimelineItemsItemTypePullRequestRevisionMarker PullRequestTimelineItemsItemType = "PULL_REQUEST_REVISION_MARKER" // Represents the latest point in the pull request timeline for which the viewer has seen the pull request's commits. PullRequestTimelineItemsItemTypeAutomaticBaseChangeFailedEvent PullRequestTimelineItemsItemType = "AUTOMATIC_BASE_CHANGE_FAILED_EVENT" // Represents a 'automatic_base_change_failed' event on a given pull request. PullRequestTimelineItemsItemTypeAutomaticBaseChangeSucceededEvent PullRequestTimelineItemsItemType = "AUTOMATIC_BASE_CHANGE_SUCCEEDED_EVENT" // Represents a 'automatic_base_change_succeeded' event on a given pull request. + PullRequestTimelineItemsItemTypeAutoMergeDisabledEvent PullRequestTimelineItemsItemType = "AUTO_MERGE_DISABLED_EVENT" // Represents a 'auto_merge_disabled' event on a given pull request. + PullRequestTimelineItemsItemTypeAutoMergeEnabledEvent PullRequestTimelineItemsItemType = "AUTO_MERGE_ENABLED_EVENT" // Represents a 'auto_merge_enabled' event on a given pull request. + PullRequestTimelineItemsItemTypeAutoRebaseEnabledEvent PullRequestTimelineItemsItemType = "AUTO_REBASE_ENABLED_EVENT" // Represents a 'auto_rebase_enabled' event on a given pull request. + PullRequestTimelineItemsItemTypeAutoSquashEnabledEvent PullRequestTimelineItemsItemType = "AUTO_SQUASH_ENABLED_EVENT" // Represents a 'auto_squash_enabled' event on a given pull request. PullRequestTimelineItemsItemTypeBaseRefChangedEvent PullRequestTimelineItemsItemType = "BASE_REF_CHANGED_EVENT" // Represents a 'base_ref_changed' event on a given issue or pull request. PullRequestTimelineItemsItemTypeBaseRefForcePushedEvent PullRequestTimelineItemsItemType = "BASE_REF_FORCE_PUSHED_EVENT" // Represents a 'base_ref_force_pushed' event on a given pull request. PullRequestTimelineItemsItemTypeBaseRefDeletedEvent PullRequestTimelineItemsItemType = "BASE_REF_DELETED_EVENT" // Represents a 'base_ref_deleted' event on a given pull request. @@ -1215,6 +1304,8 @@ const ( RequestableCheckStatusStateQueued RequestableCheckStatusState = "QUEUED" // The check suite or run has been queued. RequestableCheckStatusStateInProgress RequestableCheckStatusState = "IN_PROGRESS" // The check suite or run is in progress. RequestableCheckStatusStateCompleted RequestableCheckStatusState = "COMPLETED" // The check suite or run has been completed. + RequestableCheckStatusStateWaiting RequestableCheckStatusState = "WAITING" // The check suite or run is in waiting state. + RequestableCheckStatusStatePending RequestableCheckStatusState = "PENDING" // The check suite or run is in pending state. ) // SamlDigestAlgorithm represents the possible digest algorithms used to sign SAML requests for an identity provider. @@ -1255,6 +1346,7 @@ const ( SearchTypeIssue SearchType = "ISSUE" // Returns results matching issues in repositories. SearchTypeRepository SearchType = "REPOSITORY" // Returns results matching repositories. SearchTypeUser SearchType = "USER" // Returns results matching users and organizations on GitHub. + SearchTypeDiscussion SearchType = "DISCUSSION" // Returns matching discussions in repositories. ) // SecurityAdvisoryEcosystem represents the possible ecosystems of a security vulnerability's package. @@ -1262,12 +1354,14 @@ type SecurityAdvisoryEcosystem string // The possible ecosystems of a security vulnerability's package. const ( - SecurityAdvisoryEcosystemRubygems SecurityAdvisoryEcosystem = "RUBYGEMS" // Ruby gems hosted at RubyGems.org. - SecurityAdvisoryEcosystemNpm SecurityAdvisoryEcosystem = "NPM" // JavaScript packages hosted at npmjs.com. - SecurityAdvisoryEcosystemPip SecurityAdvisoryEcosystem = "PIP" // Python packages hosted at PyPI.org. + SecurityAdvisoryEcosystemComposer SecurityAdvisoryEcosystem = "COMPOSER" // PHP packages hosted at packagist.org. + SecurityAdvisoryEcosystemGo SecurityAdvisoryEcosystem = "GO" // Go modules. SecurityAdvisoryEcosystemMaven SecurityAdvisoryEcosystem = "MAVEN" // Java artifacts hosted at the Maven central repository. + SecurityAdvisoryEcosystemNpm SecurityAdvisoryEcosystem = "NPM" // JavaScript packages hosted at npmjs.com. SecurityAdvisoryEcosystemNuget SecurityAdvisoryEcosystem = "NUGET" // .NET packages hosted at the NuGet Gallery. - SecurityAdvisoryEcosystemComposer SecurityAdvisoryEcosystem = "COMPOSER" // PHP packages hosted at packagist.org. + SecurityAdvisoryEcosystemPip SecurityAdvisoryEcosystem = "PIP" // Python packages hosted at PyPI.org. + SecurityAdvisoryEcosystemRubygems SecurityAdvisoryEcosystem = "RUBYGEMS" // Ruby gems hosted at RubyGems.org. + SecurityAdvisoryEcosystemOther SecurityAdvisoryEcosystem = "OTHER" // Applications, runtimes, operating systems and other kinds of software. ) // SecurityAdvisoryIdentifierType represents identifier formats available for advisories. @@ -1307,6 +1401,55 @@ const ( SecurityVulnerabilityOrderFieldUpdatedAt SecurityVulnerabilityOrderField = "UPDATED_AT" // Order vulnerability by update time. ) +// SponsorableOrderField represents properties by which sponsorable connections can be ordered. +type SponsorableOrderField string + +// Properties by which sponsorable connections can be ordered. +const ( + SponsorableOrderFieldLogin SponsorableOrderField = "LOGIN" // Order sponsorable entities by login (username). +) + +// SponsorsActivityAction represents the possible actions that GitHub Sponsors activities can represent. +type SponsorsActivityAction string + +// The possible actions that GitHub Sponsors activities can represent. +const ( + SponsorsActivityActionNewSponsorship SponsorsActivityAction = "NEW_SPONSORSHIP" // The activity was starting a sponsorship. + SponsorsActivityActionCancelledSponsorship SponsorsActivityAction = "CANCELLED_SPONSORSHIP" // The activity was cancelling a sponsorship. + SponsorsActivityActionTierChange SponsorsActivityAction = "TIER_CHANGE" // The activity was changing the sponsorship tier, either directly by the sponsor or by a scheduled/pending change. + SponsorsActivityActionRefund SponsorsActivityAction = "REFUND" // The activity was funds being refunded to the sponsor or GitHub. + SponsorsActivityActionPendingChange SponsorsActivityAction = "PENDING_CHANGE" // The activity was scheduling a downgrade or cancellation. + SponsorsActivityActionSponsorMatchDisabled SponsorsActivityAction = "SPONSOR_MATCH_DISABLED" // The activity was disabling matching for a previously matched sponsorship. +) + +// SponsorsActivityOrderField represents properties by which GitHub Sponsors activity connections can be ordered. +type SponsorsActivityOrderField string + +// Properties by which GitHub Sponsors activity connections can be ordered. +const ( + SponsorsActivityOrderFieldTimestamp SponsorsActivityOrderField = "TIMESTAMP" // Order activities by when they happened. +) + +// SponsorsActivityPeriod represents the possible time periods for which Sponsors activities can be requested. +type SponsorsActivityPeriod string + +// The possible time periods for which Sponsors activities can be requested. +const ( + SponsorsActivityPeriodDay SponsorsActivityPeriod = "DAY" // The previous calendar day. + SponsorsActivityPeriodWeek SponsorsActivityPeriod = "WEEK" // The previous seven days. + SponsorsActivityPeriodMonth SponsorsActivityPeriod = "MONTH" // The previous thirty days. + SponsorsActivityPeriodAll SponsorsActivityPeriod = "ALL" // Don't restrict the activity to any date range, include all activity. +) + +// SponsorsGoalKind represents the different kinds of goals a GitHub Sponsors member can have. +type SponsorsGoalKind string + +// The different kinds of goals a GitHub Sponsors member can have. +const ( + SponsorsGoalKindTotalSponsorsCount SponsorsGoalKind = "TOTAL_SPONSORS_COUNT" // The goal is about reaching a certain number of sponsors. + SponsorsGoalKindMonthlySponsorshipAmount SponsorsGoalKind = "MONTHLY_SPONSORSHIP_AMOUNT" // The goal is about getting a certain dollar amount from sponsorships each month. +) + // SponsorsTierOrderField represents properties by which Sponsors tiers connections can be ordered. type SponsorsTierOrderField string @@ -1476,3 +1619,12 @@ type UserStatusOrderField string const ( UserStatusOrderFieldUpdatedAt UserStatusOrderField = "UPDATED_AT" // Order user statuses by when they were updated. ) + +// VerifiableDomainOrderField represents properties by which verifiable domain connections can be ordered. +type VerifiableDomainOrderField string + +// Properties by which verifiable domain connections can be ordered. +const ( + VerifiableDomainOrderFieldDomain VerifiableDomainOrderField = "DOMAIN" // Order verifiable domains by the domain name. + VerifiableDomainOrderFieldCreatedAt VerifiableDomainOrderField = "CREATED_AT" // Order verifiable domains by their creation date. +) diff --git a/vendor/github.com/shurcooL/githubv4/input.go b/vendor/github.com/shurcooL/githubv4/input.go index 550d544e98..266eeca09e 100644 --- a/vendor/github.com/shurcooL/githubv4/input.go +++ b/vendor/github.com/shurcooL/githubv4/input.go @@ -4,7 +4,7 @@ package githubv4 // Input represents one of the Input structs: // -// AcceptEnterpriseAdministratorInvitationInput, AcceptTopicSuggestionInput, AddAssigneesToAssignableInput, AddCommentInput, AddLabelsToLabelableInput, AddProjectCardInput, AddProjectColumnInput, AddPullRequestReviewCommentInput, AddPullRequestReviewInput, AddPullRequestReviewThreadInput, AddReactionInput, AddStarInput, ArchiveRepositoryInput, AuditLogOrder, CancelEnterpriseAdminInvitationInput, ChangeUserStatusInput, CheckAnnotationData, CheckAnnotationRange, CheckRunAction, CheckRunFilter, CheckRunOutput, CheckRunOutputImage, CheckSuiteAutoTriggerPreference, CheckSuiteFilter, ClearLabelsFromLabelableInput, CloneProjectInput, CloneTemplateRepositoryInput, CloseIssueInput, ClosePullRequestInput, CommitAuthor, CommitContributionOrder, ContributionOrder, ConvertProjectCardNoteToIssueInput, CreateBranchProtectionRuleInput, CreateCheckRunInput, CreateCheckSuiteInput, CreateEnterpriseOrganizationInput, CreateIpAllowListEntryInput, CreateIssueInput, CreateProjectInput, CreatePullRequestInput, CreateRefInput, CreateRepositoryInput, CreateTeamDiscussionCommentInput, CreateTeamDiscussionInput, DeclineTopicSuggestionInput, DeleteBranchProtectionRuleInput, DeleteDeploymentInput, DeleteIpAllowListEntryInput, DeleteIssueCommentInput, DeleteIssueInput, DeleteProjectCardInput, DeleteProjectColumnInput, DeleteProjectInput, DeletePullRequestReviewCommentInput, DeletePullRequestReviewInput, DeleteRefInput, DeleteTeamDiscussionCommentInput, DeleteTeamDiscussionInput, DeploymentOrder, DismissPullRequestReviewInput, DraftPullRequestReviewComment, DraftPullRequestReviewThread, EnterpriseAdministratorInvitationOrder, EnterpriseMemberOrder, EnterpriseServerInstallationOrder, EnterpriseServerUserAccountEmailOrder, EnterpriseServerUserAccountOrder, EnterpriseServerUserAccountsUploadOrder, FollowUserInput, GistOrder, InviteEnterpriseAdminInput, IpAllowListEntryOrder, IssueCommentOrder, IssueFilters, IssueOrder, LabelOrder, LanguageOrder, LinkRepositoryToProjectInput, LockLockableInput, MarkFileAsViewedInput, MarkPullRequestReadyForReviewInput, MergeBranchInput, MergePullRequestInput, MilestoneOrder, MinimizeCommentInput, MoveProjectCardInput, MoveProjectColumnInput, OrganizationOrder, PackageFileOrder, PackageOrder, PackageVersionOrder, ProjectOrder, PullRequestOrder, ReactionOrder, RefOrder, RegenerateEnterpriseIdentityProviderRecoveryCodesInput, ReleaseOrder, RemoveAssigneesFromAssignableInput, RemoveEnterpriseAdminInput, RemoveEnterpriseIdentityProviderInput, RemoveEnterpriseOrganizationInput, RemoveLabelsFromLabelableInput, RemoveOutsideCollaboratorInput, RemoveReactionInput, RemoveStarInput, ReopenIssueInput, ReopenPullRequestInput, RepositoryInvitationOrder, RepositoryOrder, RequestReviewsInput, RerequestCheckSuiteInput, ResolveReviewThreadInput, SavedReplyOrder, SecurityAdvisoryIdentifierFilter, SecurityAdvisoryOrder, SecurityVulnerabilityOrder, SetEnterpriseIdentityProviderInput, SetOrganizationInteractionLimitInput, SetRepositoryInteractionLimitInput, SetUserInteractionLimitInput, SponsorsTierOrder, SponsorshipOrder, StarOrder, SubmitPullRequestReviewInput, TeamDiscussionCommentOrder, TeamDiscussionOrder, TeamMemberOrder, TeamOrder, TeamRepositoryOrder, TransferIssueInput, UnarchiveRepositoryInput, UnfollowUserInput, UnlinkRepositoryFromProjectInput, UnlockLockableInput, UnmarkFileAsViewedInput, UnmarkIssueAsDuplicateInput, UnminimizeCommentInput, UnresolveReviewThreadInput, UpdateBranchProtectionRuleInput, UpdateCheckRunInput, UpdateCheckSuitePreferencesInput, UpdateEnterpriseAdministratorRoleInput, UpdateEnterpriseAllowPrivateRepositoryForkingSettingInput, UpdateEnterpriseDefaultRepositoryPermissionSettingInput, UpdateEnterpriseMembersCanChangeRepositoryVisibilitySettingInput, UpdateEnterpriseMembersCanCreateRepositoriesSettingInput, UpdateEnterpriseMembersCanDeleteIssuesSettingInput, UpdateEnterpriseMembersCanDeleteRepositoriesSettingInput, UpdateEnterpriseMembersCanInviteCollaboratorsSettingInput, UpdateEnterpriseMembersCanMakePurchasesSettingInput, UpdateEnterpriseMembersCanUpdateProtectedBranchesSettingInput, UpdateEnterpriseMembersCanViewDependencyInsightsSettingInput, UpdateEnterpriseOrganizationProjectsSettingInput, UpdateEnterpriseProfileInput, UpdateEnterpriseRepositoryProjectsSettingInput, UpdateEnterpriseTeamDiscussionsSettingInput, UpdateEnterpriseTwoFactorAuthenticationRequiredSettingInput, UpdateIpAllowListEnabledSettingInput, UpdateIpAllowListEntryInput, UpdateIssueCommentInput, UpdateIssueInput, UpdateProjectCardInput, UpdateProjectColumnInput, UpdateProjectInput, UpdatePullRequestInput, UpdatePullRequestReviewCommentInput, UpdatePullRequestReviewInput, UpdateRefInput, UpdateRepositoryInput, UpdateSubscriptionInput, UpdateTeamDiscussionCommentInput, UpdateTeamDiscussionInput, UpdateTopicsInput, UserStatusOrder. +// AcceptEnterpriseAdministratorInvitationInput, AcceptTopicSuggestionInput, AddAssigneesToAssignableInput, AddCommentInput, AddDiscussionCommentInput, AddEnterpriseSupportEntitlementInput, AddLabelsToLabelableInput, AddProjectCardInput, AddProjectColumnInput, AddPullRequestReviewCommentInput, AddPullRequestReviewInput, AddPullRequestReviewThreadInput, AddReactionInput, AddStarInput, AddUpvoteInput, AddVerifiableDomainInput, ApproveDeploymentsInput, ApproveVerifiableDomainInput, ArchiveRepositoryInput, AuditLogOrder, CancelEnterpriseAdminInvitationInput, ChangeUserStatusInput, CheckAnnotationData, CheckAnnotationRange, CheckRunAction, CheckRunFilter, CheckRunOutput, CheckRunOutputImage, CheckSuiteAutoTriggerPreference, CheckSuiteFilter, ClearLabelsFromLabelableInput, CloneProjectInput, CloneTemplateRepositoryInput, CloseIssueInput, ClosePullRequestInput, CommitAuthor, CommitContributionOrder, ContributionOrder, ConvertProjectCardNoteToIssueInput, ConvertPullRequestToDraftInput, CreateBranchProtectionRuleInput, CreateCheckRunInput, CreateCheckSuiteInput, CreateDiscussionInput, CreateEnterpriseOrganizationInput, CreateEnvironmentInput, CreateIpAllowListEntryInput, CreateIssueInput, CreateProjectInput, CreatePullRequestInput, CreateRefInput, CreateRepositoryInput, CreateTeamDiscussionCommentInput, CreateTeamDiscussionInput, DeclineTopicSuggestionInput, DeleteBranchProtectionRuleInput, DeleteDeploymentInput, DeleteDiscussionCommentInput, DeleteDiscussionInput, DeleteEnvironmentInput, DeleteIpAllowListEntryInput, DeleteIssueCommentInput, DeleteIssueInput, DeleteProjectCardInput, DeleteProjectColumnInput, DeleteProjectInput, DeletePullRequestReviewCommentInput, DeletePullRequestReviewInput, DeleteRefInput, DeleteTeamDiscussionCommentInput, DeleteTeamDiscussionInput, DeleteVerifiableDomainInput, DeploymentOrder, DisablePullRequestAutoMergeInput, DiscussionOrder, DismissPullRequestReviewInput, DraftPullRequestReviewComment, DraftPullRequestReviewThread, EnablePullRequestAutoMergeInput, EnterpriseAdministratorInvitationOrder, EnterpriseMemberOrder, EnterpriseServerInstallationOrder, EnterpriseServerUserAccountEmailOrder, EnterpriseServerUserAccountOrder, EnterpriseServerUserAccountsUploadOrder, FollowUserInput, GistOrder, InviteEnterpriseAdminInput, IpAllowListEntryOrder, IssueCommentOrder, IssueFilters, IssueOrder, LabelOrder, LanguageOrder, LinkRepositoryToProjectInput, LockLockableInput, MarkDiscussionCommentAsAnswerInput, MarkFileAsViewedInput, MarkPullRequestReadyForReviewInput, MergeBranchInput, MergePullRequestInput, MilestoneOrder, MinimizeCommentInput, MoveProjectCardInput, MoveProjectColumnInput, OrganizationOrder, PackageFileOrder, PackageOrder, PackageVersionOrder, PinIssueInput, ProjectOrder, PullRequestOrder, ReactionOrder, RefOrder, RegenerateEnterpriseIdentityProviderRecoveryCodesInput, RegenerateVerifiableDomainTokenInput, RejectDeploymentsInput, ReleaseOrder, RemoveAssigneesFromAssignableInput, RemoveEnterpriseAdminInput, RemoveEnterpriseIdentityProviderInput, RemoveEnterpriseOrganizationInput, RemoveEnterpriseSupportEntitlementInput, RemoveLabelsFromLabelableInput, RemoveOutsideCollaboratorInput, RemoveReactionInput, RemoveStarInput, RemoveUpvoteInput, ReopenIssueInput, ReopenPullRequestInput, RepositoryInvitationOrder, RepositoryOrder, RequestReviewsInput, RerequestCheckSuiteInput, ResolveReviewThreadInput, SavedReplyOrder, SecurityAdvisoryIdentifierFilter, SecurityAdvisoryOrder, SecurityVulnerabilityOrder, SetEnterpriseIdentityProviderInput, SetOrganizationInteractionLimitInput, SetRepositoryInteractionLimitInput, SetUserInteractionLimitInput, SponsorableOrder, SponsorsActivityOrder, SponsorsTierOrder, SponsorshipOrder, StarOrder, SubmitPullRequestReviewInput, TeamDiscussionCommentOrder, TeamDiscussionOrder, TeamMemberOrder, TeamOrder, TeamRepositoryOrder, TransferIssueInput, UnarchiveRepositoryInput, UnfollowUserInput, UnlinkRepositoryFromProjectInput, UnlockLockableInput, UnmarkDiscussionCommentAsAnswerInput, UnmarkFileAsViewedInput, UnmarkIssueAsDuplicateInput, UnminimizeCommentInput, UnpinIssueInput, UnresolveReviewThreadInput, UpdateBranchProtectionRuleInput, UpdateCheckRunInput, UpdateCheckSuitePreferencesInput, UpdateDiscussionCommentInput, UpdateDiscussionInput, UpdateEnterpriseAdministratorRoleInput, UpdateEnterpriseAllowPrivateRepositoryForkingSettingInput, UpdateEnterpriseDefaultRepositoryPermissionSettingInput, UpdateEnterpriseMembersCanChangeRepositoryVisibilitySettingInput, UpdateEnterpriseMembersCanCreateRepositoriesSettingInput, UpdateEnterpriseMembersCanDeleteIssuesSettingInput, UpdateEnterpriseMembersCanDeleteRepositoriesSettingInput, UpdateEnterpriseMembersCanInviteCollaboratorsSettingInput, UpdateEnterpriseMembersCanMakePurchasesSettingInput, UpdateEnterpriseMembersCanUpdateProtectedBranchesSettingInput, UpdateEnterpriseMembersCanViewDependencyInsightsSettingInput, UpdateEnterpriseOrganizationProjectsSettingInput, UpdateEnterpriseProfileInput, UpdateEnterpriseRepositoryProjectsSettingInput, UpdateEnterpriseTeamDiscussionsSettingInput, UpdateEnterpriseTwoFactorAuthenticationRequiredSettingInput, UpdateEnvironmentInput, UpdateIpAllowListEnabledSettingInput, UpdateIpAllowListEntryInput, UpdateIpAllowListForInstalledAppsEnabledSettingInput, UpdateIssueCommentInput, UpdateIssueInput, UpdateNotificationRestrictionSettingInput, UpdateProjectCardInput, UpdateProjectColumnInput, UpdateProjectInput, UpdatePullRequestInput, UpdatePullRequestReviewCommentInput, UpdatePullRequestReviewInput, UpdateRefInput, UpdateRepositoryInput, UpdateSubscriptionInput, UpdateTeamDiscussionCommentInput, UpdateTeamDiscussionInput, UpdateTopicsInput, UserStatusOrder, VerifiableDomainOrder, VerifyVerifiableDomainInput. type Input interface{} // AcceptEnterpriseAdministratorInvitationInput is an autogenerated input type of AcceptEnterpriseAdministratorInvitation. @@ -49,6 +49,30 @@ type AddCommentInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// AddDiscussionCommentInput is an autogenerated input type of AddDiscussionComment. +type AddDiscussionCommentInput struct { + // The Node ID of the discussion to comment on. (Required.) + DiscussionID ID `json:"discussionId"` + // The contents of the comment. (Required.) + Body String `json:"body"` + + // The Node ID of the discussion comment within this discussion to reply to. (Optional.) + ReplyToID *ID `json:"replyToId,omitempty"` + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + +// AddEnterpriseSupportEntitlementInput is an autogenerated input type of AddEnterpriseSupportEntitlement. +type AddEnterpriseSupportEntitlementInput struct { + // The ID of the Enterprise which the admin belongs to. (Required.) + EnterpriseID ID `json:"enterpriseId"` + // The login of a member who will receive the support entitlement. (Required.) + Login String `json:"login"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // AddLabelsToLabelableInput is an autogenerated input type of AddLabelsToLabelable. type AddLabelsToLabelableInput struct { // The id of the labelable object to add labels to. (Required.) @@ -167,6 +191,48 @@ type AddStarInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// AddUpvoteInput is an autogenerated input type of AddUpvote. +type AddUpvoteInput struct { + // The Node ID of the discussion or comment to upvote. (Required.) + SubjectID ID `json:"subjectId"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + +// AddVerifiableDomainInput is an autogenerated input type of AddVerifiableDomain. +type AddVerifiableDomainInput struct { + // The ID of the owner to add the domain to. (Required.) + OwnerID ID `json:"ownerId"` + // The URL of the domain. (Required.) + Domain URI `json:"domain"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + +// ApproveDeploymentsInput is an autogenerated input type of ApproveDeployments. +type ApproveDeploymentsInput struct { + // The node ID of the workflow run containing the pending deployments. (Required.) + WorkflowRunID ID `json:"workflowRunId"` + // The ids of environments to reject deployments. (Required.) + EnvironmentIDs []ID `json:"environmentIds"` + + // Optional comment for approving deployments. (Optional.) + Comment *String `json:"comment,omitempty"` + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + +// ApproveVerifiableDomainInput is an autogenerated input type of ApproveVerifiableDomain. +type ApproveVerifiableDomainInput struct { + // The ID of the verifiable domain to approve. (Required.) + ID ID `json:"id"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // ArchiveRepositoryInput is an autogenerated input type of ArchiveRepository. type ArchiveRepositoryInput struct { // The ID of the repository to mark as archived. (Required.) @@ -410,6 +476,15 @@ type ConvertProjectCardNoteToIssueInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// ConvertPullRequestToDraftInput is an autogenerated input type of ConvertPullRequestToDraft. +type ConvertPullRequestToDraftInput struct { + // ID of the pull request to convert to draft. (Required.) + PullRequestID ID `json:"pullRequestId"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // CreateBranchProtectionRuleInput is an autogenerated input type of CreateBranchProtectionRule. type CreateBranchProtectionRuleInput struct { // The global relay id of the repository in which a new branch protection rule should be created in. (Required.) @@ -449,6 +524,8 @@ type CreateBranchProtectionRuleInput struct { PushActorIDs *[]ID `json:"pushActorIds,omitempty"` // List of required status check contexts that must pass for commits to be accepted to matching branches. (Optional.) RequiredStatusCheckContexts *[]String `json:"requiredStatusCheckContexts,omitempty"` + // Are conversations required to be resolved before merging. (Optional.) + RequiresConversationResolution *Boolean `json:"requiresConversationResolution,omitempty"` // A unique identifier for the client performing the mutation. (Optional.) ClientMutationID *String `json:"clientMutationId,omitempty"` } @@ -493,6 +570,21 @@ type CreateCheckSuiteInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// CreateDiscussionInput is an autogenerated input type of CreateDiscussion. +type CreateDiscussionInput struct { + // The id of the repository on which to create the discussion. (Required.) + RepositoryID ID `json:"repositoryId"` + // The title of the discussion. (Required.) + Title String `json:"title"` + // The body of the discussion. (Required.) + Body String `json:"body"` + // The id of the discussion category to associate with this discussion. (Required.) + CategoryID ID `json:"categoryId"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // CreateEnterpriseOrganizationInput is an autogenerated input type of CreateEnterpriseOrganization. type CreateEnterpriseOrganizationInput struct { // The ID of the enterprise owning the new organization. (Required.) @@ -510,6 +602,17 @@ type CreateEnterpriseOrganizationInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// CreateEnvironmentInput is an autogenerated input type of CreateEnvironment. +type CreateEnvironmentInput struct { + // The node ID of the repository. (Required.) + RepositoryID ID `json:"repositoryId"` + // The name of the environment. (Required.) + Name String `json:"name"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // CreateIpAllowListEntryInput is an autogenerated input type of CreateIpAllowListEntry. type CreateIpAllowListEntryInput struct { // The ID of the owner for which to create the new IP allow list entry. (Required.) @@ -644,7 +747,7 @@ type CreateTeamDiscussionInput struct { // The content of the discussion. (Required.) Body String `json:"body"` - // If true, restricts the visiblity of this discussion to team members and organization admins. If false or not specified, allows any organization member to view this discussion. (Optional.) + // If true, restricts the visibility of this discussion to team members and organization admins. If false or not specified, allows any organization member to view this discussion. (Optional.) Private *Boolean `json:"private,omitempty"` // A unique identifier for the client performing the mutation. (Optional.) ClientMutationID *String `json:"clientMutationId,omitempty"` @@ -681,6 +784,33 @@ type DeleteDeploymentInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// DeleteDiscussionCommentInput is an autogenerated input type of DeleteDiscussionComment. +type DeleteDiscussionCommentInput struct { + // The Node id of the discussion comment to delete. (Required.) + ID ID `json:"id"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + +// DeleteDiscussionInput is an autogenerated input type of DeleteDiscussion. +type DeleteDiscussionInput struct { + // The id of the discussion to delete. (Required.) + ID ID `json:"id"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + +// DeleteEnvironmentInput is an autogenerated input type of DeleteEnvironment. +type DeleteEnvironmentInput struct { + // The Node ID of the environment to be deleted. (Required.) + ID ID `json:"id"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // DeleteIpAllowListEntryInput is an autogenerated input type of DeleteIpAllowListEntry. type DeleteIpAllowListEntryInput struct { // The ID of the IP allow list entry to delete. (Required.) @@ -780,6 +910,15 @@ type DeleteTeamDiscussionInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// DeleteVerifiableDomainInput is an autogenerated input type of DeleteVerifiableDomain. +type DeleteVerifiableDomainInput struct { + // The ID of the verifiable domain to delete. (Required.) + ID ID `json:"id"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // DeploymentOrder represents ordering options for deployment connections. type DeploymentOrder struct { // The field to order deployments by. (Required.) @@ -788,6 +927,23 @@ type DeploymentOrder struct { Direction OrderDirection `json:"direction"` } +// DisablePullRequestAutoMergeInput is an autogenerated input type of DisablePullRequestAutoMerge. +type DisablePullRequestAutoMergeInput struct { + // ID of the pull request to disable auto merge on. (Required.) + PullRequestID ID `json:"pullRequestId"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + +// DiscussionOrder represents ways in which lists of discussions can be ordered upon return. +type DiscussionOrder struct { + // The field by which to order discussions. (Required.) + Field DiscussionOrderField `json:"field"` + // The direction in which to order discussions by the specified field. (Required.) + Direction OrderDirection `json:"direction"` +} + // DismissPullRequestReviewInput is an autogenerated input type of DismissPullRequestReview. type DismissPullRequestReviewInput struct { // The Node ID of the pull request review to modify. (Required.) @@ -826,6 +982,23 @@ type DraftPullRequestReviewThread struct { StartSide *DiffSide `json:"startSide,omitempty"` } +// EnablePullRequestAutoMergeInput is an autogenerated input type of EnablePullRequestAutoMerge. +type EnablePullRequestAutoMergeInput struct { + // ID of the pull request to enable auto-merge on. (Required.) + PullRequestID ID `json:"pullRequestId"` + + // Commit headline to use for the commit when the PR is mergable; if omitted, a default message will be used. (Optional.) + CommitHeadline *String `json:"commitHeadline,omitempty"` + // Commit body to use for the commit when the PR is mergable; if omitted, a default message will be used. (Optional.) + CommitBody *String `json:"commitBody,omitempty"` + // The merge method to use. If omitted, defaults to 'MERGE'. (Optional.) + MergeMethod *PullRequestMergeMethod `json:"mergeMethod,omitempty"` + // The email address to associate with this merge. (Optional.) + AuthorEmail *String `json:"authorEmail,omitempty"` + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // EnterpriseAdministratorInvitationOrder represents ordering options for enterprise administrator invitation connections. type EnterpriseAdministratorInvitationOrder struct { // The field to order enterprise administrator invitations by. (Required.) @@ -989,6 +1162,15 @@ type LockLockableInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// MarkDiscussionCommentAsAnswerInput is an autogenerated input type of MarkDiscussionCommentAsAnswer. +type MarkDiscussionCommentAsAnswerInput struct { + // The Node ID of the discussion comment to mark as an answer. (Required.) + ID ID `json:"id"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // MarkFileAsViewedInput is an autogenerated input type of MarkFileAsViewed. type MarkFileAsViewedInput struct { // The Node ID of the pull request. (Required.) @@ -1123,6 +1305,15 @@ type PackageVersionOrder struct { Direction *OrderDirection `json:"direction,omitempty"` } +// PinIssueInput is an autogenerated input type of PinIssue. +type PinIssueInput struct { + // The ID of the issue to be pinned. (Required.) + IssueID ID `json:"issueId"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // ProjectOrder represents ways in which lists of projects can be ordered upon return. type ProjectOrder struct { // The field in which to order projects by. (Required.) @@ -1164,6 +1355,28 @@ type RegenerateEnterpriseIdentityProviderRecoveryCodesInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// RegenerateVerifiableDomainTokenInput is an autogenerated input type of RegenerateVerifiableDomainToken. +type RegenerateVerifiableDomainTokenInput struct { + // The ID of the verifiable domain to regenerate the verification token of. (Required.) + ID ID `json:"id"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + +// RejectDeploymentsInput is an autogenerated input type of RejectDeployments. +type RejectDeploymentsInput struct { + // The node ID of the workflow run containing the pending deployments. (Required.) + WorkflowRunID ID `json:"workflowRunId"` + // The ids of environments to reject deployments. (Required.) + EnvironmentIDs []ID `json:"environmentIds"` + + // Optional comment for rejecting deployments. (Optional.) + Comment *String `json:"comment,omitempty"` + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // ReleaseOrder represents ways in which lists of releases can be ordered upon return. type ReleaseOrder struct { // The field in which to order releases by. (Required.) @@ -1214,6 +1427,17 @@ type RemoveEnterpriseOrganizationInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// RemoveEnterpriseSupportEntitlementInput is an autogenerated input type of RemoveEnterpriseSupportEntitlement. +type RemoveEnterpriseSupportEntitlementInput struct { + // The ID of the Enterprise which the admin belongs to. (Required.) + EnterpriseID ID `json:"enterpriseId"` + // The login of a member who will lose the support entitlement. (Required.) + Login String `json:"login"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // RemoveLabelsFromLabelableInput is an autogenerated input type of RemoveLabelsFromLabelable. type RemoveLabelsFromLabelableInput struct { // The id of the Labelable to remove labels from. (Required.) @@ -1256,6 +1480,15 @@ type RemoveStarInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// RemoveUpvoteInput is an autogenerated input type of RemoveUpvote. +type RemoveUpvoteInput struct { + // The Node ID of the discussion or comment to remove upvote. (Required.) + SubjectID ID `json:"subjectId"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // ReopenIssueInput is an autogenerated input type of ReopenIssue. type ReopenIssueInput struct { // ID of the issue to be opened. (Required.) @@ -1415,6 +1648,22 @@ type SetUserInteractionLimitInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// SponsorableOrder represents ordering options for connections to get sponsorable entities for GitHub Sponsors. +type SponsorableOrder struct { + // The field to order sponsorable entities by. (Required.) + Field SponsorableOrderField `json:"field"` + // The ordering direction. (Required.) + Direction OrderDirection `json:"direction"` +} + +// SponsorsActivityOrder represents ordering options for GitHub Sponsors activity connections. +type SponsorsActivityOrder struct { + // The field to order activity by. (Required.) + Field SponsorsActivityOrderField `json:"field"` + // The ordering direction. (Required.) + Direction OrderDirection `json:"direction"` +} + // SponsorsTierOrder represents ordering options for Sponsors tiers connections. type SponsorsTierOrder struct { // The field to order tiers by. (Required.) @@ -1543,6 +1792,15 @@ type UnlockLockableInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// UnmarkDiscussionCommentAsAnswerInput is an autogenerated input type of UnmarkDiscussionCommentAsAnswer. +type UnmarkDiscussionCommentAsAnswerInput struct { + // The Node ID of the discussion comment to unmark as an answer. (Required.) + ID ID `json:"id"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // UnmarkFileAsViewedInput is an autogenerated input type of UnmarkFileAsViewed. type UnmarkFileAsViewedInput struct { // The Node ID of the pull request. (Required.) @@ -1574,6 +1832,15 @@ type UnminimizeCommentInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// UnpinIssueInput is an autogenerated input type of UnpinIssue. +type UnpinIssueInput struct { + // The ID of the issue to be unpinned. (Required.) + IssueID ID `json:"issueId"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // UnresolveReviewThreadInput is an autogenerated input type of UnresolveReviewThread. type UnresolveReviewThreadInput struct { // The ID of the thread to unresolve. (Required.) @@ -1622,6 +1889,8 @@ type UpdateBranchProtectionRuleInput struct { PushActorIDs *[]ID `json:"pushActorIds,omitempty"` // List of required status check contexts that must pass for commits to be accepted to matching branches. (Optional.) RequiredStatusCheckContexts *[]String `json:"requiredStatusCheckContexts,omitempty"` + // Are conversations required to be resolved before merging. (Optional.) + RequiresConversationResolution *Boolean `json:"requiresConversationResolution,omitempty"` // A unique identifier for the client performing the mutation. (Optional.) ClientMutationID *String `json:"clientMutationId,omitempty"` } @@ -1666,6 +1935,32 @@ type UpdateCheckSuitePreferencesInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// UpdateDiscussionCommentInput is an autogenerated input type of UpdateDiscussionComment. +type UpdateDiscussionCommentInput struct { + // The Node ID of the discussion comment to update. (Required.) + CommentID ID `json:"commentId"` + // The new contents of the comment body. (Required.) + Body String `json:"body"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + +// UpdateDiscussionInput is an autogenerated input type of UpdateDiscussion. +type UpdateDiscussionInput struct { + // The Node ID of the discussion to update. (Required.) + DiscussionID ID `json:"discussionId"` + + // The new discussion title. (Optional.) + Title *String `json:"title,omitempty"` + // The new contents of the discussion body. (Optional.) + Body *String `json:"body,omitempty"` + // The Node ID of a discussion category within the same repository to change this discussion to. (Optional.) + CategoryID *ID `json:"categoryId,omitempty"` + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // UpdateEnterpriseAdministratorRoleInput is an autogenerated input type of UpdateEnterpriseAdministratorRole. type UpdateEnterpriseAdministratorRoleInput struct { // The ID of the Enterprise which the admin belongs to. (Required.) @@ -1692,9 +1987,9 @@ type UpdateEnterpriseAllowPrivateRepositoryForkingSettingInput struct { // UpdateEnterpriseDefaultRepositoryPermissionSettingInput is an autogenerated input type of UpdateEnterpriseDefaultRepositoryPermissionSetting. type UpdateEnterpriseDefaultRepositoryPermissionSettingInput struct { - // The ID of the enterprise on which to set the default repository permission setting. (Required.) + // The ID of the enterprise on which to set the base repository permission setting. (Required.) EnterpriseID ID `json:"enterpriseId"` - // The value for the default repository permission setting on the enterprise. (Required.) + // The value for the base repository permission setting on the enterprise. (Required.) SettingValue EnterpriseDefaultRepositoryPermissionSettingValue `json:"settingValue"` // A unique identifier for the client performing the mutation. (Optional.) @@ -1858,6 +2153,19 @@ type UpdateEnterpriseTwoFactorAuthenticationRequiredSettingInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// UpdateEnvironmentInput is an autogenerated input type of UpdateEnvironment. +type UpdateEnvironmentInput struct { + // The node ID of the environment. (Required.) + EnvironmentID ID `json:"environmentId"` + + // The wait timer in minutes. (Optional.) + WaitTimer *Int `json:"waitTimer,omitempty"` + // The ids of users or teams that can approve deployments to this environment. (Optional.) + Reviewers *[]ID `json:"reviewers,omitempty"` + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // UpdateIpAllowListEnabledSettingInput is an autogenerated input type of UpdateIpAllowListEnabledSetting. type UpdateIpAllowListEnabledSettingInput struct { // The ID of the owner on which to set the IP allow list enabled setting. (Required.) @@ -1884,6 +2192,17 @@ type UpdateIpAllowListEntryInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// UpdateIpAllowListForInstalledAppsEnabledSettingInput is an autogenerated input type of UpdateIpAllowListForInstalledAppsEnabledSetting. +type UpdateIpAllowListForInstalledAppsEnabledSettingInput struct { + // The ID of the owner. (Required.) + OwnerID ID `json:"ownerId"` + // The value for the IP allow list configuration for installed GitHub Apps setting. (Required.) + SettingValue IpAllowListForInstalledAppsEnabledSettingValue `json:"settingValue"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // UpdateIssueCommentInput is an autogenerated input type of UpdateIssueComment. type UpdateIssueCommentInput struct { // The ID of the IssueComment to modify. (Required.) @@ -1918,6 +2237,17 @@ type UpdateIssueInput struct { ClientMutationID *String `json:"clientMutationId,omitempty"` } +// UpdateNotificationRestrictionSettingInput is an autogenerated input type of UpdateNotificationRestrictionSetting. +type UpdateNotificationRestrictionSettingInput struct { + // The ID of the owner on which to set the restrict notifications setting. (Required.) + OwnerID ID `json:"ownerId"` + // The value for the restrict notifications setting. (Required.) + SettingValue NotificationRestrictionSettingValue `json:"settingValue"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} + // UpdateProjectCardInput is an autogenerated input type of UpdateProjectCard. type UpdateProjectCardInput struct { // The ProjectCard ID to update. (Required.) @@ -2103,3 +2433,20 @@ type UserStatusOrder struct { // The ordering direction. (Required.) Direction OrderDirection `json:"direction"` } + +// VerifiableDomainOrder represents ordering options for verifiable domain connections. +type VerifiableDomainOrder struct { + // The field to order verifiable domains by. (Required.) + Field VerifiableDomainOrderField `json:"field"` + // The ordering direction. (Required.) + Direction OrderDirection `json:"direction"` +} + +// VerifyVerifiableDomainInput is an autogenerated input type of VerifyVerifiableDomain. +type VerifyVerifiableDomainInput struct { + // The ID of the verifiable domain to verify. (Required.) + ID ID `json:"id"` + + // A unique identifier for the client performing the mutation. (Optional.) + ClientMutationID *String `json:"clientMutationId,omitempty"` +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 054c14f1d4..d808de2003 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -370,7 +370,7 @@ github.com/ryancurrah/gomodguard # github.com/securego/gosec v0.0.0-20200316084457-7da9f46445fd github.com/securego/gosec github.com/securego/gosec/rules -# github.com/shurcooL/githubv4 v0.0.0-20201206200315-234843c633fa +# github.com/shurcooL/githubv4 v0.0.0-20210725200734-83ba7b4c9228 ## explicit github.com/shurcooL/githubv4 # github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f From 2cc591af436019ee8c59983538004841c697dc7d Mon Sep 17 00:00:00 2001 From: Josh Barker Date: Tue, 14 Sep 2021 16:29:35 +1000 Subject: [PATCH 3/3] feat: add conversation resolution variable on branch protection --- github/resource_github_branch_protection.go | 80 ++++++++++------- .../resource_github_branch_protection_test.go | 88 +++++++++++++++++++ github/util_v4_branch_protection.go | 76 ++++++++-------- github/util_v4_consts.go | 33 +++---- .../docs/r/branch_protection.html.markdown | 1 + 5 files changed, 193 insertions(+), 85 deletions(-) diff --git a/github/resource_github_branch_protection.go b/github/resource_github_branch_protection.go index 1f99a3db5a..b5777040f2 100644 --- a/github/resource_github_branch_protection.go +++ b/github/resource_github_branch_protection.go @@ -53,6 +53,11 @@ func resourceGithubBranchProtection() *schema.Resource { Optional: true, Default: false, }, + PROTECTION_REQUIRES_CONVERSATION_RESOLUTION: { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, PROTECTION_REQUIRES_APPROVING_REVIEWS: { Type: schema.TypeList, Optional: true, @@ -141,23 +146,24 @@ func resourceGithubBranchProtectionCreate(d *schema.ResourceData, meta interface return err } input := githubv4.CreateBranchProtectionRuleInput{ - AllowsDeletions: githubv4.NewBoolean(githubv4.Boolean(data.AllowsDeletions)), - AllowsForcePushes: githubv4.NewBoolean(githubv4.Boolean(data.AllowsForcePushes)), - DismissesStaleReviews: githubv4.NewBoolean(githubv4.Boolean(data.DismissesStaleReviews)), - IsAdminEnforced: githubv4.NewBoolean(githubv4.Boolean(data.IsAdminEnforced)), - Pattern: githubv4.String(data.Pattern), - PushActorIDs: githubv4NewIDSlice(githubv4IDSlice(data.PushActorIDs)), - RepositoryID: githubv4.NewID(githubv4.ID(data.RepositoryID)), - RequiredApprovingReviewCount: githubv4.NewInt(githubv4.Int(data.RequiredApprovingReviewCount)), - RequiredStatusCheckContexts: githubv4NewStringSlice(githubv4StringSlice(data.RequiredStatusCheckContexts)), - RequiresApprovingReviews: githubv4.NewBoolean(githubv4.Boolean(data.RequiresApprovingReviews)), - RequiresCodeOwnerReviews: githubv4.NewBoolean(githubv4.Boolean(data.RequiresCodeOwnerReviews)), - RequiresCommitSignatures: githubv4.NewBoolean(githubv4.Boolean(data.RequiresCommitSignatures)), - RequiresStatusChecks: githubv4.NewBoolean(githubv4.Boolean(data.RequiresStatusChecks)), - RequiresStrictStatusChecks: githubv4.NewBoolean(githubv4.Boolean(data.RequiresStrictStatusChecks)), - RestrictsPushes: githubv4.NewBoolean(githubv4.Boolean(data.RestrictsPushes)), - RestrictsReviewDismissals: githubv4.NewBoolean(githubv4.Boolean(data.RestrictsReviewDismissals)), - ReviewDismissalActorIDs: githubv4NewIDSlice(githubv4IDSlice(data.ReviewDismissalActorIDs)), + AllowsDeletions: githubv4.NewBoolean(githubv4.Boolean(data.AllowsDeletions)), + AllowsForcePushes: githubv4.NewBoolean(githubv4.Boolean(data.AllowsForcePushes)), + DismissesStaleReviews: githubv4.NewBoolean(githubv4.Boolean(data.DismissesStaleReviews)), + IsAdminEnforced: githubv4.NewBoolean(githubv4.Boolean(data.IsAdminEnforced)), + Pattern: githubv4.String(data.Pattern), + PushActorIDs: githubv4NewIDSlice(githubv4IDSlice(data.PushActorIDs)), + RepositoryID: githubv4.NewID(githubv4.ID(data.RepositoryID)), + RequiredApprovingReviewCount: githubv4.NewInt(githubv4.Int(data.RequiredApprovingReviewCount)), + RequiredStatusCheckContexts: githubv4NewStringSlice(githubv4StringSlice(data.RequiredStatusCheckContexts)), + RequiresApprovingReviews: githubv4.NewBoolean(githubv4.Boolean(data.RequiresApprovingReviews)), + RequiresCodeOwnerReviews: githubv4.NewBoolean(githubv4.Boolean(data.RequiresCodeOwnerReviews)), + RequiresCommitSignatures: githubv4.NewBoolean(githubv4.Boolean(data.RequiresCommitSignatures)), + RequiresConversationResolution: githubv4.NewBoolean(githubv4.Boolean(data.RequiresConversationResolution)), + RequiresStatusChecks: githubv4.NewBoolean(githubv4.Boolean(data.RequiresStatusChecks)), + RequiresStrictStatusChecks: githubv4.NewBoolean(githubv4.Boolean(data.RequiresStrictStatusChecks)), + RestrictsPushes: githubv4.NewBoolean(githubv4.Boolean(data.RestrictsPushes)), + RestrictsReviewDismissals: githubv4.NewBoolean(githubv4.Boolean(data.RestrictsReviewDismissals)), + ReviewDismissalActorIDs: githubv4NewIDSlice(githubv4IDSlice(data.ReviewDismissalActorIDs)), } ctx := context.Background() @@ -227,6 +233,11 @@ func resourceGithubBranchProtectionRead(d *schema.ResourceData, meta interface{} log.Printf("[WARN] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_REQUIRES_LINEAR_HISTORY, protection.Repository.Name, protection.Pattern, d.Id()) } + err = d.Set(PROTECTION_REQUIRES_CONVERSATION_RESOLUTION, protection.RequiresConversationResolution) + if err != nil { + log.Printf("[WARN] Problem setting '%s' in %s %s branch protection (%s)", PROTECTION_REQUIRES_CONVERSATION_RESOLUTION, protection.Repository.Name, protection.Pattern, d.Id()) + } + approvingReviews := setApprovingReviews(protection) err = d.Set(PROTECTION_REQUIRES_APPROVING_REVIEWS, approvingReviews) if err != nil { @@ -261,23 +272,24 @@ func resourceGithubBranchProtectionUpdate(d *schema.ResourceData, meta interface return err } input := githubv4.UpdateBranchProtectionRuleInput{ - BranchProtectionRuleID: d.Id(), - AllowsDeletions: githubv4.NewBoolean(githubv4.Boolean(data.AllowsDeletions)), - AllowsForcePushes: githubv4.NewBoolean(githubv4.Boolean(data.AllowsForcePushes)), - DismissesStaleReviews: githubv4.NewBoolean(githubv4.Boolean(data.DismissesStaleReviews)), - IsAdminEnforced: githubv4.NewBoolean(githubv4.Boolean(data.IsAdminEnforced)), - Pattern: githubv4.NewString(githubv4.String(data.Pattern)), - PushActorIDs: githubv4NewIDSlice(githubv4IDSlice(data.PushActorIDs)), - RequiredApprovingReviewCount: githubv4.NewInt(githubv4.Int(data.RequiredApprovingReviewCount)), - RequiredStatusCheckContexts: githubv4NewStringSlice(githubv4StringSlice(data.RequiredStatusCheckContexts)), - RequiresApprovingReviews: githubv4.NewBoolean(githubv4.Boolean(data.RequiresApprovingReviews)), - RequiresCodeOwnerReviews: githubv4.NewBoolean(githubv4.Boolean(data.RequiresCodeOwnerReviews)), - RequiresCommitSignatures: githubv4.NewBoolean(githubv4.Boolean(data.RequiresCommitSignatures)), - RequiresStatusChecks: githubv4.NewBoolean(githubv4.Boolean(data.RequiresStatusChecks)), - RequiresStrictStatusChecks: githubv4.NewBoolean(githubv4.Boolean(data.RequiresStrictStatusChecks)), - RestrictsPushes: githubv4.NewBoolean(githubv4.Boolean(data.RestrictsPushes)), - RestrictsReviewDismissals: githubv4.NewBoolean(githubv4.Boolean(data.RestrictsReviewDismissals)), - ReviewDismissalActorIDs: githubv4NewIDSlice(githubv4IDSlice(data.ReviewDismissalActorIDs)), + BranchProtectionRuleID: d.Id(), + AllowsDeletions: githubv4.NewBoolean(githubv4.Boolean(data.AllowsDeletions)), + AllowsForcePushes: githubv4.NewBoolean(githubv4.Boolean(data.AllowsForcePushes)), + DismissesStaleReviews: githubv4.NewBoolean(githubv4.Boolean(data.DismissesStaleReviews)), + IsAdminEnforced: githubv4.NewBoolean(githubv4.Boolean(data.IsAdminEnforced)), + Pattern: githubv4.NewString(githubv4.String(data.Pattern)), + PushActorIDs: githubv4NewIDSlice(githubv4IDSlice(data.PushActorIDs)), + RequiredApprovingReviewCount: githubv4.NewInt(githubv4.Int(data.RequiredApprovingReviewCount)), + RequiredStatusCheckContexts: githubv4NewStringSlice(githubv4StringSlice(data.RequiredStatusCheckContexts)), + RequiresApprovingReviews: githubv4.NewBoolean(githubv4.Boolean(data.RequiresApprovingReviews)), + RequiresCodeOwnerReviews: githubv4.NewBoolean(githubv4.Boolean(data.RequiresCodeOwnerReviews)), + RequiresCommitSignatures: githubv4.NewBoolean(githubv4.Boolean(data.RequiresCommitSignatures)), + RequiresConversationResolution: githubv4.NewBoolean(githubv4.Boolean(data.RequiresConversationResolution)), + RequiresStatusChecks: githubv4.NewBoolean(githubv4.Boolean(data.RequiresStatusChecks)), + RequiresStrictStatusChecks: githubv4.NewBoolean(githubv4.Boolean(data.RequiresStrictStatusChecks)), + RestrictsPushes: githubv4.NewBoolean(githubv4.Boolean(data.RestrictsPushes)), + RestrictsReviewDismissals: githubv4.NewBoolean(githubv4.Boolean(data.RestrictsReviewDismissals)), + ReviewDismissalActorIDs: githubv4NewIDSlice(githubv4IDSlice(data.ReviewDismissalActorIDs)), } ctx := context.WithValue(context.Background(), ctxId, d.Id()) diff --git a/github/resource_github_branch_protection_test.go b/github/resource_github_branch_protection_test.go index 04f9f3c67f..9cfef20810 100644 --- a/github/resource_github_branch_protection_test.go +++ b/github/resource_github_branch_protection_test.go @@ -39,6 +39,94 @@ func TestAccGithubBranchProtection(t *testing.T) { resource.TestCheckResourceAttr( "github_branch_protection.test", "require_signed_commits", "false", ), + resource.TestCheckResourceAttr( + "github_branch_protection.test", "require_conversation_resolution", "false", + ), + resource.TestCheckResourceAttr( + "github_branch_protection.test", "required_status_checks.#", "0", + ), + resource.TestCheckResourceAttr( + "github_branch_protection.test", "required_pull_request_reviews.#", "0", + ), + resource.TestCheckResourceAttr( + "github_branch_protection.test", "push_restrictions.#", "0", + ), + ) + + testCase := func(t *testing.T, mode string) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { skipUnlessMode(t, mode) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: config, + Check: check, + }, + { + ResourceName: "github_branch_protection.test", + ImportState: true, + ImportStateVerify: true, + ImportStateIdFunc: importBranchProtectionByRepoName( + fmt.Sprintf("tf-acc-test-%s", randomID), "main", + ), + }, + { + ResourceName: "github_branch_protection.test", + ImportState: true, + ExpectError: regexp.MustCompile( + `Could not find a branch protection rule with the pattern 'no-such-pattern'\.`, + ), + ImportStateIdFunc: importBranchProtectionByRepoName( + fmt.Sprintf("tf-acc-test-%s", randomID), "no-such-pattern", + ), + }, + }, + }) + } + + t.Run("with an anonymous account", func(t *testing.T) { + t.Skip("anonymous account not supported for this operation") + }) + + t.Run("with an individual account", func(t *testing.T) { + testCase(t, individual) + }) + + t.Run("with an organization account", func(t *testing.T) { + testCase(t, organization) + }) + + }) + + t.Run("configures default settings when conversation resolution is true", func(t *testing.T) { + + config := fmt.Sprintf(` + + resource "github_repository" "test" { + name = "tf-acc-test-%s" + auto_init = true + } + + resource "github_branch_protection" "test" { + + repository_id = github_repository.test.node_id + pattern = "main" + + require_conversation_resolution = true + } + + `, randomID) + + check := resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr( + "github_branch_protection.test", "pattern", "main", + ), + resource.TestCheckResourceAttr( + "github_branch_protection.test", "require_signed_commits", "false", + ), + resource.TestCheckResourceAttr( + "github_branch_protection.test", "require_conversation_resolution", "true", + ), resource.TestCheckResourceAttr( "github_branch_protection.test", "required_status_checks.#", "0", ), diff --git a/github/util_v4_branch_protection.go b/github/util_v4_branch_protection.go index e3f43aa61c..bd693c442b 100644 --- a/github/util_v4_branch_protection.go +++ b/github/util_v4_branch_protection.go @@ -39,44 +39,46 @@ type BranchProtectionRule struct { ReviewDismissalAllowances struct { Nodes []DismissalActorTypes } `graphql:"reviewDismissalAllowances(first: 100)"` - AllowsDeletions githubv4.Boolean - AllowsForcePushes githubv4.Boolean - DismissesStaleReviews githubv4.Boolean - ID githubv4.ID - IsAdminEnforced githubv4.Boolean - Pattern githubv4.String - RequiredApprovingReviewCount githubv4.Int - RequiredStatusCheckContexts []githubv4.String - RequiresApprovingReviews githubv4.Boolean - RequiresCodeOwnerReviews githubv4.Boolean - RequiresCommitSignatures githubv4.Boolean - RequiresLinearHistory githubv4.Boolean - RequiresStatusChecks githubv4.Boolean - RequiresStrictStatusChecks githubv4.Boolean - RestrictsPushes githubv4.Boolean - RestrictsReviewDismissals githubv4.Boolean + AllowsDeletions githubv4.Boolean + AllowsForcePushes githubv4.Boolean + DismissesStaleReviews githubv4.Boolean + ID githubv4.ID + IsAdminEnforced githubv4.Boolean + Pattern githubv4.String + RequiredApprovingReviewCount githubv4.Int + RequiredStatusCheckContexts []githubv4.String + RequiresApprovingReviews githubv4.Boolean + RequiresCodeOwnerReviews githubv4.Boolean + RequiresCommitSignatures githubv4.Boolean + RequiresLinearHistory githubv4.Boolean + RequiresConversationResolution githubv4.Boolean + RequiresStatusChecks githubv4.Boolean + RequiresStrictStatusChecks githubv4.Boolean + RestrictsPushes githubv4.Boolean + RestrictsReviewDismissals githubv4.Boolean } type BranchProtectionResourceData struct { - AllowsDeletions bool - AllowsForcePushes bool - BranchProtectionRuleID string - DismissesStaleReviews bool - IsAdminEnforced bool - Pattern string - PushActorIDs []string - RepositoryID string - RequiredApprovingReviewCount int - RequiredStatusCheckContexts []string - RequiresApprovingReviews bool - RequiresCodeOwnerReviews bool - RequiresCommitSignatures bool - RequiresLinearHistory bool - RequiresStatusChecks bool - RequiresStrictStatusChecks bool - RestrictsPushes bool - RestrictsReviewDismissals bool - ReviewDismissalActorIDs []string + AllowsDeletions bool + AllowsForcePushes bool + BranchProtectionRuleID string + DismissesStaleReviews bool + IsAdminEnforced bool + Pattern string + PushActorIDs []string + RepositoryID string + RequiredApprovingReviewCount int + RequiredStatusCheckContexts []string + RequiresApprovingReviews bool + RequiresCodeOwnerReviews bool + RequiresCommitSignatures bool + RequiresLinearHistory bool + RequiresConversationResolution bool + RequiresStatusChecks bool + RequiresStrictStatusChecks bool + RestrictsPushes bool + RestrictsReviewDismissals bool + ReviewDismissalActorIDs []string } func branchProtectionResourceData(d *schema.ResourceData, meta interface{}) (BranchProtectionResourceData, error) { @@ -114,6 +116,10 @@ func branchProtectionResourceData(d *schema.ResourceData, meta interface{}) (Bra data.RequiresLinearHistory = v.(bool) } + if v, ok := d.GetOk(PROTECTION_REQUIRES_CONVERSATION_RESOLUTION); ok { + data.RequiresConversationResolution = v.(bool) + } + if v, ok := d.GetOk(PROTECTION_REQUIRES_APPROVING_REVIEWS); ok { vL := v.([]interface{}) if len(vL) > 1 { diff --git a/github/util_v4_consts.go b/github/util_v4_consts.go index b4a4bc6d67..f405a6d60d 100644 --- a/github/util_v4_consts.go +++ b/github/util_v4_consts.go @@ -1,22 +1,23 @@ package github const ( - PROTECTION_ALLOWS_DELETIONS = "allows_deletions" - PROTECTION_ALLOWS_FORCE_PUSHES = "allows_force_pushes" - PROTECTION_DISMISSES_STALE_REVIEWS = "dismiss_stale_reviews" - PROTECTION_IS_ADMIN_ENFORCED = "enforce_admins" - PROTECTION_PATTERN = "pattern" - PROTECTION_REQUIRED_APPROVING_REVIEW_COUNT = "required_approving_review_count" - PROTECTION_REQUIRED_STATUS_CHECK_CONTEXTS = "contexts" - PROTECTION_REQUIRES_APPROVING_REVIEWS = "required_pull_request_reviews" - PROTECTION_REQUIRES_CODE_OWNER_REVIEWS = "require_code_owner_reviews" - PROTECTION_REQUIRES_COMMIT_SIGNATURES = "require_signed_commits" - PROTECTION_REQUIRES_LINEAR_HISTORY = "required_linear_history" - PROTECTION_REQUIRES_STATUS_CHECKS = "required_status_checks" - PROTECTION_REQUIRES_STRICT_STATUS_CHECKS = "strict" - PROTECTION_RESTRICTS_PUSHES = "push_restrictions" - PROTECTION_RESTRICTS_REVIEW_DISMISSALS = "restrict_dismissals" - PROTECTION_RESTRICTS_REVIEW_DISMISSERS = "dismissal_restrictions" + PROTECTION_ALLOWS_DELETIONS = "allows_deletions" + PROTECTION_ALLOWS_FORCE_PUSHES = "allows_force_pushes" + PROTECTION_DISMISSES_STALE_REVIEWS = "dismiss_stale_reviews" + PROTECTION_IS_ADMIN_ENFORCED = "enforce_admins" + PROTECTION_PATTERN = "pattern" + PROTECTION_REQUIRED_APPROVING_REVIEW_COUNT = "required_approving_review_count" + PROTECTION_REQUIRED_STATUS_CHECK_CONTEXTS = "contexts" + PROTECTION_REQUIRES_APPROVING_REVIEWS = "required_pull_request_reviews" + PROTECTION_REQUIRES_CODE_OWNER_REVIEWS = "require_code_owner_reviews" + PROTECTION_REQUIRES_COMMIT_SIGNATURES = "require_signed_commits" + PROTECTION_REQUIRES_LINEAR_HISTORY = "required_linear_history" + PROTECTION_REQUIRES_CONVERSATION_RESOLUTION = "require_conversation_resolution" + PROTECTION_REQUIRES_STATUS_CHECKS = "required_status_checks" + PROTECTION_REQUIRES_STRICT_STATUS_CHECKS = "strict" + PROTECTION_RESTRICTS_PUSHES = "push_restrictions" + PROTECTION_RESTRICTS_REVIEW_DISMISSALS = "restrict_dismissals" + PROTECTION_RESTRICTS_REVIEW_DISMISSERS = "dismissal_restrictions" REPOSITORY_ID = "repository_id" ) diff --git a/website/docs/r/branch_protection.html.markdown b/website/docs/r/branch_protection.html.markdown index 1db1b1bd15..ac1dfce755 100644 --- a/website/docs/r/branch_protection.html.markdown +++ b/website/docs/r/branch_protection.html.markdown @@ -77,6 +77,7 @@ The following arguments are supported: * `enforce_admins` - (Optional) Boolean, setting this to `true` enforces status checks for repository administrators. * `require_signed_commits` - (Optional) Boolean, setting this to `true` requires all commits to be signed with GPG. * `required_linear_history` - (Optional) Boolean, setting this to `true` enforces a linear commit Git history, which prevents anyone from pushing merge commits to a branch +* `require_conversation_resolution` - (Optional) Boolean, setting this to `true` requires all conversations on code must be resolved before a pull request can be merged. * `required_status_checks` - (Optional) Enforce restrictions for required status checks. See [Required Status Checks](#required-status-checks) below for details. * `required_pull_request_reviews` - (Optional) Enforce restrictions for pull request reviews. See [Required Pull Request Reviews](#required-pull-request-reviews) below for details. * `push_restrictions` - (Optional) The list of actor IDs that may push to the branch.