From 5ebb6928e26298c4e8b190c4c43928b012b4c939 Mon Sep 17 00:00:00 2001 From: Keegan Campbell Date: Thu, 2 Sep 2021 04:43:20 -0700 Subject: [PATCH] Log choices for organization/owner (#867) * Initial commit of logging owner choices * Add additional logs for configuration setup --- github/config.go | 10 ++++++++-- github/provider.go | 2 ++ github/provider_utils.go | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/github/config.go b/github/config.go index ca6d178ce3..42a0cdc499 100644 --- a/github/config.go +++ b/github/config.go @@ -2,6 +2,7 @@ package github import ( "context" + "log" "net/http" "net/url" "path" @@ -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 } - } diff --git a/github/provider.go b/github/provider.go index cb5ed60083..dc1878f2e8 100644 --- a/github/provider.go +++ b/github/provider.go @@ -2,6 +2,7 @@ package github import ( "fmt" + "log" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/terraform" @@ -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 } diff --git a/github/provider_utils.go b/github/provider_utils.go index 5e1399ebda..3672c7508d 100644 --- a/github/provider_utils.go +++ b/github/provider_utils.go @@ -2,6 +2,7 @@ package github import ( "fmt" + "log" "os" "testing" ) @@ -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 {