From eee8ea8b2959e44748663bb3a2f8ea97ee3bb454 Mon Sep 17 00:00:00 2001 From: Jeremy Udit Date: Tue, 28 Jul 2020 17:00:36 -0400 Subject: [PATCH] Ensure Owner Or Organization Present /cc https://github.com/terraform-providers/terraform-provider-github/pull/521#discussion_r461593258 --- github/provider_utils.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/github/provider_utils.go b/github/provider_utils.go index 4f2602dc19..68634492f5 100644 --- a/github/provider_utils.go +++ b/github/provider_utils.go @@ -47,13 +47,23 @@ func testAccPreCheck(t *testing.T) { } func testAccCheckOrganization() error { + baseURL := os.Getenv("GITHUB_BASE_URL") token := os.Getenv("GITHUB_TOKEN") + owner := os.Getenv("GITHUB_OWNER") + if owner == "" { + organization := os.Getenv("GITHUB_ORGANIZATION") + if organization == "" { + return fmt.Errorf("Neither `GITHUB_OWNER` or `GITHUB_ORGANIZATION` set in environment") + } + owner = organization + } + config := Config{ BaseURL: baseURL, Token: token, - Owner: testOwner, + Owner: owner, } meta, err := config.Meta()