You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: github/resource_github_repository_pages.go
+20-22Lines changed: 20 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -162,7 +162,7 @@ func resourceGithubRepositoryPagesCreate(ctx context.Context, d *schema.Resource
162
162
163
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.
164
164
cname, cnameOK:=d.GetOk("cname")
165
-
// `public` can only be set for GHEC. Hence we make sure to only send the value if it's set.
165
+
// // Sending the `public` value will return an error if the repository doesn't have public pages enabled.
166
166
public, publicOKExists:=d.GetOkExists("public") //nolint:staticcheck // SA1019: d.GetOkExists is deprecated but necessary for bool fields
167
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".
168
168
httpsEnforced, httpsEnforcedExists:=d.GetOkExists("https_enforced") //nolint:staticcheck // SA1019: d.GetOkExists is deprecated but necessary for bool fields
@@ -289,45 +289,43 @@ func resourceGithubRepositoryPagesUpdate(ctx context.Context, d *schema.Resource
289
289
290
290
update:=&github.PagesUpdate{}
291
291
292
+
// Sending a null value for `cname` will remove the custom domain in the API, so we make sure to only send the value if it's changed.
292
293
ifd.HasChange("cname") {
293
294
cname:=d.Get("cname").(string)
294
-
ifcname!="" {
295
-
update.CNAME=new(cname)
296
-
}
295
+
update.CNAME=new(cname)
297
296
}
298
297
298
+
// Sending the `public` value on updates will return an error if the repository doesn't have public pages enabled.
299
+
// Hence we make sure to only send the value if it's changed.
300
+
// Error: "400 Private pages is not enabled for this repository. All Pages will be public."
299
301
ifd.HasChange("public") {
300
302
public, ok:=d.Get("public").(bool)
301
303
ifok {
302
304
update.Public=new(public)
303
305
}
304
306
}
305
307
308
+
// `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".
0 commit comments