-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from ngrok/revert-198-mo/bindings-to-binding
Revert "endpoints bind to a single binding "
- Loading branch information
Showing
11 changed files
with
83 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package config | ||
|
||
type bindings []string | ||
|
||
// WithBinding configures ingress for an endpoint | ||
// | ||
// The requestedBindings argument specifies the type of ingress for the endpoint. | ||
func WithBindings(requestedBindings ...string) interface { | ||
HTTPEndpointOption | ||
TLSEndpointOption | ||
TCPEndpointOption | ||
} { | ||
ret := bindings{} | ||
for _, binding := range requestedBindings { | ||
ret = append(ret, binding) | ||
} | ||
return ret | ||
} | ||
|
||
func (b bindings) ApplyTLS(cfg *tlsOptions) { | ||
cfg.Bindings = []string(b) | ||
} | ||
|
||
func (b bindings) ApplyTCP(cfg *tcpOptions) { | ||
cfg.Bindings = []string(b) | ||
} | ||
|
||
func (b bindings) ApplyHTTP(cfg *httpOptions) { | ||
cfg.Bindings = []string(b) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func testBindings[T tunnelConfigPrivate, OT any](t *testing.T, | ||
makeOpts func(...OT) Tunnel, | ||
) { | ||
optsFunc := func(opts ...any) Tunnel { | ||
return makeOpts(assertSlice[OT](opts)...) | ||
} | ||
|
||
cases := testCases[T, any]{ | ||
{ | ||
name: "absent", | ||
opts: optsFunc(), | ||
expectExtra: &matchBindExtra{ | ||
Bindings: ptr([]string{}), | ||
}, | ||
}, | ||
{ | ||
name: "with bindings", | ||
opts: optsFunc(WithBindings("public")), | ||
expectExtra: &matchBindExtra{ | ||
Bindings: ptr([]string{"public"}), | ||
}, | ||
}, | ||
{ | ||
name: "with bindings with spread op", | ||
opts: optsFunc(WithBindings([]string{"public"}...)), | ||
expectExtra: &matchBindExtra{ | ||
Bindings: ptr([]string{"public"}), | ||
}, | ||
}, | ||
} | ||
|
||
cases.runAll(t) | ||
} | ||
|
||
func TestBindings(t *testing.T) { | ||
testBindings[*httpOptions](t, HTTPEndpoint) | ||
testBindings[*tlsOptions](t, TLSEndpoint) | ||
testBindings[*tcpOptions](t, TCPEndpoint) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters