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 SchemaService and FillEntityDefaults utility #119

Merged
merged 11 commits into from
Jan 28, 2022

Conversation

GGabriele
Copy link
Collaborator

Mirroring what's been previously done for Plugins,
this adds GetFullSchema to Routes, Upstreams, Targets and Services.
This also adds utils function to fill core entities with
defaults comings from their schema.

@GGabriele GGabriele requested a review from a team as a code owner January 24, 2022 14:39
@hbagdi
Copy link
Member

hbagdi commented Jan 24, 2022

Let's do this a bit differently.
Let's create a SchemaService with a function to pull a schema for any entity. Get(entityname string) something like. That is much more concise and meets the goal.

@GGabriele
Copy link
Collaborator Author

@hbagdi good point.

Since I removed the GetFullSchema from each entity service, I also moved all the tests under kong/utils_test.go. Let me know what you think.

@hbagdi hbagdi requested a review from rainest January 24, 2022 20:12
kong/schema_service.go Outdated Show resolved Hide resolved
kong/schema_service_test.go Outdated Show resolved Hide resolved
kong/schema_service_test.go Outdated Show resolved Hide resolved
kong/utils.go Outdated Show resolved Hide resolved
kong/utils.go Show resolved Hide resolved
Copy link
Member

@hbagdi hbagdi left a comment

Choose a reason for hiding this comment

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

Nice patch!

kong/utils.go Show resolved Hide resolved
kong/utils.go Show resolved Hide resolved
kong/utils.go Outdated Show resolved Hide resolved
kong/utils.go Outdated Show resolved Hide resolved
kong/utils.go Outdated Show resolved Hide resolved
kong/utils.go Show resolved Hide resolved
expected *Route
}{
{
name: "name paths",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
name: "name paths",
name: "fills defaults for all fields except paths, leaves name as is",

Descriptive tests, please.

kong/utils_test.go Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jan 26, 2022

Codecov Report

Merging #119 (0dd30c6) into main (e965de2) will increase coverage by 0.07%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #119      +/-   ##
==========================================
+ Coverage   44.46%   44.54%   +0.07%     
==========================================
  Files          42       43       +1     
  Lines        3805     3929     +124     
==========================================
+ Hits         1692     1750      +58     
- Misses       1793     1851      +58     
- Partials      320      328       +8     
Flag Coverage Δ
2.0.5 39.37% <66.66%> (+0.24%) ⬆️
2.1.4 39.19% <66.66%> (+0.24%) ⬆️
2.2.2 39.19% <66.66%> (+0.24%) ⬆️
2.3.3 39.19% <66.66%> (+0.24%) ⬆️
2.4.0 39.19% <66.66%> (+0.24%) ⬆️
community 39.37% <66.66%> (+0.24%) ⬆️
enterprise 44.23% <66.66%> (+0.08%) ⬆️
enterprise-1.5.0.11 44.23% <66.66%> (+0.08%) ⬆️
enterprise-2.1.4.6 43.14% <66.66%> (+0.11%) ⬆️
enterprise-2.2.1.3 43.14% <66.66%> (+0.11%) ⬆️
enterprise-2.3.3.2 43.46% <66.66%> (+0.43%) ⬆️
enterprise-2.3.3.4 43.46% <66.66%> (?)
enterprise-2.4.1.3 43.46% <66.66%> (?)
enterprise-2.5.1.2 43.46% <66.66%> (?)
enterprise-2.6.0.2 43.46% <66.66%> (?)
integration 44.54% <66.66%> (+0.07%) ⬆️

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

Impacted Files Coverage Δ
kong/schema_service.go 45.45% <45.45%> (ø)
kong/utils.go 80.09% <67.16%> (-5.91%) ⬇️
kong/client.go 59.33% <100.00%> (+0.39%) ⬆️
kong/plugin_service.go 56.79% <100.00%> (ø)
kong/types.go 9.09% <0.00%> (+2.04%) ⬆️

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 e965de2...0dd30c6. Read the comment docs.

@hbagdi
Copy link
Member

hbagdi commented Jan 26, 2022

@rainest Can I get a review from you on this one as well?

@GGabriele GGabriele changed the title feat: add GetFullSchema and Fill*Defaults to core entities feat: add SchemaService and FillEntityDefaults utility Jan 27, 2022
Copy link
Member

@hbagdi hbagdi left a comment

Choose a reason for hiding this comment

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

Let's move ahead on this one. If there are more issues, @GGabriele please take care of resolving with subsequent PRs.

@hbagdi hbagdi merged commit 3c62c40 into main Jan 28, 2022
@hbagdi hbagdi deleted the core_entities_defaults branch January 28, 2022 17:47
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.

None yet

3 participants