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

add Sprint column for issue. Fix get group member function to return all members. #119

Merged
merged 14 commits into from
Apr 3, 2018

Conversation

zenixls2
Copy link
Contributor

@zenixls2
Copy link
Contributor Author

It seems accessing https://issues.apache.org/jira/rest/agile/1.0/issue/MESOS-3325 needs to be authenticated...

@rbriski
Copy link
Contributor

rbriski commented Mar 12, 2018

This change will affect everyone else using the library. You're changing the version of the API that we use for pulling issues. It also uses the AuthenticationService to determine which version of the API to use. That seems fragile. If you're going to change the endpoint version, should we version the entire service as well?

@rbriski
Copy link
Contributor

rbriski commented Mar 12, 2018

I looked at this again and you're switching to the agile endpoint. This means everyone will have to switch to the agile endpoint. I don't think we should force everyone to a non-standard endpoint just to include agile feature like boards and sprints. Please move the agile endpoint into a separate entity instead of taking over the Issue entity.

Also, I like the idea of pagination support but for everything, not just a one-off for groups. Github handles pagination nicely (https://github.com/google/go-github/blob/2f5b584d4694ff036b98283940be4d23d113e2d4/github/github.go#L352). This doesn't translate exactly to how JIRA handles it but I think it's a good start for a nicer solution that covers all cases.

@zenixls2
Copy link
Contributor Author

@rbriski Do you mean like the implementation for Sprint and Board APIs? I'm not sure what entity name it should be if I create a separate service for agile endpoints. Also, I'm not sure if creating a new service would be a right way for implementing the agile endpoints. BTW, is agile endpoint not stable or not ready for production use, as you have mentioned that it is non-standard?

And yes, I agree that pagination support is quite important for many cases in go-jira. However, only getting the first page of something doesn't make sense for any use case.

For the request for pagination, actually sb. has already reported in issues (just listed here for reference):
#55
need some plans for backward compatibility, since this modification will sure influence almost all users.
(Or just create a new version, like go-jira 2.0, to support new features)
If we really want to implement pagination in this pull request, please give me any advice on the backward compatibility part. The returned type for many APIs might have to be changed.

@rbriski
Copy link
Contributor

rbriski commented Mar 13, 2018

Adding Sprint to the IssueFields struct should be fine. If the field is not there, it should just omit it since you have the omitempty flag set.

By "non-standard" I just mean that it may not be available to everyone. Is the agile endpoint available for projects that aren't agile? What about service desk projects? It seems like a lot of unknowns to just be dropping a new endpoint in.

You could do something like GetWithAgile and replicate the Get method but with the agile endpoint. Are there additional agile endpoints? Should we consider letting the base endpoint be settable? I'm not exactly sure but I'd like to consider the larger picture rather than fixing a single use case.

Regarding pagination, yes, it should be there but I don't think this is the best way. I haven't looked closely enough to figure out a backward compatible way. I'll have more time this weekend.

If you figure out a good way to add the agile "GET", just strip out the pagination stuff for now and I can merge this. Even if you do have a good idea of pagination, it would be best to have it in a separate PR.

@rbriski
Copy link
Contributor

rbriski commented Mar 13, 2018

Looking at this more, the Agile add-on encompasses a lot more calls:
https://docs.atlassian.com/jira-software/REST/7.3.1/

You could add Sprint to the struct but I think I'd create an entirely new service just to handle agile stuff.

@zenixls2
Copy link
Contributor Author

The modification I applied:

  • split out agile endpoint with another API
  • create another function for group pagination only. Left original function for backward compatibility.
  • add test for the group pagination
    Only one thing needs to be confirmed: groupMembersResult is a private struct, so it won't be shown in godoc. New GetNextPage function won't be shown either. Maybe we should make it public?

Copy link
Contributor

@rbriski rbriski left a comment

Choose a reason for hiding this comment

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

I've been thinking about this a lot for the past few days and I have some ideas that I've laid out below. Tell me if you want me to elaborate more. I know it's been a little scattered but I think I've landed on the best solution right now.

group.go Outdated
// User of this resource is required to have sysadmin or admin permissions.
//
// JIRA API docs: https://docs.atlassian.com/jira/REST/server/#api/2/group-getUsersFromGroup
func (s *GroupService) GetByPage(name string, startAt int, maxResults int, includeInactiveUsers bool) (*groupMembersResult, *Response, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you rename this to GetWithOptions and have the method signature match this:
https://github.com/andygrunwald/go-jira/blob/master/issue.go#L783

That's a good example of how pagination is set up in this library. I'm not sure why it wasn't included in the GroupService but ... here we are. If there's a major version change in the future, I would expect options to be included in the Get function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, this make sense. Would better to wrap these in options.

issue.go Outdated
//
// JIRA API docs: https://docs.atlassian.com/jira-software/REST/7.3.1/#agile/1.0/issue-getIssue
// TODO: create agile service for holding all agile apis' implementation
func (s *IssueService) GetWithAgile(issueID string, options *GetQueryOptions) (*Issue, *Response, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you put this in the SprintService? I'd like to keep all of the agile-specific stuff together. I think naming it GetIssue will make sense in that service. You can also get rid of the if/else stuff for the endpoint because they'll know exactly what they're calling if they use SprintService

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually board also uses agile api. are we going to merge board to somewhere else?
Moreover, the agile api doesn't actually only add sprint information. It also comes out with the epic infor. I think it might not be proper to put in SprintService.

group.go Outdated
@@ -18,6 +18,30 @@ type groupMembersResult struct {
MaxResults int `json:"maxResults"`
Total int `json:"total"`
Members []GroupMember `json:"values"`
IsLast bool `json:"isLast"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove these. They're not needed in this results struct.

group.go Outdated
Client *Client `json:"-"`
}

func (g *groupMembersResult) GetNextPage() (*groupMembersResult, *Response, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remove this function? I don't think we need to copy the GetByPage function. The code to set up the next page can be in the calling code's loop like this:
https://github.com/google/go-github#pagination

Copy link
Contributor

@rbriski rbriski left a comment

Choose a reason for hiding this comment

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

The pagination stuff looks good. Just a request to use GetWithOptions since GetByOption doesn't make sense.

Regarding the SprintService, I agree that it's not ideal, but it's better than mixing the agile stuff in with the main API. There aren't any other functions named "Agile" and SprintService.GetIssue keeps the agile stuff together. I know there's a BoardService but that seems more for kanban (maybe?). JIRA certainly makes it confusing.

group.go Outdated
// User of this resource is required to have sysadmin or admin permissions.
//
// JIRA API docs: https://docs.atlassian.com/jira/REST/server/#api/2/group-getUsersFromGroup
func (s *GroupService) GetByOption(name string, options *GroupSearchOptions) ([]GroupMember, *Response, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

GetWithOptions

@rbriski
Copy link
Contributor

rbriski commented Mar 27, 2018

@zenixls2 are you still working on this?

@zenixls2
Copy link
Contributor Author

sorry, i was quite busy during these days, and maybe until next week. I'll fix this when i have time.

@zenixls2
Copy link
Contributor Author

zenixls2 commented Apr 3, 2018

hi, I've changed the code according to your comments

@rbriski rbriski merged commit 7f227a2 into andygrunwald:master Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants