From 7dcd386a2ccebc164548aceb9b656905f0fa6d83 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Sat, 10 Jan 2026 23:24:25 +0200 Subject: [PATCH 1/5] Change provider schema to use `ConflictsWith` to re-enable having an empty `provider` block Signed-off-by: Timo Sand --- github/provider.go | 20 ++++++++++---------- github/provider_test.go | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/github/provider.go b/github/provider.go index 3a3b24863c..e49e17b0d0 100644 --- a/github/provider.go +++ b/github/provider.go @@ -18,11 +18,11 @@ func Provider() *schema.Provider { p := &schema.Provider{ Schema: map[string]*schema.Schema{ "token": { - Type: schema.TypeString, - Optional: true, - DefaultFunc: schema.EnvDefaultFunc("GITHUB_TOKEN", nil), - Description: descriptions["token"], - ExactlyOneOf: []string{"app_auth"}, + Type: schema.TypeString, + Optional: true, + DefaultFunc: schema.EnvDefaultFunc("GITHUB_TOKEN", nil), + Description: descriptions["token"], + ConflictsWith: []string{"app_auth"}, }, "owner": { Type: schema.TypeString, @@ -94,11 +94,11 @@ func Provider() *schema.Provider { Description: descriptions["parallel_requests"], }, "app_auth": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Description: descriptions["app_auth"], - ExactlyOneOf: []string{"token"}, + Type: schema.TypeList, + Optional: true, + MaxItems: 1, + Description: descriptions["app_auth"], + ConflictsWith: []string{"token"}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "id": { diff --git a/github/provider_test.go b/github/provider_test.go index 6d05f3fa15..39cef45ef8 100644 --- a/github/provider_test.go +++ b/github/provider_test.go @@ -248,7 +248,7 @@ func TestAccProviderConfigure(t *testing.T) { Steps: []resource.TestStep{ { Config: config, - ExpectError: regexp.MustCompile("only one of `app_auth,token` can be specified"), + ExpectError: regexp.MustCompile(`"app_auth": conflicts with token`), }, }, }) @@ -273,7 +273,7 @@ func TestAccProviderConfigure(t *testing.T) { Steps: []resource.TestStep{ { Config: config, - ExpectError: regexp.MustCompile("only one of `app_auth,token` can be specified"), + ExpectError: regexp.MustCompile(`"token": conflicts with app_auth`), }, }, }) From 09ee5c547f282867966810ed1bc2ce5bc7325daf Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Sat, 10 Jan 2026 23:25:14 +0200 Subject: [PATCH 2/5] Add DEBUG message to failed `gh` CLI auth Signed-off-by: Timo Sand --- github/provider.go | 1 + 1 file changed, 1 insertion(+) diff --git a/github/provider.go b/github/provider.go index e49e17b0d0..cd4e905ade 100644 --- a/github/provider.go +++ b/github/provider.go @@ -505,6 +505,7 @@ func tokenFromGHCLI(u *url.URL) string { out, err := exec.Command(ghCliPath, "auth", "token", "--hostname", host).Output() if err != nil { + log.Printf("[DEBUG] Error getting token from GitHub CLI: %s", err.Error()) // GH CLI is either not installed or there was no `gh auth login` command issued, // which is fine. don't return the error to keep the flow going return "" From 746630fc9d8b263711576a9ed4da61137a25d73e Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Sat, 10 Jan 2026 23:26:02 +0200 Subject: [PATCH 3/5] Fix anon test to actually run anonumously Signed-off-by: Timo Sand --- github/provider_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/provider_test.go b/github/provider_test.go index 39cef45ef8..103956c9a0 100644 --- a/github/provider_test.go +++ b/github/provider_test.go @@ -54,12 +54,12 @@ func TestAccProviderConfigure(t *testing.T) { t.Run("can be configured to run anonymously", func(t *testing.T) { config := ` provider "github" { - token = "" } data "github_ip_ranges" "test" {} ` resource.Test(t, resource.TestCase{ + PreCheck: func() { t.Setenv("GITHUB_TOKEN", ""); t.Setenv("GH_PATH", "none-existent-path") }, ProviderFactories: providerFactories, Steps: []resource.TestStep{ { From 4f4991be0ed6c8c1f8b0337652b7c89d85af3045 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Sat, 10 Jan 2026 23:26:46 +0200 Subject: [PATCH 4/5] Change GHES test to be able to run on GHES config Signed-off-by: Timo Sand --- github/provider_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/github/provider_test.go b/github/provider_test.go index 103956c9a0..93508b317b 100644 --- a/github/provider_test.go +++ b/github/provider_test.go @@ -161,10 +161,15 @@ func TestAccProviderConfigure(t *testing.T) { provider "github" { token = "%s" base_url = "%s" - }`, testAccConf.token, testAccConf.owner) + }`, testAccConf.token, testAccConf.baseURL) resource.Test(t, resource.TestCase{ - PreCheck: func() { skipUnlessMode(t, individual) }, + PreCheck: func() { + skipUnlessMode(t, enterprise) + if testAccConf.baseURL.Host != "api.github.com" { + t.Skip("Skipping as test mode is not GHES") + } + }, ProviderFactories: providerFactories, Steps: []resource.TestStep{ { From 2a1bdadf56e864217b6b76b7b9ab9c4ee2ec3ab4 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Sat, 10 Jan 2026 23:29:59 +0200 Subject: [PATCH 5/5] Removed unnecessary skips Signed-off-by: Timo Sand --- github/provider_test.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/github/provider_test.go b/github/provider_test.go index 93508b317b..037c91cbf4 100644 --- a/github/provider_test.go +++ b/github/provider_test.go @@ -192,7 +192,6 @@ func TestAccProviderConfigure(t *testing.T) { `, testAccConf.owner, testMaxRetries) resource.Test(t, resource.TestCase{ - PreCheck: func() { skipUnauthenticated(t) }, ProviderFactories: providerFactories, Steps: []resource.TestStep{ { @@ -216,7 +215,6 @@ func TestAccProviderConfigure(t *testing.T) { `, testAccConf.owner, testMaxPerPage) resource.Test(t, resource.TestCase{ - PreCheck: func() { skipUnauthenticated(t) }, ProviderFactories: providerFactories, Steps: []resource.TestStep{ { @@ -248,7 +246,6 @@ func TestAccProviderConfigure(t *testing.T) { `, testAccConf.owner, testAccConf.token) resource.Test(t, resource.TestCase{ - PreCheck: func() { skipUnauthenticated(t) }, ProviderFactories: providerFactories, Steps: []resource.TestStep{ { @@ -273,7 +270,7 @@ func TestAccProviderConfigure(t *testing.T) { `, testAccConf.owner) resource.Test(t, resource.TestCase{ - PreCheck: func() { skipUnauthenticated(t); t.Setenv("GITHUB_TOKEN", "1234567890") }, + PreCheck: func() { t.Setenv("GITHUB_TOKEN", "1234567890") }, ProviderFactories: providerFactories, Steps: []resource.TestStep{ {