Skip to content

Commit b46999d

Browse files
authored
fix: Revert provider input constraints (#3099)
Signed-off-by: Steve Hipwell <[email protected]>
1 parent d519f0d commit b46999d

2 files changed

Lines changed: 39 additions & 37 deletions

File tree

github/provider.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ func Provider() *schema.Provider {
1818
p := &schema.Provider{
1919
Schema: map[string]*schema.Schema{
2020
"token": {
21-
Type: schema.TypeString,
22-
Optional: true,
23-
DefaultFunc: schema.EnvDefaultFunc("GITHUB_TOKEN", nil),
24-
Description: descriptions["token"],
25-
ConflictsWith: []string{"app_auth"},
21+
Type: schema.TypeString,
22+
Optional: true,
23+
DefaultFunc: schema.EnvDefaultFunc("GITHUB_TOKEN", nil),
24+
Description: descriptions["token"],
25+
// ConflictsWith: []string{"app_auth"}, // TODO: Enable as part of v7.
2626
},
2727
"owner": {
2828
Type: schema.TypeString,
@@ -94,11 +94,11 @@ func Provider() *schema.Provider {
9494
Description: descriptions["parallel_requests"],
9595
},
9696
"app_auth": {
97-
Type: schema.TypeList,
98-
Optional: true,
99-
MaxItems: 1,
100-
Description: descriptions["app_auth"],
101-
ConflictsWith: []string{"token"},
97+
Type: schema.TypeList,
98+
Optional: true,
99+
MaxItems: 1,
100+
Description: descriptions["app_auth"],
101+
// ConflictsWith: []string{"token"}, // TODO: Enable as part of v7.
102102
Elem: &schema.Resource{
103103
Schema: map[string]*schema.Schema{
104104
"id": {

github/provider_test.go

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestProvider(t *testing.T) {
5151
}
5252

5353
func TestAccProviderConfigure(t *testing.T) {
54-
t.Run("can be configured to run anonymously", func(t *testing.T) {
54+
t.Run("can_be_configured_to_run_anonymously", func(t *testing.T) {
5555
config := `
5656
provider "github" {
5757
}
@@ -71,10 +71,36 @@ func TestAccProviderConfigure(t *testing.T) {
7171
})
7272
})
7373

74+
t.Run("can_be_configured_with_app_auth_and_ignore_github_token", func(t *testing.T) {
75+
t.Skip("This test requires a valid app auth setup to run.")
76+
config := fmt.Sprintf(`
77+
provider "github" {
78+
owner = "%s"
79+
app_auth {
80+
id = "1234567890"
81+
installation_id = "1234567890"
82+
pem_file = "1234567890"
83+
}
84+
}
85+
86+
data "github_ip_ranges" "test" {}
87+
`, testAccConf.owner)
88+
89+
resource.Test(t, resource.TestCase{
90+
PreCheck: func() { t.Setenv("GITHUB_TOKEN", "1234567890") },
91+
ProviderFactories: providerFactories,
92+
Steps: []resource.TestStep{
93+
{
94+
Config: config,
95+
ExpectNonEmptyPlan: false,
96+
},
97+
},
98+
})
99+
})
100+
74101
t.Run("can be configured to run insecurely", func(t *testing.T) {
75102
config := `
76103
provider "github" {
77-
token = ""
78104
insecure = true
79105
}
80106
data "github_ip_ranges" "test" {}
@@ -231,6 +257,7 @@ func TestAccProviderConfigure(t *testing.T) {
231257
})
232258
})
233259
t.Run("should not allow both token and app_auth to be configured", func(t *testing.T) {
260+
t.Skip("This would be a semver breaking change, this will be reinstated for v7.")
234261
config := fmt.Sprintf(`
235262
provider "github" {
236263
owner = "%s"
@@ -255,29 +282,4 @@ func TestAccProviderConfigure(t *testing.T) {
255282
},
256283
})
257284
})
258-
t.Run("should not allow app_auth and GITHUB_TOKEN to be configured", func(t *testing.T) {
259-
config := fmt.Sprintf(`
260-
provider "github" {
261-
owner = "%s"
262-
app_auth {
263-
id = "1234567890"
264-
installation_id = "1234567890"
265-
pem_file = "1234567890"
266-
}
267-
}
268-
269-
data "github_ip_ranges" "test" {}
270-
`, testAccConf.owner)
271-
272-
resource.Test(t, resource.TestCase{
273-
PreCheck: func() { t.Setenv("GITHUB_TOKEN", "1234567890") },
274-
ProviderFactories: providerFactories,
275-
Steps: []resource.TestStep{
276-
{
277-
Config: config,
278-
ExpectError: regexp.MustCompile(`"token": conflicts with app_auth`),
279-
},
280-
},
281-
})
282-
})
283285
}

0 commit comments

Comments
 (0)