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

Defines the Information Service on top of Kong's Root endpoint #65

Merged
merged 19 commits into from
Jul 1, 2021
Merged

Defines the Information Service on top of Kong's Root endpoint #65

merged 19 commits into from
Jul 1, 2021

Conversation

mmorel-35
Copy link
Contributor

@mmorel-35 mmorel-35 commented May 15, 2021

@hbagdi, after your comment #62 (comment) , here is my suggestion.

@mmorel-35 mmorel-35 requested a review from a team as a code owner May 15, 2021 07:37
@codecov-commenter
Copy link

codecov-commenter commented May 15, 2021

Codecov Report

Merging #65 (0a6add2) into main (c7c6276) will decrease coverage by 5.76%.
The diff coverage is 53.84%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #65      +/-   ##
==========================================
- Coverage   45.50%   39.74%   -5.77%     
==========================================
  Files          40       41       +1     
  Lines        2525     2539      +14     
==========================================
- Hits         1149     1009     -140     
- Misses       1077     1280     +203     
+ Partials      299      250      -49     
Flag Coverage Δ
2.0.5 39.74% <53.84%> (+0.09%) ⬆️
2.1.4 39.50% <53.84%> (+0.09%) ⬆️
2.2.2 39.50% <53.84%> (+0.09%) ⬆️
2.3.3 39.50% <53.84%> (+0.09%) ⬆️
2.4.0 39.50% <53.84%> (+0.09%) ⬆️
community 39.74% <53.84%> (+0.09%) ⬆️
enterprise ?
enterprise-1.5.0.11 ?
enterprise-2.1.4.6 ?
enterprise-2.2.1.3 ?
enterprise-2.3.3.2 ?
integration 39.74% <53.84%> (-5.77%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
kong/client.go 65.85% <ø> (+0.27%) ⬆️
kong/types.go 11.62% <ø> (ø)
kong/information_service.go 53.84% <53.84%> (ø)
kong/mtls_auth_service.go 0.00% <0.00%> (-66.16%) ⬇️
kong/workspace_service.go 0.00% <0.00%> (-56.67%) ⬇️
kong/admin_service.go 0.00% <0.00%> (-21.52%) ⬇️
kong/credentials.go 85.71% <0.00%> (-14.29%) ⬇️
kong/utils.go 71.42% <0.00%> (-3.58%) ⬇️
kong/sni_service.go 58.75% <0.00%> (ø)
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c7c6276...0a6add2. Read the comment docs.

Copy link
Contributor

@mflendrich mflendrich left a comment

Choose a reason for hiding this comment

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

The proposed API design:

  • makes a new HTTP request for each separate field of information
  • treats the returned object as unstructured

We should instead:

  • define a data structure to deserialize the JSON object into
  • have just one API on the service that pulls the kong info endpoint (/ or /:workspace/kong)
  • define accessor methods for individual bits of information on that object, instead of implementing them on the abstract service

@mmorel-35
Copy link
Contributor Author

mmorel-35 commented May 18, 2021

What do you think of something like this :

type Info struct {
    version string `json:version`
    configuration struct {
        database... 
        portal... 
        rbac...
   }
}
func (p *Info) Version()
func (p *Info) IsEnterprise()
func (p *Info) Database()
func (p *Info) IsInMemory()
func (p *Info) IsRBACEnabled()
func (p *Info) IsPortalEnabled()

And as it would be a single function it doesn't need an entire service of it's own. So it would directly be at the client's level.

client.Info(ctx) (*Info, error) 

@mmorel-35 mmorel-35 requested a review from mflendrich May 19, 2021 11:54
kong/information.go Outdated Show resolved Hide resolved
kong/information.go Outdated Show resolved Hide resolved
kong/information.go Outdated Show resolved Hide resolved
kong/information.go Outdated Show resolved Hide resolved
kong/information.go Outdated Show resolved Hide resolved
kong/information.go Outdated Show resolved Hide resolved
@mmorel-35 mmorel-35 requested a review from mflendrich May 21, 2021 18:15
kong/information_service.go Outdated Show resolved Hide resolved
kong/types.go Outdated Show resolved Hide resolved
Copy link
Contributor

@mflendrich mflendrich left a comment

Choose a reason for hiding this comment

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

Some minor style issues + a request for a simple integration test. Otherwise the information service looks good to me.

Please consider this comment #65 (comment) non-blocking - we'll make adjustments before merging if necessary.

kong/information_service.go Outdated Show resolved Hide resolved
kong/information_service.go Outdated Show resolved Hide resolved
kong/types.go Outdated Show resolved Hide resolved
kong/information_service_test.go Show resolved Hide resolved
kong/information_service_test.go Outdated Show resolved Hide resolved
mmorel-35 and others added 5 commits May 25, 2021 14:03
Co-authored-by: Michał Flendrich <m.flendrich@gmail.com>
Co-authored-by: Michał Flendrich <m.flendrich@gmail.com>
Co-authored-by: Michał Flendrich <m.flendrich@gmail.com>
Copy link
Contributor

@mflendrich mflendrich left a comment

Choose a reason for hiding this comment

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

Please remove the deepcopy bit (as requested in the attached comment) and this PR is good to go.

kong/types.go Outdated Show resolved Hide resolved
kong/types.go Outdated Show resolved Hide resolved
@mmorel-35 mmorel-35 requested a review from mflendrich May 29, 2021 08:22
@hbagdi
Copy link
Member

hbagdi commented Jun 7, 2021

Deferring the entire review to @mflendrich here.

@mmorel-35
Copy link
Contributor Author

Hi @mflendrich, anything left to do here?

Copy link
Contributor

@mflendrich mflendrich left a comment

Choose a reason for hiding this comment

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

Looks good now!

@mflendrich mflendrich merged commit 26f0e0e into Kong:main Jul 1, 2021
@mmorel-35 mmorel-35 deleted the feature/informations branch July 1, 2021 15:34
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.

4 participants