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: schema for apisixroute #345

Merged
merged 3 commits into from
Apr 10, 2021

Conversation

tokers
Copy link
Contributor

@tokers tokers commented Apr 6, 2021

Please answer these questions before submitting a pull request

  • Why submit this pull request?

  • Bugfix

  • New feature provided

  • Improve performance

  • Backport patches

  • Related issues


Bugfix

  • Description

  • How to fix?


New feature or improvement

  • Describe the details and related test reports.

Backport patches

  • Why need to backport?

  • Source branch

  • Related commits and pull requests

  • Target branch

@codecov-io
Copy link

codecov-io commented Apr 6, 2021

Codecov Report

Merging #345 (6cc3e99) into master (456efa6) will decrease coverage by 0.34%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #345      +/-   ##
==========================================
- Coverage   43.84%   43.50%   -0.35%     
==========================================
  Files          40       39       -1     
  Lines        3435     3455      +20     
==========================================
- Hits         1506     1503       -3     
- Misses       1761     1781      +20     
- Partials      168      171       +3     
Impacted Files Coverage Δ
pkg/apisix/cluster.go 28.44% <0.00%> (-5.97%) ⬇️
pkg/kube/translation/apisix_route.go 46.08% <0.00%> (-1.29%) ⬇️
pkg/apisix/route.go 44.84% <0.00%> (-0.50%) ⬇️
pkg/kube/translation/util.go 100.00% <0.00%> (ø)
test/e2e/e2e.go
pkg/apisix/resource.go 78.64% <0.00%> (+0.20%) ⬆️
pkg/apisix/upstream.go 48.04% <0.00%> (+1.18%) ⬆️

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 456efa6...6cc3e99. Read the comment docs.

properties:
scope:
type: string
enum: ["Header", "Query", "Cookie", "Path"]
Copy link
Member

Choose a reason for hiding this comment

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

Should enums be sorted consistently the same way in each file ?

Suggested change
enum: ["Header", "Query", "Cookie", "Path"]
enum: ["Cookie", "Header", "Path", "Query"]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point.

minItems: 1
items:
type: string
enum: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT", "TRACE"]
Copy link
Member

Choose a reason for hiding this comment

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

Whilst "GET" and "POST" are probably the most used or probably the most well known, should an enum array or list have a sort order or be random ?

Suggested change
enum: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT", "TRACE"]
enum: ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"]

- scope
op:
type: string
enum:
Copy link
Member

Choose a reason for hiding this comment

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

Should we sort enums ? Or at least sort some part of the enums ?

- LessThan
- In
- NotIn
- RegexMatch
Copy link
Member

Choose a reason for hiding this comment

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

So for this enum maybe keep the top part with the custom order and then for the bottom part sort it ?

Suggested change
- RegexMatch
- RegexMatch
- RegexMatchCaseInsensitive
- RegexNotMatch
- RegexNotMatchCaseInsensitive

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I grouped them by their meanings.

items:
type: string
oneOf:
- required: ["subject", "op", "value"]
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
- required: ["subject", "op", "value"]
- required: ["op", "subject", "value"]

type: string
oneOf:
- required: ["subject", "op", "value"]
- required: ["subject", "op", "set"]
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
- required: ["subject", "op", "set"]
- required: ["op", "set", "subject"]

items:
type: object
oneOf:
- required: ["name", "match", "backend"]
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
- required: ["name", "match", "backend"]
- required: ["backend", "match", "name"]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I grouped them by their meanings.

type: object
oneOf:
- required: ["name", "match", "backend"]
- required: ["name", "match", "backends"]
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
- required: ["name", "match", "backends"]
- required: ["backends", "match", "name"]

@tokers
Copy link
Contributor Author

tokers commented Apr 9, 2021

@jbampton Fields like expr operators can be grouped together by their meanings, the lexicographical orders are not so important.

@tokers tokers added this to the 0.5.0 milestone Apr 9, 2021
samples/deploy/crd/v1beta1/ApisixRoute.yaml Show resolved Hide resolved
minItems: 1
items:
type: string
pattern: "^/" # start with "/"
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
pattern: "^/" # start with "/"
pattern: "^\/[a-zA-Z0-9\-._~%!$&'()+,;=:@/]*\*?$"

@tokers tokers merged commit 9deb22f into apache:master Apr 10, 2021
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