mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-04 17:29:16 +02:00
cluster name (#1834)
This commit is contained in:
parent
67f6030e1e
commit
66ff2cdaba
6 changed files with 86 additions and 19 deletions
|
@ -243,6 +243,10 @@ func (srv *Server) buildControlPlanePrefixRoute(prefix string, protected bool) (
|
|||
}
|
||||
|
||||
var getPolicyName = func(policy *config.Policy) string {
|
||||
if policy.EnvoyOpts != nil && policy.EnvoyOpts.Name != "" {
|
||||
return policy.EnvoyOpts.Name
|
||||
}
|
||||
|
||||
id, _ := policy.RouteID()
|
||||
return fmt.Sprintf("policy-%x", id)
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
envoy_config_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
|
||||
envoy_config_route_v3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -936,6 +937,11 @@ func Test_buildPolicyRouteRedirectAction(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestPolicyName(t *testing.T) {
|
||||
assert.Greater(t, getPolicyName(&config.Policy{}), "policy-")
|
||||
assert.Equal(t, getPolicyName(&config.Policy{EnvoyOpts: &envoy_config_cluster_v3.Cluster{Name: "my-pomerium-cluster"}}), "my-pomerium-cluster")
|
||||
}
|
||||
|
||||
func mustParseURL(t *testing.T, str string) *url.URL {
|
||||
u, err := url.Parse(str)
|
||||
require.NoError(t, err, str)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue