Repository: google/go-github
Pull request #1778 (2021-01-15 19:36:19)

Extend IP ranges in meta API
GitHub have added two extra IP address types in the `/meta` API. That is `actions` and `dependabot`.

I have extended the `APIMeta` method and struct with that new data, so we can consume it.

Closes https://github.com/google/go-github/issues/1777

google-cla[bot]: 
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: **Please visit <https://cla.developers.google.com/> to sign.**

Once you've signed (or fixed any issues), please reply here with `@googlebot I signed it!` and we'll verify it.

----

#### What to do if you already signed the CLA

##### Individual signers

*   It's possible we don't have your GitHub username or you're using a different email address on your commit. Check [your existing CLA data](https://cla.developers.google.com/clas) and verify that your [email is set on your git commits](https://help.github.com/articles/setting-your-email-in-git/).

##### Corporate signers

*   Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the Google project maintainer to [go/cla#troubleshoot](http://go/cla#troubleshoot) ([Public version](https://opensource.google/docs/cla/#troubleshoot)).
*   The email used to register you as an authorized contributor must be the email used for the Git commit. Check [your existing CLA data](https://cla.developers.google.com/clas) and verify that your [email is set on your git commits](https://help.github.com/articles/setting-your-email-in-git/).
*   The email used to register you as an authorized contributor must also be [attached to your GitHub account](https://github.com/settings/emails).
		

ℹ️ **Googlers: [Go here](https://goto.google.com/prinfo/https%3A%2F%2Fgithub.com%2Fgoogle%2Fgo-github%2Fpull%2F1778) for more info**.

<!-- need_sender_cla -->
sorenhansendk: @googlebot I signed it!
codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/1778?src=pr&el=h1) Report
> Merging [#1778](https://codecov.io/gh/google/go-github/pull/1778?src=pr&el=desc) (0f13077) into [master](https://codecov.io/gh/google/go-github/commit/9318e629ec694193e3b982ae5764359b96e296e1?el=desc) (9318e62) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/google/go-github/pull/1778/graphs/tree.svg?width=650&height=150&src=pr&token=EgYjGjZlI0)](https://codecov.io/gh/google/go-github/pull/1778?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #1778   +/-   ##
=======================================
  Coverage   97.53%   97.53%           
=======================================
  Files          98       98           
  Lines        6382     6382           
=======================================
  Hits         6225     6225           
  Misses         85       85           
  Partials       72       72           
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/1778?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [github/misc.go](https://codecov.io/gh/google/go-github/pull/1778/diff?src=pr&el=tree#diff-Z2l0aHViL21pc2MuZ28=) | `97.46% <ø> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/go-github/pull/1778?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/go-github/pull/1778?src=pr&el=footer). Last update [9318e62...0f13077](https://codecov.io/gh/google/go-github/pull/1778?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

gmlewis: Thank you, @sorenhansendk !
Would you mind adding a URL link to the GitHub developer docs that describe these fields in their respective comments?
sorenhansendk: Oh, yes! https://docs.github.com/en/free-pro-team@latest/rest/reference/meta#get-github-meta-information

The `dependabot` property is not in the example response, but if you execute this you will see it 👍 

**Request:**

<pre>
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/met
</pre>

**Response:**

<pre>
{
  "verifiable_password_authentication": false,
  "ssh_key_fingerprints": {
    "SHA256_RSA": "nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8",
    "SHA256_DSA": "br9IjFspm1vxR3iA35FWE+4VTyz1hYVLIE2t1/CeyWQ"
  },
  "hooks": [
    "192.30.252.0/22",
    ...
  ],
  "web": [
    "192.30.252.0/22",
    ...
  ],
  "git": [
    "192.30.252.0/22",
    ...
  ],
  "pages": [
    "192.30.252.153/32",
    ...
  ],
  "importer": [
    "192.30.252.0/22",
    ...
  ],
  "actions": [
    "13.64.0.0/16",
    ...
  ],
  "dependabot": [
    "18.213.123.130/32",
    ...
  ]
}
</pre>
sorenhansendk: @gmlewis Done - https://github.com/google/go-github/pull/1778/commits/bbea7eb9c776015b3d44547856e35d5ef7a953eb

Patch:
diff --git a/github/misc.go b/github/misc.go
index 458b6f7d..1fa6c4e1 100644
--- a/github/misc.go
+++ b/github/misc.go
@@ -162,13 +162,21 @@ type APIMeta struct {
 	// An Array of IP addresses specifying the addresses that source imports
 	// will originate from on GitHub.com.
 	Importer []string `json:"importer,omitempty"`
+
+	// An array of IP addresses in CIDR format specifying the IP addresses
+	// GitHub Actions will originate from.
+	Actions []string `json:"actions,omitempty"`
+
+	// An array of IP addresses in CIDR format specifying the IP addresses
+	// Dependabot will originate from.
+	Dependabot []string `json:"dependabot,omitempty"`
 }
 
 // APIMeta returns information about GitHub.com, the service. Or, if you access
 // this endpoint on your organization’s GitHub Enterprise installation, this
 // endpoint provides information about that installation.
 //
-// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/meta/
+// GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/meta#get-github-meta-information
 func (c *Client) APIMeta(ctx context.Context) (*APIMeta, *Response, error) {
 	req, err := c.NewRequest("GET", "meta", nil)
 	if err != nil {


Test patch:
diff --git a/github/misc_test.go b/github/misc_test.go
index c283de2b..7cab3f48 100644
--- a/github/misc_test.go
+++ b/github/misc_test.go
@@ -185,12 +185,17 @@ func TestAPIMeta_marshal(t *testing.T) {
 		VerifiablePasswordAuthentication: Bool(true),
 		Pages:                            []string{"p"},
 		Importer:                         []string{"i"},
+		Actions:                          []string{"a"},
+		Dependabot:                       []string{"d"},
 	}
 	want := `{
 		"hooks":["h"],
 		"git":["g"],
 		"verifiable_password_authentication":true,
-		"pages":["p"],"importer":["i"]
+		"pages":["p"],
+		"importer":["i"],
+		"actions":["a"],
+		"dependabot":["d"]
 	}`
 
 	testJSONMarshal(t, a, want)
@@ -202,7 +207,7 @@ func TestAPIMeta(t *testing.T) {
 
 	mux.HandleFunc("/meta", func(w http.ResponseWriter, r *http.Request) {
 		testMethod(t, r, "GET")
-		fmt.Fprint(w, `{"hooks":["h"], "git":["g"], "pages":["p"], "importer":["i"], "verifiable_password_authentication": true}`)
+		fmt.Fprint(w, `{"hooks":["h"], "git":["g"], "pages":["p"], "importer":["i"], "actions":["a"], "dependabot":["d"], "verifiable_password_authentication": true}`)
 	})
 
 	ctx := context.Background()
@@ -212,10 +217,12 @@ func TestAPIMeta(t *testing.T) {
 	}
 
 	want := &APIMeta{
-		Hooks:    []string{"h"},
-		Git:      []string{"g"},
-		Pages:    []string{"p"},
-		Importer: []string{"i"},
+		Hooks:      []string{"h"},
+		Git:        []string{"g"},
+		Pages:      []string{"p"},
+		Importer:   []string{"i"},
+		Actions:    []string{"a"},
+		Dependabot: []string{"d"},
 
 		VerifiablePasswordAuthentication: Bool(true),
 	}