Skip to content

Commit 4b5d697

Browse files
committed
Address possible edge-case if either allow_ settings value is not known at diff time
Signed-off-by: Timo Sand <timo.sand@f-secure.com>
1 parent 67aae69 commit 4b5d697

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

github/resource_github_repository.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ func customDiffFunction(ctx context.Context, diff *schema.ResourceDiff, v any) e
538538
// We need to check the `allow_squash_merge` flag by checking if the `squash_merge_commit_title` and `squash_merge_commit_message` are set in the configuration.
539539
isSquashMergeCommitTitleSet := !diff.GetRawConfig().GetAttr("squash_merge_commit_title").IsNull()
540540
isSquashMergeCommitMessageSet := !diff.GetRawConfig().GetAttr("squash_merge_commit_message").IsNull()
541-
if isSquashMergeCommitMessageSet || isSquashMergeCommitTitleSet {
541+
if (isSquashMergeCommitMessageSet || isSquashMergeCommitTitleSet) && diff.NewValueKnown("allow_squash_merge") {
542542
allowSquashMerge, _ := diff.Get("allow_squash_merge").(bool)
543543
if !allowSquashMerge {
544544
return fmt.Errorf("allow_squash_merge is required when squash_merge_commit_title or squash_merge_commit_message is set")
@@ -548,7 +548,7 @@ func customDiffFunction(ctx context.Context, diff *schema.ResourceDiff, v any) e
548548
// We need to check the `allow_merge_commit` flag by checking if the `merge_commit_title` and `merge_commit_message` are set in the configuration.
549549
isMergeCommitTitleSet := !diff.GetRawConfig().GetAttr("merge_commit_title").IsNull()
550550
isMergeCommitMessageSet := !diff.GetRawConfig().GetAttr("merge_commit_message").IsNull()
551-
if isMergeCommitMessageSet || isMergeCommitTitleSet {
551+
if (isMergeCommitMessageSet || isMergeCommitTitleSet) && diff.NewValueKnown("allow_merge_commit") {
552552
allowMergeCommit, _ := diff.Get("allow_merge_commit").(bool)
553553
if !allowMergeCommit {
554554
return fmt.Errorf("allow_merge_commit is required when merge_commit_title or merge_commit_message is set")

0 commit comments

Comments
 (0)