Repository: google/go-github
Pull request #2293 (2022-02-17 00:23:35)

Add APIMeta fields related to SSH keys
As described in https://docs.github.com/en/rest/reference/meta.

gmlewis: Thank you, @twpayne !  Please run `go generate ./...` and push the changes to the PR.
See CONTRIBUTING.md for more information.
twpayne: 🙈 Doh! Sorry about missing that. In updating this I also deliberately made the faux pas of modifying the original commit with a forced push, but I hope it's OK in this case as the extra changes are automatically generated.
codecov[bot]: # [Codecov](https://codecov.io/gh/google/go-github/pull/2293?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> Merging [#2293](https://codecov.io/gh/google/go-github/pull/2293?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (2ec5da9) into [master](https://codecov.io/gh/google/go-github/commit/2981e4f9a39e392bbd3234e4cce8aab6efc1daad?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (2981e4f) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/google/go-github/pull/2293/graphs/tree.svg?width=650&height=150&src=pr&token=EgYjGjZlI0&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)](https://codecov.io/gh/google/go-github/pull/2293?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)

```diff
@@           Coverage Diff           @@
##           master    #2293   +/-   ##
=======================================
  Coverage   97.84%   97.84%           
=======================================
  Files         115      115           
  Lines       10378    10378           
=======================================
  Hits        10154    10154           
  Misses        156      156           
  Partials       68       68           
```


| [Impacted Files](https://codecov.io/gh/google/go-github/pull/2293?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Coverage Δ | |
|---|---|---|
| [github/misc.go](https://codecov.io/gh/google/go-github/pull/2293/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL21pc2MuZ28=) | `96.36% <ø> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/go-github/pull/2293?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/go-github/pull/2293?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Last update [2981e4f...2ec5da9](https://codecov.io/gh/google/go-github/pull/2293?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).


Patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 3be5bdd3..6c13f545 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -316,6 +316,14 @@ func (a *AnalysesListOptions) GetSarifID() string {
 	return *a.SarifID
 }
 
+// GetSSHKeyFingerprints returns the SSHKeyFingerprints map if it's non-nil, an empty map otherwise.
+func (a *APIMeta) GetSSHKeyFingerprints() map[string]string {
+	if a == nil || a.SSHKeyFingerprints == nil {
+		return map[string]string{}
+	}
+	return a.SSHKeyFingerprints
+}
+
 // GetVerifiablePasswordAuthentication returns the VerifiablePasswordAuthentication field if it's non-nil, zero value otherwise.
 func (a *APIMeta) GetVerifiablePasswordAuthentication() bool {
 	if a == nil || a.VerifiablePasswordAuthentication == nil {
diff --git a/github/misc.go b/github/misc.go
index 1fa6c4e1..7672e08a 100644
--- a/github/misc.go
+++ b/github/misc.go
@@ -170,6 +170,12 @@ type APIMeta struct {
 	// An array of IP addresses in CIDR format specifying the IP addresses
 	// Dependabot will originate from.
 	Dependabot []string `json:"dependabot,omitempty"`
+
+	// A map of algorithms to SSH key fingerprints.
+	SSHKeyFingerprints map[string]string `json:"ssh_key_fingerprints,omitempty"`
+
+	// An array of SSH keys.
+	SSHKeys []string `json:"ssh_keys,omitempty"`
 }
 
 // APIMeta returns information about GitHub.com, the service. Or, if you access


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 986b8c7e..d06e6356 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -348,6 +348,16 @@ func TestAnalysesListOptions_GetSarifID(tt *testing.T) {
 	a.GetSarifID()
 }
 
+func TestAPIMeta_GetSSHKeyFingerprints(tt *testing.T) {
+	zeroValue := map[string]string{}
+	a := &APIMeta{SSHKeyFingerprints: zeroValue}
+	a.GetSSHKeyFingerprints()
+	a = &APIMeta{}
+	a.GetSSHKeyFingerprints()
+	a = nil
+	a.GetSSHKeyFingerprints()
+}
+
 func TestAPIMeta_GetVerifiablePasswordAuthentication(tt *testing.T) {
 	var zeroValue bool
 	a := &APIMeta{VerifiablePasswordAuthentication: &zeroValue}
diff --git a/github/misc_test.go b/github/misc_test.go
index 8b15fd46..fc91d712 100644
--- a/github/misc_test.go
+++ b/github/misc_test.go
@@ -188,6 +188,8 @@ func TestAPIMeta_Marshal(t *testing.T) {
 		Importer:                         []string{"i"},
 		Actions:                          []string{"a"},
 		Dependabot:                       []string{"d"},
+		SSHKeyFingerprints:               map[string]string{"a": "f"},
+		SSHKeys:                          []string{"k"},
 	}
 	want := `{
 		"hooks":["h"],
@@ -196,7 +198,9 @@ func TestAPIMeta_Marshal(t *testing.T) {
 		"pages":["p"],
 		"importer":["i"],
 		"actions":["a"],
-		"dependabot":["d"]
+		"dependabot":["d"],
+		"ssh_key_fingerprints":{"a":"f"},
+		"ssh_keys":["k"]
 	}`
 
 	testJSONMarshal(t, a, want)