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

alias WithTrafficPolicy to WithPolicyString #190

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.11.0

Changes:

- Adds `WithTrafficPolicy` function, replacing `WithPolicyString`

## 1.10.0

Enhancements:
Expand Down
18 changes: 14 additions & 4 deletions config/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type rule po.Rule
type action po.Action
type trafficPolicy string

// WithPolicyString configures this edge with the provided policy configuration
// passed as a json or yaml string and overwrites any previously-set traffic policy
// WithTrafficPolicy configures this edge with the provided policy configuration
// passed as a json or yaml string and overwrites any previously-set traffic policy.
// https://ngrok.com/docs/http/traffic-policy
func WithPolicyString(str string) interface {
func WithTrafficPolicy(str string) interface {
HTTPEndpointOption
TLSEndpointOption
TCPEndpointOption
Expand All @@ -29,6 +29,16 @@ func WithPolicyString(str string) interface {
return trafficPolicy(str)
}

// WithPolicyString is deprecated, use WithTrafficPolicy instead.
// https://ngrok.com/docs/http/traffic-policy/
func WithPolicyString(str string) interface {
HTTPEndpointOption
TLSEndpointOption
TCPEndpointOption
} {
return WithTrafficPolicy(str)
}

func (p trafficPolicy) ApplyTLS(opts *tlsOptions) {
opts.TrafficPolicy = string(p)
}
Expand All @@ -51,7 +61,7 @@ func isYamlStr(yamlStr string) bool {
return yaml.Unmarshal([]byte(yamlStr), &yml) == nil
}

// WithPolicy is deprecated, use WithPolicyString instead.
// WithPolicy is deprecated, use WithTrafficPolicy instead.
// https://ngrok.com/docs/http/traffic-policy/
func WithPolicy(p po.Policy) interface {
HTTPEndpointOption
Expand Down
4 changes: 2 additions & 2 deletions config/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ inbound:
{
name: "with valid JSON policy string",
opts: optsFunc(
WithPolicyString(`
WithTrafficPolicy(`
{
"inbound":[
{
Expand Down Expand Up @@ -145,7 +145,7 @@ inbound:
{
name: "with valid YAML policy string",
opts: optsFunc(
WithPolicyString(yamlPolicy)),
WithTrafficPolicy(yamlPolicy)),
expectOpts: func(t *testing.T, opts *O) {
actual := getPolicies(opts)
require.NotEmpty(t, actual)
Expand Down
Loading