Skip to content

Commit

Permalink
Merge branch 'main' into v6
Browse files Browse the repository at this point in the history
  • Loading branch information
kfcampbell committed Feb 2, 2024
2 parents 8bed68e + 970dd20 commit f73621b
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/immediate-response.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
run: echo "NUMBER=${{ github.event.issue.number || github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"

- name: Respond to issue or PR
uses: peter-evans/create-or-update-comment@v3
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ steps.extract.outputs.NUMBER }}
body: >
Expand Down
25 changes: 25 additions & 0 deletions github/data_source_github_ip_ranges.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ func dataSourceGithubIpRanges() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"packages": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"pages": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -72,6 +77,11 @@ func dataSourceGithubIpRanges() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"packages_ipv4": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"pages_ipv4": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -112,6 +122,11 @@ func dataSourceGithubIpRanges() *schema.Resource {
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"packages_ipv6": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"pages_ipv6": {
Type: schema.TypeList,
Computed: true,
Expand Down Expand Up @@ -154,6 +169,11 @@ func dataSourceGithubIpRangesRead(d *schema.ResourceData, meta interface{}) erro
return err
}

cidrPackagesIpv4, cidrPackagesIpv6, err := splitIpv4Ipv6Cidrs(&api.Packages)
if err != nil {
return err
}

cidrPagesIpv4, cidrPagesIpv6, err := splitIpv4Ipv6Cidrs(&api.Pages)
if err != nil {
return err
Expand Down Expand Up @@ -215,6 +235,11 @@ func dataSourceGithubIpRangesRead(d *schema.ResourceData, meta interface{}) erro
return err
}
}
if len(api.Packages) > 0 {
d.Set("packages", api.Packages)
d.Set("packages_ipv4", cidrPackagesIpv4)
d.Set("packages_ipv6", cidrPackagesIpv6)
}
if len(api.Pages) > 0 {
err = d.Set("pages", api.Pages)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions github/data_source_github_ip_ranges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func TestAccGithubIpRangesDataSource(t *testing.T) {
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", "packages.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "pages.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "importer.#"),
resource.TestCheckResourceAttrSet("data.github_ip_ranges.test", "actions.#"),
Expand All @@ -25,6 +26,7 @@ func TestAccGithubIpRangesDataSource(t *testing.T) {
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", "packages_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.#"),
Expand All @@ -33,6 +35,7 @@ func TestAccGithubIpRangesDataSource(t *testing.T) {
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", "packages_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
20 changes: 15 additions & 5 deletions github/data_source_github_rest_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package github

import (
"context"
"encoding/json"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand All @@ -25,11 +26,11 @@ func dataSourceGithubRestApi() *schema.Resource {
Computed: true,
},
"headers": {
Type: schema.TypeMap,
Type: schema.TypeString,
Computed: true,
},
"body": {
Type: schema.TypeMap,
Type: schema.TypeString,
Computed: true,
},
},
Expand All @@ -51,19 +52,28 @@ func dataSourceGithubRestApiRead(d *schema.ResourceData, meta interface{}) error

resp, _ := client.Do(ctx, req, &body)

h, err := json.Marshal(resp.Header)
if err != nil {
return err
}

b, err := json.Marshal(body)
if err != nil {
return err
}

d.SetId(resp.Header.Get("x-github-request-id"))
if err = d.Set("code", resp.StatusCode); err != nil {
return err
}
if err = d.Set("status", resp.Status); err != nil {
return err
}
if err = d.Set("headers", resp.Header); err != nil {
if err = d.Set("headers", string(h)); err != nil {
return err
}
if err = d.Set("body", body); err != nil {
if err = d.Set("body", string(b)); err != nil {
return err
}

return nil
}
10 changes: 10 additions & 0 deletions github/data_source_github_rest_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ func TestAccGithubRestApiDataSource(t *testing.T) {
resource.TestMatchResourceAttr(
"data.github_rest_api.test", "code", regexp.MustCompile("200"),
),
resource.TestMatchResourceAttr(
"data.github_rest_api.test", "status", regexp.MustCompile("200 OK"),
),
resource.TestCheckResourceAttrSet("data.github_rest_api.test", "body"),
resource.TestCheckResourceAttrSet("data.github_rest_api.test", "headers"),
)

testCase := func(t *testing.T, mode string) {
Expand Down Expand Up @@ -76,6 +81,11 @@ func TestAccGithubRestApiDataSource(t *testing.T) {
resource.TestMatchResourceAttr(
"data.github_rest_api.test", "code", regexp.MustCompile("404"),
),
resource.TestMatchResourceAttr(
"data.github_rest_api.test", "status", regexp.MustCompile("404 Not Found"),
),
resource.TestCheckResourceAttrSet("data.github_rest_api.test", "body"),
resource.TestCheckResourceAttrSet("data.github_rest_api.test", "headers"),
)

testCase := func(t *testing.T, mode string) {
Expand Down
29 changes: 13 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,26 @@ require (
github.com/client9/misspell v0.3.4
github.com/golangci/golangci-lint v1.41.1
github.com/google/go-github/v57 v57.0.0
github.com/google/uuid v1.5.0
github.com/google/uuid v1.6.0
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0
github.com/shurcooL/githubv4 v0.0.0-20221126192849-0b5c4c7994eb
github.com/stretchr/testify v1.8.4
golang.org/x/crypto v0.18.0
golang.org/x/oauth2 v0.16.0
gopkg.in/square/go-jose.v2 v2.6.0
)

require (
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/hashicorp/hc-install v0.6.2 // indirect
github.com/hashicorp/terraform-plugin-go v0.20.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
)

require (
4d63.com/gochecknoglobals v0.1.0 // indirect
github.com/BurntSushi/toml v1.2.1 // indirect
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/OpenPeeDeeP/depguard v1.1.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/alexkohler/prealloc v1.0.0 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/ashanbrown/forbidigo v1.3.0 // indirect
github.com/ashanbrown/makezero v1.1.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand All @@ -45,6 +34,7 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/charithe/durationcheck v0.0.9 // indirect
github.com/chavacava/garif v0.0.0-20220630083739-93517212f375 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/daixiang0/gci v0.2.9 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/denis-tingajkin/go-header v0.4.2 // indirect
Expand Down Expand Up @@ -91,12 +81,16 @@ require (
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hc-install v0.6.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/hcl/v2 v2.19.1 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.19.0 // indirect
github.com/hashicorp/terraform-json v0.18.0 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0
github.com/hashicorp/terraform-plugin-go v0.20.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/jgautheron/goconst v1.5.1 // indirect
Expand Down Expand Up @@ -172,6 +166,9 @@ require (
github.com/ultraware/funlen v0.0.3 // indirect
github.com/ultraware/whitespace v0.0.5 // indirect
github.com/uudashr/gocognit v1.0.6 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/yeya24/promlinter v0.2.0 // indirect
github.com/zclconf/go-cty v1.14.1 // indirect
golang.org/x/exp/typeparams v0.0.0-20220827204233-334a2380cb91 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c/go.mod h1:TIyPZe4Mgqvf
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
Expand Down
13 changes: 13 additions & 0 deletions vendor/github.com/google/uuid/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions vendor/github.com/google/uuid/hash.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 34 additions & 5 deletions vendor/github.com/google/uuid/version7.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ github.com/google/go-github/v57/github
# github.com/google/go-querystring v1.1.0
## explicit; go 1.10
github.com/google/go-querystring/query
# github.com/google/uuid v1.5.0
# github.com/google/uuid v1.6.0
## explicit
github.com/google/uuid
# github.com/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8
Expand Down
3 changes: 3 additions & 0 deletions website/docs/d/ip_ranges.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ data "github_ip_ranges" "test" {}
* `api` - An Array of IP addresses in CIDR format for the GitHub API.
* `api_ipv4` - A subset of the `api` array that contains IP addresses in IPv4 CIDR format.
* `api_ipv6` - A subset of the `api` array that contains IP addresses in IPv6 CIDR format.
* `packages` - An Array of IP addresses in CIDR format specifying the A records for GitHub Packages.
* `packages_ipv4` - A subset of the `packages` array that contains IP addresses in IPv4 CIDR format.
* `packages_ipv6` - A subset of the `packages` array that contains IP addresses in IPv6 CIDR format.
* `pages` - An Array of IP addresses in CIDR format specifying the A records for GitHub Pages.
* `pages_ipv4` - A subset of the `pages` array that contains IP addresses in IPv4 CIDR format.
* `pages_ipv6` - A subset of the `pages` array that contains IP addresses in IPv6 CIDR format.
Expand Down
5 changes: 3 additions & 2 deletions website/docs/d/rest_api.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ data "github_rest_api" "example" {

## Attributes Reference

* `id` - The GitHub API Request ID
* `code` - A response status code.
* `status` - A response status string.
* `headers` - A map of response headers.
* `body` - A map of response body.
* `headers` - A JSON string containing response headers.
* `body` - A JSON string containing response body.

0 comments on commit f73621b

Please sign in to comment.