Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add manage_ghes endpoints introduced in 3.15 #3433

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

s4mur4i
Copy link

@s4mur4i s4mur4i commented Jan 15, 2025

closes #3415

@gmlewis gmlewis changed the title feat: Adding manage_ghes endpoints introduced in 3.15 feat: Add manage_ghes endpoints introduced in 3.15 Jan 15, 2025
Copy link

codecov bot commented Jan 15, 2025

Codecov Report

Attention: Patch coverage is 94.00000% with 15 lines in your changes missing coverage. Please review.

Project coverage is 92.29%. Comparing base (2b8c7fa) to head (c4121e9).
Report is 223 commits behind head on master.

Files with missing lines Patch % Lines
github/enterprise_manage_ghes.go 88.88% 4 Missing and 2 partials ⚠️
github/enterprise_manage_ghes_config.go 95.16% 4 Missing and 2 partials ⚠️
github/enterprise_manage_ghes_maintenance.go 90.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3433      +/-   ##
==========================================
- Coverage   97.72%   92.29%   -5.43%     
==========================================
  Files         153      178      +25     
  Lines       13390    15273    +1883     
==========================================
+ Hits        13085    14096    +1011     
- Misses        215     1078     +863     
- Partials       90       99       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 15, 2025

Please run ./script/generate.sh and ./script/fmt.sh and push the changes to this PR. Thanks.

@s4mur4i
Copy link
Author

s4mur4i commented Jan 15, 2025

Please run ./script/generate.sh and ./script/fmt.sh and push the changes to this PR. Thanks.

Strangely it doesn't show any diff for me:

➜  go-github git:(master) ./script/generate.sh                                                                
➜  go-github git:(master) ./script/fmt.sh                                                                     
➜  go-github git:(master) git status                                                                         
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

Even lint shows no diff:

➜  go-github git:(master) ./script/lint.sh                                                                   
linting .
linting example
linting scrape
linting tools
validating generated files

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 15, 2025

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

Thank you, @s4mur4i .

This is a very large PR, and it looks like there are going to be many things to address, so I'll stop my review here and hopefully we will get the linting issues worked out.

Please see CONTRIBUTING.md for more helpful information.

github/enterprise_manage_ghes.go Outdated Show resolved Hide resolved
github/enterprise_manage_ghes.go Outdated Show resolved Hide resolved
github/enterprise_manage_ghes.go Outdated Show resolved Hide resolved
github/enterprise_manage_ghes.go Outdated Show resolved Hide resolved
github/enterprise_manage_ghes.go Show resolved Hide resolved
@s4mur4i
Copy link
Author

s4mur4i commented Jan 15, 2025

Can you see this? https://github.com/google/go-github/actions/runs/12794271004/job/35672748807?pr=3433

Yes, I can. I don't really understand why I don't see change.

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 15, 2025

Can you see this? https://github.com/google/go-github/actions/runs/12794271004/job/35672748807?pr=3433

Yes, I can. I don't really understand why I don't see change.

One thing that I don't typically see in PRs is that you didn't create a separate branch for this change, but instead stayed on "master". I'm not sure if that is a problem or not, but it is one thing I don't think I've ever seen before. Typically, after you fork a repo and want to create a PR, you create a new branch and perform your work on that branch, then make a pull request off of that branch. Maybe this is nothing... I don't know... it's just different.

@s4mur4i
Copy link
Author

s4mur4i commented Jan 15, 2025

Can you see this? https://github.com/google/go-github/actions/runs/12794271004/job/35672748807?pr=3433

Yes, I can. I don't really understand why I don't see change.

One thing that I don't typically see in PRs is that you didn't create a separate branch for this change, but instead stayed on "master". I'm not sure if that is a problem or not, but it is one thing I don't think I've ever seen before. Typically, after you fork a repo and want to create a PR, you create a new branch and perform your work on that branch, then make a pull request off of that branch. Maybe this is nothing... I don't know... it's just different.

I cloned in a new directory and worked. strange. but should be good now.

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Jan 15, 2025
@s4mur4i
Copy link
Author

s4mur4i commented Jan 16, 2025

@gmlewis Regarding generate. I dont know how to solve that issue.
I tried with one of my colleagues, and he has same output and behaviour.
I don't know if it might be because of mac-os.

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 16, 2025

@gmlewis Regarding generate. I dont know how to solve that issue. I tried with one of my colleagues, and he has same output and behaviour. I don't know if it might be because of mac-os.

Hmmm... very strange. I'm on a Mac too and have not seen this before.

