Skip to content

Commit

Permalink
Add owner attribute for reading public repos
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolay Mishin committed Oct 7, 2023
1 parent 680c66e commit 9c35b8d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
15 changes: 5 additions & 10 deletions github/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,12 @@ func (c *Config) Meta() (interface{}, error) {
owner.v4client = v4client
owner.v3client = v3client

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

type previewHeaderInjectorTransport struct {
Expand Down
22 changes: 22 additions & 0 deletions github/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,28 @@ func TestAccProviderConfigure(t *testing.T) {

})

t.Run("can be configured to run with an individual accoun without token", func(t *testing.T) {

config := fmt.Sprintf(`
provider "github" {
owner = "%s"
}`,
testOwnerFunc(),
)

resource.Test(t, resource.TestCase{
PreCheck: func() { skipUnlessMode(t, anonymous) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: config,
ExpectNonEmptyPlan: false,
},
},
})

})

t.Run("can be configured to run insecurely", func(t *testing.T) {

config := fmt.Sprintf(`
Expand Down

0 comments on commit 9c35b8d

Please sign in to comment.