Skip to content

Commit

Permalink
Log choices for organization/owner (#867)
Browse files Browse the repository at this point in the history
* Initial commit of logging owner choices

* Add additional logs for configuration setup
  • Loading branch information
kfcampbell authored Sep 2, 2021
1 parent 3ef2d53 commit 71276dd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
10 changes: 8 additions & 2 deletions github/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package github

import (
"context"
"log"
"net/http"
"net/url"
"path"
Expand Down Expand Up @@ -148,9 +149,14 @@ func (c *Config) Meta() (interface{}, error) {
owner.v3client = v3client

if c.Anonymous() {
log.Printf("[DEBUG] No token present; configuring anonymous owner.")
return &owner, nil
} else {
return c.ConfigureOwner(&owner)
_, err = c.ConfigureOwner(&owner)
if err != nil {
return &owner, err
}
log.Printf("[DEBUG] Token present; configuring authenticated owner: %s", owner.name)
return &owner, nil
}

}
2 changes: 2 additions & 0 deletions github/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package github

import (
"fmt"
"log"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
Expand Down Expand Up @@ -182,6 +183,7 @@ func providerConfigure(p *schema.Provider) schema.ConfigureFunc {

org := d.Get("organization").(string)
if org != "" {
log.Printf("[DEBUG] Selecting organization attribute as owner: %s", org)
owner = org
}

Expand Down
6 changes: 5 additions & 1 deletion github/provider_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package github

import (
"fmt"
"log"
"os"
"testing"
)
Expand Down Expand Up @@ -97,9 +98,12 @@ func testAccCheckOrganization() error {

func OwnerOrOrgEnvDefaultFunc() (interface{}, error) {
if organization := os.Getenv("GITHUB_ORGANIZATION"); organization != "" {
log.Printf("[DEBUG] Selecting owner %s from GITHUB_ORGANIZATION environment variable", organization)
return organization, nil
}
return os.Getenv("GITHUB_OWNER"), nil
owner := os.Getenv("GITHUB_OWNER")
log.Printf("[DEBUG] Selecting owner %s from GITHUB_OWNER environment variable", owner)
return owner, nil
}

func testOrganizationFunc() string {
Expand Down

0 comments on commit 71276dd

Please sign in to comment.