@s4mur4i
Copy link
Author

s4mur4i commented Jan 16, 2025

I reinstalled go o match exact version:

go-github git:(master) ✗ go version                                                                                                                                                           
go version go1.22.10 darwin/arm64

Pushed the update.

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 16, 2025

@stevehipwell - @alexandear - @dnwe - @willnorris - with our recently changes to Go Toolchain settings, we are now seeing bizarre problems like this one where the tooling did not help out the developer and made for a frustrating formatting experience. GitHub Workflows linting conflicted with the developer linting.

We need to come up with a solution that doesn't hurt the developer experience and yet is easy to maintain moving forward.

@seruman
Copy link

seruman commented Jan 16, 2025

.. I tried with one of my colleagues, and he has same output and behaviour.

Colleague here! I've took a look at this and here're my findings;

SMTP struct has two fields; UserName and Username, looks like Github API returns both username and user_name 🤷

https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/manage-ghes#get-the-ghes-settings

https://github.com/s4mur4i/go-github/blob/a6383545144dd8f98845c94f4c453c920cb82046/github/enterprise_manage_ghes_config.go#L241-L242

The issue seems to be, for both fields getter.sortVal generated to has same value, lower case receiver + field;

sortVal: strings.ToLower(receiverType) + "." + strings.ToLower(fieldName),

Since sort.Sort is not stable, it might sort these two getter's different on each run;

// Sort getters by ReceiverType.FieldName.
sort.Sort(byName(t.Getters))

@dnwe
Copy link
Contributor

dnwe commented Jan 16, 2025

@gmlewis I think #3436 is likely the required fix here

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 16, 2025

@s4mur4i - can you please manually make the changes from #3436 to this PR and see if that solves the problem for you?

@s4mur4i
Copy link
Author

s4mur4i commented Jan 16, 2025

