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 authored and Jeremy Udit committed Jan 12, 2021
1 parent ffbce5e commit 898c00d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion github/data_source_github_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,4 @@ func TestAccGithubRepositoryDataSource(t *testing.T) {

})

}
}
10 changes: 8 additions & 2 deletions github/resource_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,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;
// to set to the root directory "/", leave source.Path unset
// To set to the root directory "/", leave source.Path unset
if v != "" && v != "/" {
source.Path = github.String(v)
}
Expand All @@ -585,9 +584,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
2 changes: 1 addition & 1 deletion github/resource_github_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,4 +700,4 @@ func init() {
Name: "github_repository",
F: testSweepRepositories,
})
}
}
2 changes: 1 addition & 1 deletion website/docs/r/repository.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ resource "github_repository" "example" {
```hcl
resource "github_repository" "example" {
name = "example"
description = "My awesome codebase"
description = "My awesome web page"
private = false
Expand Down

0 comments on commit 898c00d

Please sign in to comment.