diff --git a/github/github-accessors.go b/github/github-accessors.go index 3be5bdd34d..6c13f545cd 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/github-accessors_test.go b/github/github-accessors_test.go index 986b8c7e36..d06e6356d7 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.go b/github/misc.go index 1fa6c4e130..7672e08acc 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 diff --git a/github/misc_test.go b/github/misc_test.go index 8b15fd4631..fc91d71294 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)