I accidently did a merge commit, just wanted to fix a resolve conflict :(
I applied the fixes from Pr #3436

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 16, 2025

I accidently did a merge commit, just wanted to fix a resolve conflict :( I applied the fixes from Pr #3436

No worries about the merge commit in this repo. We always squash-and-merge and therefore always have a clean commit history. This is also why we ask people to please not use force-push in this repo, as it makes it much more difficult for reviewers to see what has changed since their last review.

@s4mur4i
Copy link
Author

s4mur4i commented Jan 16, 2025

As I see there is still lint error. I guess then the toolchain was not a fix for this case.

@s4mur4i
Copy link
Author

s4mur4i commented Jan 17, 2025

I ran generate and fmt, lint shows no change for me. hopefully it is good now.
I rebased of master.

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

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

I have to step out of office for a while, but this review is taking a lot of time, so I will go ahead and give feedback on the one file I've looked at so far.
Please remember to not use force-push in this repo moving forward in order to save me review time for this large PR. Thanks.

github/enterprise_manage_ghes.go Outdated Show resolved Hide resolved
github/enterprise_manage_ghes.go Outdated Show resolved Hide resolved
// ClusterStatus represents a response from the GetClusterStatus and GetReplicationStatus method.
type ClusterStatus struct {
Status *string `json:"status,omitempty"`
Nodes []*ClusterStatusNodes `json:"nodes"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Nodes []*ClusterStatusNodes `json:"nodes"`
Nodes []*ClusterStatusNode `json:"nodes"`

Copy link
Author

Choose a reason for hiding this comment

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

The reason I decided to go with Plural is that its an array, and would normally hold more nodes. The reason for the change would be that the struc defines a single Node and its more convention?

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in d18f95d . PTAL

Comment on lines 28 to 29
// ClusterStatusNodes represents the status of a cluster node.
type ClusterStatusNodes struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// ClusterStatusNodes represents the status of a cluster node.
type ClusterStatusNodes struct {
// ClusterStatusNode represents the status of a cluster node.
type ClusterStatusNode struct {

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in d18f95d . PTAL

type ClusterStatusNodes struct {
Hostname *string `json:"hostname,omitempty"`
Status *string `json:"status,omitempty"`
Services []*ClusterStatusNodesServices `json:"services"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Services []*ClusterStatusNodesServices `json:"services"`
Services []*ClusterStatusNodesService `json:"services"`

Copy link
Author

Choose a reason for hiding this comment

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

Following logic from previous review, wouldnt ClusterStatusNodeService to remove plural be better?

return replicationStatus, resp, nil
}

// Versions gets the versions information deployed to each node.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// Versions gets the versions information deployed to each node.
// Versions gets the version information deployed to each node.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in d18f95d . PTAL

// GitHub API docs: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/manage-ghes#get-all-ghes-release-versions-for-all-nodes
//
//meta:operation GET /manage/v1/version
func (s *EnterpriseService) Versions(ctx context.Context, opts *NodeQueryOptions) ([]*NodeReleaseVersions, *Response, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func (s *EnterpriseService) Versions(ctx context.Context, opts *NodeQueryOptions) ([]*NodeReleaseVersions, *Response, error) {
func (s *EnterpriseService) GetNodeReleaseVersions(ctx context.Context, opts *NodeQueryOptions) ([]*NodeReleaseVersion, *Response, error) {

Copy link
Author

Choose a reason for hiding this comment

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

One question here. Since we are returning a []*NodeReleaseVersion shouldn't name be GetNodeReleaseVersion?
We are returning version from each node, so if output is singular, shouldn't the API call be also singular?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, because you get back a slice of zero or more versions returned.

Copy link
Author

Choose a reason for hiding this comment

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

Okay, than you. Fixed in d18f95d . PTAL

Comment on lines 61 to 62
// NodeReleaseVersions represents a response from the GetReplicationStatus method.
type NodeReleaseVersions struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// NodeReleaseVersions represents a response from the GetReplicationStatus method.
type NodeReleaseVersions struct {
// NodeReleaseVersion represents a response from the GetNodeReleaseVersions method.
type NodeReleaseVersion struct {

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in d18f95d . PTAL

Comment on lines 64 to 68
Version *ReleaseVersions `json:"version"`
}

// ReleaseVersions holds the release version information of the node.
type ReleaseVersions struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Version *ReleaseVersions `json:"version"`
}
// ReleaseVersions holds the release version information of the node.
type ReleaseVersions struct {
Version *ReleaseVersion `json:"version"`
}
// ReleaseVersion holds the release version information of the node.
type ReleaseVersion struct {

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in d18f95d . PTAL

Version *string `json:"version,omitempty"`
Platform *string `json:"platform,omitempty"`
BuildID *string `json:"build_id,omitempty"`
BuildDate *string `json:"build_date,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be *Timestamp instead of *string? I'll need to check the official docs, but don't have time right now.

Copy link
Contributor

Choose a reason for hiding this comment

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

@gmlewis it's a string in the following format 2023-05-02 (docs)

Copy link
Author

Choose a reason for hiding this comment

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

Yes, thats why I decided to use string. Dont know if Timestamp could have done a short date format.

type ConfigApplyStatus struct {
Running *bool `json:"running,omitempty"`
Successful *bool `json:"successful,omitempty"`
Nodes []*ConfigApplyStatusNodes `json:"nodes"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Nodes []*ConfigApplyStatusNodes `json:"nodes"`
Nodes []*ConfigApplyStatusNode `json:"nodes"`

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in c4121e9. PTAL

Comment on lines 26 to 27
// ConfigApplyStatusNodes is a struct to hold the response from the ConfigApply API.
type ConfigApplyStatusNodes struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// ConfigApplyStatusNodes is a struct to hold the response from the ConfigApply API.
type ConfigApplyStatusNodes struct {
// ConfigApplyStatusNode is a struct to hold the response from the ConfigApply API.
type ConfigApplyStatusNode struct {

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in c4121e9. PTAL


// ConfigApplyEvents is a struct to hold the response from the ConfigApplyEvents API.
type ConfigApplyEvents struct {
Nodes []*ConfigApplyEventsNodes `json:"nodes"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Nodes []*ConfigApplyEventsNodes `json:"nodes"`
Nodes []*ConfigApplyEventsNode `json:"nodes"`

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in c4121e9. PTAL

Comment on lines 44 to 45
// ConfigApplyEventsNodes is a struct to hold the response from the ConfigApplyEvents API.
type ConfigApplyEventsNodes struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// ConfigApplyEventsNodes is a struct to hold the response from the ConfigApplyEvents API.
type ConfigApplyEventsNodes struct {
// ConfigApplyEventsNode is a struct to hold the response from the ConfigApplyEvents API.
type ConfigApplyEventsNode struct {

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in c4121e9. PTAL

type ConfigApplyEventsNodes struct {
Node *string `json:"node,omitempty"`
LastRequestID *string `json:"last_request_id,omitempty"`
Events []*ConfigApplyEventsNodeEvents `json:"events"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Events []*ConfigApplyEventsNodeEvents `json:"events"`
Events []*ConfigApplyEventsNodeEvent `json:"events"`

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in c4121e9. PTAL

Comment on lines 51 to 52
// ConfigApplyEventsNodeEvents is a struct to hold the response from the ConfigApplyEvents API.
type ConfigApplyEventsNodeEvents struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// ConfigApplyEventsNodeEvents is a struct to hold the response from the ConfigApplyEvents API.
type ConfigApplyEventsNodeEvents struct {
// ConfigApplyEventsNodeEvent is a struct to hold the response from the ConfigApplyEvents API.
type ConfigApplyEventsNodeEvent struct {

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in c4121e9. PTAL

UUID *string `json:"uuid,omitempty"`
Status *string `json:"status,omitempty"`
ScheduledTime *Timestamp `json:"scheduled_time,omitempty"`
ConnectionServices []*ConnectionServices `json:"connection_services"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ConnectionServices []*ConnectionServices `json:"connection_services"`
ConnectionServices []*ConnectionService `json:"connection_services"`

Comment on lines +31 to +32
// ConnectionServices represents the connection services for the maintenance status.
type ConnectionServices struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// ConnectionServices represents the connection services for the maintenance status.
type ConnectionServices struct {
// ConnectionService represents the connection services for the maintenance status.
type ConnectionService struct {

Comment on lines 26 to 27
// ClusterSSHKeys represents the SSH keys configured for the instance.
type ClusterSSHKeys struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// ClusterSSHKeys represents the SSH keys configured for the instance.
type ClusterSSHKeys struct {
// ClusterSSHKey represents the SSH keys configured for the instance.
type ClusterSSHKey struct {

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in f3d10fd . PTAL

@stevehipwell
Copy link
Contributor

@s4mur4i I added a few more review comments based on the ones in the file that @gmlewis had already covered.

@s4mur4i
Copy link
Author

s4mur4i commented Jan 17, 2025

I have to step out of office for a while, but this review is taking a lot of time, so I will go ahead and give feedback on the one file I've looked at so far. Please remember to not use force-push in this repo moving forward in order to save me review time for this large PR. Thanks.

One question for myself. Contribution.md says not to use merge commit, but would say to do cherry-pick or rebase. I did a rebase to get the patch and to get latest state. but a rebase would require a force-push, I don't know of other way to do it.
Should I have just taken patch applied it manually, or is there any other method recommended?

s4mur4i and others added 2 commits January 17, 2025 18:00
Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
Co-authored-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com>
@stevehipwell
Copy link
Contributor

@s4mur4i I think @gmlewis prefers a merge on top of your branch.

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 17, 2025

One question for myself. Contribution.md says not to use merge commit, but would say to do cherry-pick or rebase. I did a rebase to get the patch and to get latest state. but a rebase would require a force-push, I don't know of other way to do it.
Should I have just taken patch applied it manually, or is there any other method recommended?

While you are working on a PR, you don't need to worry about what the master branch is doing.
Just keep pushing commits to your PR and please do NOT force-push.

We ALWAYS use "Squash and merge" in this repo, so our commit history is always clean. Do a "git log" on this repo to see what I mean.

If you ever have conflicting changes and GitHub says that the PR needs updating, you can simply follow these steps:

  1. git checkout master
  2. git pull origin master
  3. git checkout my-custom-cool-branch-that-I-am-currently-working-on
  4. git merge master

If there are conflicts, I personally like to use git mergetool (with kdiff3 as my merge tool) and resolve all the conflicts and then finalize the resolution with the command git commit -sam 'git merge master'.

  1. git push origin my-custom-cool-branch-that-I-am-currently-working-on

This may add many commits to a PR, but in the end, it never matters because we always "Squash and merge".

Please let me know if any of this is not clear.

I tried to explain this clearly in CONTRIBUTING.md, but if it is still unclear, please send me a PR to clean up the wording so that it is super-easy to understand.
Thank you.

@s4mur4i
Copy link
Author

s4mur4i commented Jan 17, 2025

@gmlewis I have an interesting issue, which I don't fully understand why.
I am working on 2 Comments. I have following Patch:

git diff github/enterprise_manage_ghes.go                                                                                                                                           cost-cluster
diff --git a/github/enterprise_manage_ghes.go b/github/enterprise_manage_ghes.go
index 3ecf373f..f4e136d8 100644
--- a/github/enterprise_manage_ghes.go
+++ b/github/enterprise_manage_ghes.go
@@ -27,13 +27,13 @@ type ClusterStatus struct {

 // ClusterStatusNode represents the status of a cluster node.
 type ClusterStatusNode struct {
-	Hostname *string                       `json:"hostname,omitempty"`
-	Status   *string                       `json:"status,omitempty"`
-	Services []*ClusterStatusNodesServices `json:"services"`
+	Hostname *string                      `json:"hostname,omitempty"`
+	Status   *string                      `json:"status,omitempty"`
+	Services []*ClusterStatusNodesService `json:"services"`
 }

-// ClusterStatusNodesServices represents the status of a service running on a cluster node.
-type ClusterStatusNodesServices struct {
+// ClusterStatusNodesService represents the status of a service running on a cluster node.
+type ClusterStatusNodesService struct {
 	Status  *string `json:"status,omitempty"`
 	Name    *string `json:"name,omitempty"`
 	Details *string `json:"details,omitempty"`

When I run generate I get following error:

./script/generate.sh                                                                                                                                                                cost-cluster
no operations defined for ClusterStatusNodesService.GetDetails
no operations defined for ClusterStatusNodesService.GetName
no operations defined for ClusterStatusNodesService.GetStatus
github/github.go:8: running "../script/metadata.sh": exit status 1

Same thing happens when I edit ConnectionService
Do you have idea why it might happen? All other generates were successful, just these 2 are having issues.
In github-accessors.go I see files successfully generated:

git diff github/github-accessors.go                                                                                                                                                 cost-cluster
diff --git a/github/github-accessors.go b/github/github-accessors.go
index d7841914..a020bcb4 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -2527,7 +2527,7 @@ func (c *ClusterStatusNode) GetStatus() string {
 }

 // GetDetails returns the Details field if it's non-nil, zero value otherwise.
-func (c *ClusterStatusNodesServices) GetDetails() string {
+func (c *ClusterStatusNodesService) GetDetails() string {
 	if c == nil || c.Details == nil {
 		return ""
 	}
@@ -2535,7 +2535,7 @@ func (c *ClusterStatusNodesServices) GetDetails() string {
 }

 // GetName returns the Name field if it's non-nil, zero value otherwise.
-func (c *ClusterStatusNodesServices) GetName() string {
+func (c *ClusterStatusNodesService) GetName() string {
 	if c == nil || c.Name == nil {
 		return ""
 	}
@@ -2543,7 +2543,7 @@ func (c *ClusterStatusNodesServices) GetName() string {
 }

 // GetStatus returns the Status field if it's non-nil, zero value otherwise.
-func (c *ClusterStatusNodesServices) GetStatus() string {
+func (c *ClusterStatusNodesService) GetStatus() string {
 	if c == nil || c.Status == nil {
 		return ""
 	}

Even stranger if I change it to ClusterStatusNodesServicess it works, and also ClusterStatusNodesServic works.

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 17, 2025

#3437 was just merged into master - can you please try it out to see if that fixes the problems you are seeing?

@s4mur4i
Copy link
Author

s4mur4i commented Jan 17, 2025

#3437 was just merged into master - can you please try it out to see if that fixes the problems you are seeing?

This morning this got merged into my branch:
s4mur4i@d13c739
it is not working with it.

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 17, 2025

#3437 was just merged into master - can you please try it out to see if that fixes the problems you are seeing?

This morning this got merged into my branch: s4mur4i@d13c739 it is not working with it.

@alexandear - can you please comment?

@alexandear
Copy link
Contributor

alexandear commented Jan 20, 2025

@gmlewis I have an interesting issue, which I don't fully understand why. I am working on 2 Comments. I have following Patch:
...

When I run generate I get following error:

./script/generate.sh                                                                                                                                                                cost-cluster
no operations defined for ClusterStatusNodesService.GetDetails
no operations defined for ClusterStatusNodesService.GetName
no operations defined for ClusterStatusNodesService.GetStatus
github/github.go:8: running "../script/metadata.sh": exit status 1

Same thing happens when I edit ConnectionService

Even stranger if I change it to ClusterStatusNodesServicess it works, and also ClusterStatusNodesServic works.

The issue appears because the struct suffixed with Service. It's because generate.sh executes metadata.sh, see

//go:generate ../script/metadata.sh update-go

Every exported type where type name ends in Service, see
if !id.IsExported() || !fn.Name.IsExported() || !strings.HasSuffix(id.Name, "Service") {

Service type is a special type in go-github for grouping related API functions. Examples: IssuesService, EnterpriseService etc.

To workaround this, we can rename ClusterStatusNodesServices to ClusterStatusNodesServiceItem, ConnectionServices to ConnectionServiceItem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsReview PR is awaiting a review before merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing api for managing Github Enterprise Server
6 participants