Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions github/enterprise_manage_ghes_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
}

// LicenseStatus is a struct to hold the response from the License API.
// SupportKey is documented as string but is actual a bool.
// TODO: Remove comment after github updates schema documentation

Check failure on line 74 in github/enterprise_manage_ghes_config.go

View workflow job for this annotation

GitHub Actions / golangci-lint

Comment should end in a period (godot)
type LicenseStatus struct {
AdvancedSecurityEnabled *bool `json:"advancedSecurityEnabled,omitempty"`
AdvancedSecuritySeats *int `json:"advancedSecuritySeats,omitempty"`
Expand All @@ -87,8 +89,10 @@
ReferenceNumber *string `json:"referenceNumber,omitempty"`
Seats *int `json:"seats,omitempty"`
SSHAllowed *bool `json:"sshAllowed,omitempty"`
SupportKey *string `json:"supportKey,omitempty"`
// SupportKey is documented as a string, but the actual response is a bool.
// TODO: Remove this note once GitHub corrects the schema documentation.
SupportKey *bool `json:"supportKey,omitempty"`
UnlimitedSeating *bool `json:"unlimitedSeating,omitempty"`

Check failure on line 95 in github/enterprise_manage_ghes_config.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not properly formatted (gci)
}

// UploadLicenseOptions is a struct to hold the options for the UploadLicense API.
Expand Down Expand Up @@ -354,14 +358,16 @@
// GitHub API docs: https://docs.github.com/enterprise-server@3.21/rest/enterprise-admin/manage-ghes#get-the-enterprise-license-information
//
//meta:operation GET /manage/v1/config/license
func (s *EnterpriseService) License(ctx context.Context) ([]*LicenseStatus, *Response, error) {
// Current Docs shouw incorrect return type. They list as [{...}] but actual is {...}
// TODO: Remove comment after github updates schema documentation
func (s *EnterpriseService) License(ctx context.Context) (*LicenseStatus, *Response, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a comment to the function that GitHub documentation is wrong about the response.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Their last response was:

We’ll treat this as a documentation/schema mismatch and route it for review so the example can be corrected to match the actual GHES behavior.

Eventually it should be corrected, in that case wouldn't that cause confusion?

u := "manage/v1/config/license"
req, err := s.client.NewRequest(ctx, "GET", u, nil)
if err != nil {
return nil, nil, err
}

var licenseStatus []*LicenseStatus
var licenseStatus *LicenseStatus
resp, err := s.client.Do(req, &licenseStatus)
if err != nil {
return nil, resp, err
Expand Down
12 changes: 6 additions & 6 deletions github/enterprise_manage_ghes_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func TestEnterpriseService_License(t *testing.T) {

mux.HandleFunc("/manage/v1/config/license", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `[{
fmt.Fprint(w, `{
"advancedSecurityEnabled": true,
"advancedSecuritySeats": 0,
"clusterSupport": false,
Expand All @@ -424,9 +424,9 @@ func TestEnterpriseService_License(t *testing.T) {
"referenceNumber": "32a145",
"seats": 0,
"sshAllowed": true,
"supportKey": "",
"supportKey": true,
"unlimitedSeating": true
}]`)
}`)
})

ctx := t.Context()
Expand All @@ -435,7 +435,7 @@ func TestEnterpriseService_License(t *testing.T) {
t.Errorf("Enterprise.License returned error: %v", err)
}

want := []*LicenseStatus{{
want := &LicenseStatus{
AdvancedSecurityEnabled: Ptr(true),
AdvancedSecuritySeats: Ptr(0),
ClusterSupport: Ptr(false),
Expand All @@ -452,9 +452,9 @@ func TestEnterpriseService_License(t *testing.T) {
ReferenceNumber: Ptr("32a145"),
Seats: Ptr(0),
SSHAllowed: Ptr(true),
SupportKey: Ptr(""),
SupportKey: Ptr(true),
UnlimitedSeating: Ptr(true),
}}
}
if diff := cmp.Diff(want, license); diff != "" {
t.Errorf("diff mismatch (-want +got):\n%v", diff)
}
Expand Down
4 changes: 2 additions & 2 deletions github/github-accessors.go

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

2 changes: 1 addition & 1 deletion github/github-accessors_test.go

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

Loading