-
Notifications
You must be signed in to change notification settings - Fork 98
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
Wildcard support for multi-tenant interceptor #281
Comments
@comron sounds like a great idea! We'll get this implemented and released in |
Hi there! func (t *Table) AddTarget(
host string,
target Target) error {
n := strings.Count(host, "*")
if n > 0 && (!strings.HasPrefix(host, "*") || n > 1) {
return fmt.Errorf("invalid wildcard for host %s", host)
} else if n > 0 {
host = "^" + strings.Replace(host, "*", "[a-zA-Z0-9-]+", 1) + "$"
}
t.l.Lock()
defer t.l.Unlock()
_, err := t.lookup(host)
if err == ErrTargetNotFound {
t.m[host] = target
return nil
}
return fmt.Errorf(
"host %s is already registered in the routing table",
host,
)
}
func (t *Table) lookup(host string) (string, error) {
_, ok := t.m[host]
if ok {
return host, nil
}
for k := range t.m {
if matched, _ := regexp.MatchString(k, host); matched {
return k, nil
}
}
return "", ErrTargetNotFound
} What do you all think about this? Should i simplify the solution? |
On an initial look, this code looks good, but I'm on holiday looking at it from my iPad, so I'll take a more in-depth look when I'm back. Thank for putting it together! |
@andresrsanchez I looked in more depth at the code you posted and have a few questions/comments:
For an initial implementation, we definitely need to answer (1), but we don't necessarily need to have the most efficient implementation on our first PR. Let me know what you think |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
is this support given? wildcard support in hosts |
Allow for wildcards when specifying Host headers and routing information for interceptor and scaler.
Use-Case
Some services might have multiple hostnames, say for multiple customers in the form of "customername.service.example.com". So supplying a single Host header for routing/scaling wont suffice. We would need to support simple wildcards (*.service.exmaple.com") at the very least for this case. It might also be desirable to have the host parameter be a list rather than a single value.
Specification
I'm not intimately familiar with the internals of the project but my first take would be:
host
in anHTTPScaledObject
allow for wildcards (and possibly multiple values)The text was updated successfully, but these errors were encountered: