Skip to content

Commit eb4caae

Browse files
committed
Add comments to make it clearer why we need to use this partial value setting in Create
Signed-off-by: Timo Sand <[email protected]>
1 parent 5170b65 commit eb4caae

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

github/resource_github_repository_pages.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,11 @@ func resourceGithubRepositoryPagesCreate(ctx context.Context, d *schema.Resource
160160
return diag.FromErr(err)
161161
}
162162

163-
// Check if we have values set that can't be configured as part of the create logic
163+
// Sending a null value will remove the custom domain in the API, so we make sure to only send the value if it's set.
164164
cname, cnameOK := d.GetOk("cname")
165-
public, publicOKExists := d.GetOkExists("public") //nolint:staticcheck // SA1019: d.GetOkExists is deprecated but necessary for bool fields
165+
// `public` can only be set for GHEC. Hence we make sure to only send the value if it's set.
166+
public, publicOKExists := d.GetOkExists("public") //nolint:staticcheck // SA1019: d.GetOkExists is deprecated but necessary for bool fields
167+
// `https_enforced` can't be sent to the API unless `cname` is set. Otherwise the API will return "404 The certificate does not exist yet".
166168
httpsEnforced, httpsEnforcedExists := d.GetOkExists("https_enforced") //nolint:staticcheck // SA1019: d.GetOkExists is deprecated but necessary for bool fields
167169
tflog.Debug(ctx, "Do we have values set that need the update logic?", map[string]any{
168170
"public": public,

0 commit comments

Comments
 (0)