Skip to content

Commit

Permalink
add additional comments in expand methods
Browse files Browse the repository at this point in the history
  • Loading branch information
anGie44 committed Jun 14, 2020
1 parent 92a27ef commit 37c4cab
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion github/resource_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ func expandPages(input []interface{}) *github.Pages {
Branch: github.String(pagesSource["branch"].(string)),
}
if v, ok := pagesSource["path"].(string); ok {
// Github Pages API only accepts non-root directory paths (i.e. /docs) in source.Path;
// Github Pages API only accepts "/docs" in source.Path;
// to set to the root directory "/", leave source.Path unset
if v != "" && v != "/" {
source.Path = github.String(v)
Expand All @@ -505,9 +505,16 @@ func expandPagesUpdate(input []interface{}) *github.PagesUpdate {

pages := input[0].(map[string]interface{})
update := &github.PagesUpdate{}

// Only set the github.PagesUpdate CNAME field if the value is a non-empty string.
// Leaving the CNAME field unset will remove the custom domain.
if v, ok := pages["cname"].(string); ok && v != "" {
update.CNAME = github.String(v)
}

// To update the Github Pages source, the github.PagesUpdate Source field
// must include the branch name and optionally the subdirectory /docs.
// e.g. "master" or "master /docs"
pagesSource := pages["source"].([]interface{})[0].(map[string]interface{})
source := pagesSource["branch"].(string)
if v, ok := pagesSource["path"].(string); ok {
Expand Down

0 comments on commit 37c4cab

Please sign in to comment.