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: ingress annotations supports the specified upstream schema #1451

Merged
merged 17 commits into from
Dec 8, 2022
Merged

feat: ingress annotations supports the specified upstream schema #1451

merged 17 commits into from
Dec 8, 2022

Conversation

dickens7
Copy link
Contributor

Type of change:

#1420

  • Bugfix
  • New feature provided
  • Improve performance
  • Backport patches

What this PR does / why we need it:

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

@codecov-commenter
Copy link

codecov-commenter commented Nov 13, 2022

Codecov Report

Merging #1451 (3513249) into master (c8d3bd5) will increase coverage by 0.26%.
The diff coverage is 64.70%.

@@            Coverage Diff             @@
##           master    #1451      +/-   ##
==========================================
+ Coverage   41.11%   41.38%   +0.26%     
==========================================
  Files          82       84       +2     
  Lines        7340     7382      +42     
==========================================
+ Hits         3018     3055      +37     
- Misses       3969     3974       +5     
  Partials      353      353              
Impacted Files Coverage Δ
pkg/providers/ingress/translation/annotations.go 88.23% <ø> (+29.41%) ⬆️
pkg/providers/ingress/translation/translator.go 0.00% <0.00%> (ø)
...ation/annotations/upstreamscheme/upstreamscheme.go 100.00% <100.00%> (ø)
...ingress/translation/annotations/plugins/plugins.go 0.00% <0.00%> (ø)
...ess/translation/annotations/plugins/http_method.go 81.81% <0.00%> (ø)
cmd/ingress/ingress.go 82.75% <0.00%> (+0.45%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@tao12345666333
Copy link
Member

sorry for delay, could you please merge master branch? thanks!

Comment on lines 27 to 29
func (w *upstreamscheme) Parse(e annotations.Extractor) (interface{}, error) {
return e.GetStringAnnotation(annotations.AnnotationsUpstreamScheme), nil
}
Copy link
Member

Choose a reason for hiding this comment

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

We need to check that its value is within these available ranges

// SchemeHTTP represents the HTTP protocol.
SchemeHTTP = "http"
// SchemeGRPC represents the GRPC protocol.
SchemeGRPC = "grpc"
// SchemeHTTPS represents the HTTPS protocol.
SchemeHTTPS = "https"
// SchemeGRPCS represents the GRPCS protocol.
SchemeGRPCS = "grpcs"

@dickens7
Copy link
Contributor Author

Please take a look at this unit-test-ci

Copy link
Member

@tao12345666333 tao12345666333 left a comment

Choose a reason for hiding this comment

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

Please add e2e test cases to cover this. Thanks

}

func (w *upstreamscheme) Parse(e annotations.Extractor) (interface{}, error) {
scheme := e.GetStringAnnotation(annotations.AnnotationsUpstreamScheme)

if inSchemes(scheme) {
_, ok := schemeMap[scheme]
Copy link
Member

Choose a reason for hiding this comment

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

I thought we could ignore case?
both HTTP and http can be used.

You can convert the obtained configuration items to lowercase

@dickens7
Copy link
Contributor Author

Please help me re-run ci.

@tao12345666333
Copy link
Member

could you please merge master branch first?
I have sovled the markdown lint issue.

}

var schemeMap map[string]struct{} = map[string]struct{}{
"http": {},
Copy link
Member

Choose a reason for hiding this comment

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

A small suggestion. Can we make this variable global? Together with the schemes in pkg/types/apisix/v1/types.go.
Otherwise, we may need to deal with cross-file constant dependencies.

Copy link
Member

Choose a reason for hiding this comment

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

good catch, we have

// SchemeHTTP represents the HTTP protocol.
SchemeHTTP = "http"
// SchemeGRPC represents the GRPC protocol.
SchemeGRPC = "grpc"
// SchemeHTTPS represents the HTTPS protocol.
SchemeHTTPS = "https"
// SchemeGRPCS represents the GRPCS protocol.
SchemeGRPCS = "grpcs"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We define SchemeMap to pkg/types/apisix/v1/types.go
Or just use constants like SchemeHTTP , SchemeGRPC

pkg/types/apisix/v1/types.go

var SchemeMap map[string]struct{} = map[string]struct{}{
	SchemeHTTP:  {},
	SchemeHTTPS: {},
	SchemeGRPC:  {},
	SchemeGRPCS: {},
}

or

pkg/providers/ingress/translation/annotations/upstreamscheme/upstreamscheme.go

var schemeMap map[string]struct{} = map[string]struct{}{
	types.SchemeHTTP:  {},
	types.SchemeHTTPS: {},
	types.SchemeGRPC:  {},
	types.SchemeGRPCS: {},
}

pkg/types/apisix/v1/types.go Outdated Show resolved Hide resolved
@tao12345666333 tao12345666333 merged commit 931ab06 into apache:master Dec 8, 2022
@tao12345666333 tao12345666333 added this to the v1.6.0 milestone Dec 8, 2022
@dickens7 dickens7 deleted the feat-upstream-schema branch December 8, 2022 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

discuss: ingress annotations supports the specified upstream protocol
5 participants