Skip to content

Commit

Permalink
Merge branch 'main' into secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
bpaquet authored Sep 6, 2022
2 parents db11fb8 + 1f14bb2 commit b8e4435
Show file tree
Hide file tree
Showing 1,375 changed files with 189,311 additions and 43,514 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.18'
go-version: '1.19'
- run: make tools
- run: make lint
- run: make website-lint
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# NOTE: CHANGELOG.md is deprecated

After the release of v4.24.0, please see the [GitHub release notes](https://github.com/integrations/terraform-provider-github/releases) for the provider in order to view the most up-to-date changes.

# 4.24.0 (Apr 28, 2022)

ENHANCEMENTS:
Expand Down
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ default: build

tools:
go install github.com/client9/misspell/cmd/misspell
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.48.0

build: fmtcheck
go build ./...
Expand Down
4 changes: 2 additions & 2 deletions github/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/pem"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"time"

Expand Down Expand Up @@ -51,7 +51,7 @@ func getInstallationAccessToken(baseURL string, jwt string, installationID strin
}
defer func() { _ = res.Body.Close() }()

resBytes, err := ioutil.ReadAll(res.Body)
resBytes, err := io.ReadAll(res.Body)
if err != nil {
return "", err
}
Expand Down
6 changes: 3 additions & 3 deletions github/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"crypto/x509"
"encoding/pem"
"fmt"
"io/ioutil"
"os"
"strings"
"testing"
"time"
Expand All @@ -24,7 +24,7 @@ const (
var (
testEpochTime = time.Unix(0, 0)

testGitHubAppPrivateKeyPemData, _ = ioutil.ReadFile(testGitHubAppPrivateKeyFile)
testGitHubAppPrivateKeyPemData, _ = os.ReadFile(testGitHubAppPrivateKeyFile)
)

func TestGenerateAppJWT(t *testing.T) {
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestGenerateAppJWT(t *testing.T) {
})

t.Run("produces a verifiable jwt", func(t *testing.T) {
publicKeyData, err := ioutil.ReadFile(testGitHubAppPublicKeyFile)
publicKeyData, err := os.ReadFile(testGitHubAppPublicKeyFile)
if err != nil {
t.Logf("Failed to read public key file '%s': %s", testGitHubAppPublicKeyFile, err)
t.FailNow()
Expand Down
3 changes: 1 addition & 2 deletions github/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"path"
"time"

"github.com/google/go-github/v45/github"
"github.com/google/go-github/v47/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/logging"
"github.com/shurcooL/githubv4"
"golang.org/x/oauth2"
Expand Down Expand Up @@ -99,7 +99,6 @@ func (c *Config) NewRESTClient(client *http.Client) (*github.Client, error) {
}

func (c *Config) ConfigureOwner(owner *Owner) (*Owner, error) {

ctx := context.Background()
owner.name = c.Owner
if owner.name == "" {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"net/http"

"github.com/google/go-github/v45/github"
"github.com/google/go-github/v47/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_collaborators.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"github.com/google/go-github/v45/github"
"github.com/google/go-github/v47/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
)
Expand Down
74 changes: 74 additions & 0 deletions github/data_source_github_external_groups.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package github

import (
"context"
"encoding/json"
"fmt"

"github.com/google/go-github/v47/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func dataSourceGithubExternalGroups() *schema.Resource {
return &schema.Resource{
Read: dataSourceGithubExternalGroupsRead,
Schema: map[string]*schema.Schema{
"external_groups": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"group_id": {
Type: schema.TypeInt,
Computed: true,
},
"group_name": {
Type: schema.TypeString,
Computed: true,
},
"updated_at": {
Type: schema.TypeString,
Computed: true,
},
},
},
},
},
}
}

func dataSourceGithubExternalGroupsRead(d *schema.ResourceData, meta interface{}) error {
err := checkOrganization(meta)
if err != nil {
return err
}
client := meta.(*Owner).v3client
orgName := meta.(*Owner).name

ctx := context.WithValue(context.Background(), ctxId, d.Id())
opts := &github.ListExternalGroupsOptions{}

externalGroups, _, err := client.Teams.ListExternalGroups(ctx, orgName, opts)
if err != nil {
return err
}

// convert to JSON in order to martial to format we can return
jsonGroups, err := json.Marshal(externalGroups.Groups)
if err != nil {
return err
}

groupsState := make([]map[string]interface{}, 0)
err = json.Unmarshal(jsonGroups, &groupsState)
if err != nil {
return err
}

if err := d.Set("external_groups", groupsState); err != nil {
return err
}

d.SetId(fmt.Sprintf("/orgs/%v/external-groups", orgName))
return nil
}
50 changes: 50 additions & 0 deletions github/data_source_github_ip_ranges.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ func dataSourceGithubIpRanges() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"web": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"api": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"pages": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -52,6 +62,16 @@ func dataSourceGithubIpRanges() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"web_ipv4": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"api_ipv4": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"pages_ipv4": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -82,6 +102,16 @@ func dataSourceGithubIpRanges() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"web_ipv6": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"api_ipv6": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"pages_ipv6": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -144,6 +174,16 @@ func dataSourceGithubIpRangesRead(d *schema.ResourceData, meta interface{}) erro
return err
}

cidrWebIpv4, cidrWebIpv6, err := splitIpv4Ipv6Cidrs(&api.Web)
if err != nil {
return err
}

cidrApiIpv4, cidrApiIpv6, err := splitIpv4Ipv6Cidrs(&api.API)
if err != nil {
return err
}

if len(api.Hooks)+len(api.Git)+len(api.Pages)+len(api.Importer)+len(api.Actions)+len(api.Dependabot) > 0 {
d.SetId("github-ip-ranges")
}
Expand Down Expand Up @@ -177,6 +217,16 @@ func dataSourceGithubIpRangesRead(d *schema.ResourceData, meta interface{}) erro
d.Set("dependabot_ipv4", cidrDependabotIpv4)
d.Set("dependabot_ipv6", cidrDependabotIpv6)
}
if len(api.Web) > 0 {
d.Set("web", api.Web)
d.Set("web_ipv4", cidrWebIpv4)
d.Set("web_ipv6", cidrWebIpv6)
}
if len(api.API) > 0 {
d.Set("api", api.API)
d.Set("api_ipv4", cidrApiIpv4)
d.Set("api_ipv6", cidrApiIpv6)
}

return nil
}
Expand Down
6 changes: 6 additions & 0 deletions github/data_source_github_ip_ranges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@ func TestAccGithubIpRangesDataSource(t *testing.T) {
check := resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "hooks.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "git.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "api.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "web.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "pages.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "importer.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "actions.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "dependabot.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "hooks_ipv4.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "git_ipv4.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "api_ipv4.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "web_ipv4.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "pages_ipv4.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "importer_ipv4.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "actions_ipv4.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "dependabot_ipv4.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "hooks_ipv6.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "git_ipv6.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "api_ipv6.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "web_ipv6.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "pages_ipv6.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "importer_ipv6.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "actions_ipv6.#"),
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package github
import (
"strconv"

"github.com/google/go-github/v45/github"
"github.com/google/go-github/v47/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_organization_team_sync_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"github.com/google/go-github/v45/github"
"github.com/google/go-github/v47/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"net/http"

"github.com/google/go-github/v45/github"
"github.com/google/go-github/v47/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/helper/validation"

"github.com/google/go-github/v45/github"
"github.com/google/go-github/v47/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package github
import (
"context"

"github.com/google/go-github/v45/github"
"github.com/google/go-github/v47/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
)
Expand Down
22 changes: 21 additions & 1 deletion github/data_source_github_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http"
"strings"

"github.com/google/go-github/v45/github"
"github.com/google/go-github/v47/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down Expand Up @@ -84,6 +84,22 @@ func dataSourceGithubRepository() *schema.Resource {
Type: schema.TypeBool,
Computed: true,
},
"squash_merge_commit_title": {
Type: schema.TypeString,
Computed: true,
},
"squash_merge_commit_message": {
Type: schema.TypeString,
Computed: true,
},
"merge_commit_title": {
Type: schema.TypeString,
Computed: true,
},
"merge_commit_message": {
Type: schema.TypeString,
Computed: true,
},
"default_branch": {
Type: schema.TypeString,
Computed: true,
Expand Down Expand Up @@ -234,6 +250,10 @@ func dataSourceGithubRepositoryRead(d *schema.ResourceData, meta interface{}) er
d.Set("allow_squash_merge", repo.GetAllowSquashMerge())
d.Set("allow_rebase_merge", repo.GetAllowRebaseMerge())
d.Set("allow_auto_merge", repo.GetAllowAutoMerge())
d.Set("squash_merge_commit_title", repo.GetSquashMergeCommitTitle())
d.Set("squash_merge_commit_message", repo.GetSquashMergeCommitMessage())
d.Set("merge_commit_title", repo.GetMergeCommitTitle())
d.Set("merge_commit_message", repo.GetMergeCommitMessage())
d.Set("has_downloads", repo.GetHasDownloads())
d.Set("full_name", repo.GetFullName())
d.Set("default_branch", repo.GetDefaultBranch())
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_repository_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"log"

"github.com/google/go-github/v45/github"
"github.com/google/go-github/v47/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_repository_pull_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"strings"

"github.com/google/go-github/v45/github"
"github.com/google/go-github/v47/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
)
Expand Down
Loading

0 comments on commit b8e4435

Please sign in to comment.