2019-04-30 23:27:16 +00:00
|
|
|
package write
|
|
|
|
|
|
|
|
import (
|
2021-04-29 21:44:32 +00:00
|
|
|
"bytes"
|
2019-04-30 23:27:16 +00:00
|
|
|
"io"
|
2019-06-28 16:35:35 +00:00
|
|
|
"strings"
|
2019-04-30 23:27:16 +00:00
|
|
|
"testing"
|
2019-06-28 16:35:35 +00:00
|
|
|
"time"
|
2019-04-30 23:27:16 +00:00
|
|
|
|
2020-10-06 18:24:05 +00:00
|
|
|
"github.com/hashicorp/consul/agent/structs"
|
|
|
|
|
2021-04-06 18:19:59 +00:00
|
|
|
"github.com/mitchellh/cli"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
2019-04-30 23:27:16 +00:00
|
|
|
"github.com/hashicorp/consul/agent"
|
|
|
|
"github.com/hashicorp/consul/api"
|
|
|
|
"github.com/hashicorp/consul/sdk/testutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestConfigWrite_noTabs(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
require.NotContains(t, New(cli.NewMockUi()).Help(), "\t")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestConfigWrite(t *testing.T) {
|
2020-12-07 18:42:55 +00:00
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("too slow for testing.Short")
|
|
|
|
}
|
|
|
|
|
2019-04-30 23:27:16 +00:00
|
|
|
t.Parallel()
|
|
|
|
|
2020-03-31 19:59:56 +00:00
|
|
|
a := agent.NewTestAgent(t, ``)
|
2019-04-30 23:27:16 +00:00
|
|
|
defer a.Shutdown()
|
|
|
|
client := a.Client()
|
|
|
|
|
|
|
|
t.Run("File", func(t *testing.T) {
|
|
|
|
ui := cli.NewMockUi()
|
|
|
|
c := New(ui)
|
|
|
|
|
|
|
|
f := testutil.TempFile(t, "config-write-svc-web.hcl")
|
|
|
|
_, err := f.WriteString(`
|
|
|
|
Kind = "service-defaults"
|
|
|
|
Name = "web"
|
|
|
|
Protocol = "udp"
|
|
|
|
`)
|
|
|
|
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
args := []string{
|
|
|
|
"-http-addr=" + a.HTTPAddr(),
|
|
|
|
f.Name(),
|
|
|
|
}
|
|
|
|
|
|
|
|
code := c.Run(args)
|
|
|
|
require.Empty(t, ui.ErrorWriter.String())
|
2020-06-29 20:47:40 +00:00
|
|
|
require.Contains(t, ui.OutputWriter.String(),
|
|
|
|
`Config entry written: service-defaults/web`)
|
2019-04-30 23:27:16 +00:00
|
|
|
require.Equal(t, 0, code)
|
|
|
|
|
|
|
|
entry, _, err := client.ConfigEntries().Get("service-defaults", "web", nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
svc, ok := entry.(*api.ServiceConfigEntry)
|
|
|
|
require.True(t, ok)
|
|
|
|
require.Equal(t, api.ServiceDefaults, svc.Kind)
|
|
|
|
require.Equal(t, "web", svc.Name)
|
|
|
|
require.Equal(t, "udp", svc.Protocol)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Stdin", func(t *testing.T) {
|
|
|
|
stdinR, stdinW := io.Pipe()
|
|
|
|
|
|
|
|
ui := cli.NewMockUi()
|
|
|
|
c := New(ui)
|
|
|
|
c.testStdin = stdinR
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
stdinW.Write([]byte(`{
|
|
|
|
"Kind": "proxy-defaults",
|
|
|
|
"Name": "global",
|
|
|
|
"Config": {
|
|
|
|
"foo": "bar",
|
|
|
|
"bar": 1.0
|
|
|
|
}
|
|
|
|
}`))
|
|
|
|
stdinW.Close()
|
|
|
|
}()
|
|
|
|
|
|
|
|
args := []string{
|
|
|
|
"-http-addr=" + a.HTTPAddr(),
|
|
|
|
"-",
|
|
|
|
}
|
|
|
|
|
|
|
|
code := c.Run(args)
|
|
|
|
require.Empty(t, ui.ErrorWriter.String())
|
2020-06-29 20:47:40 +00:00
|
|
|
require.Contains(t, ui.OutputWriter.String(),
|
|
|
|
`Config entry written: proxy-defaults/global`)
|
2019-04-30 23:27:16 +00:00
|
|
|
require.Equal(t, 0, code)
|
|
|
|
|
|
|
|
entry, _, err := client.ConfigEntries().Get(api.ProxyDefaults, api.ProxyConfigGlobal, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
proxy, ok := entry.(*api.ProxyConfigEntry)
|
|
|
|
require.True(t, ok)
|
|
|
|
require.Equal(t, api.ProxyDefaults, proxy.Kind)
|
|
|
|
require.Equal(t, api.ProxyConfigGlobal, proxy.Name)
|
|
|
|
require.Equal(t, map[string]interface{}{"foo": "bar", "bar": 1.0}, proxy.Config)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("No config", func(t *testing.T) {
|
|
|
|
ui := cli.NewMockUi()
|
|
|
|
c := New(ui)
|
|
|
|
|
|
|
|
code := c.Run([]string{})
|
|
|
|
require.NotEqual(t, 0, code)
|
|
|
|
require.NotEmpty(t, ui.ErrorWriter.String())
|
|
|
|
})
|
2021-04-29 21:44:32 +00:00
|
|
|
|
|
|
|
t.Run("mesh config entry", func(t *testing.T) {
|
|
|
|
stdin := new(bytes.Buffer)
|
|
|
|
stdin.WriteString(`
|
|
|
|
kind = "mesh"
|
|
|
|
meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
|
|
|
transparent_proxy {
|
2021-06-14 20:15:09 +00:00
|
|
|
mesh_destinations_only = true
|
2021-04-29 21:44:32 +00:00
|
|
|
}
|
2022-05-03 20:29:45 +00:00
|
|
|
http {
|
|
|
|
sanitize_x_forwarded_client_cert = true
|
|
|
|
}
|
2021-04-29 21:44:32 +00:00
|
|
|
`)
|
|
|
|
|
|
|
|
ui := cli.NewMockUi()
|
|
|
|
c := New(ui)
|
|
|
|
c.testStdin = stdin
|
|
|
|
|
|
|
|
code := c.Run([]string{"-http-addr=" + a.HTTPAddr(), "-"})
|
|
|
|
require.Empty(t, ui.ErrorWriter.String())
|
|
|
|
require.Contains(t, ui.OutputWriter.String(),
|
|
|
|
`Config entry written: mesh/mesh`)
|
|
|
|
require.Equal(t, 0, code)
|
|
|
|
|
|
|
|
entry, _, err := client.ConfigEntries().Get(api.MeshConfig, api.MeshConfigMesh, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
proxy, ok := entry.(*api.MeshConfigEntry)
|
|
|
|
require.True(t, ok)
|
|
|
|
require.Equal(t, map[string]string{"foo": "bar", "gir": "zim"}, proxy.Meta)
|
2022-05-03 20:29:45 +00:00
|
|
|
require.True(t, proxy.TransparentProxy.MeshDestinationsOnly)
|
|
|
|
|
|
|
|
require.True(t, proxy.HTTP.SanitizeXForwardedClientCert)
|
2021-04-29 21:44:32 +00:00
|
|
|
})
|
2019-06-28 16:35:35 +00:00
|
|
|
}
|
|
|
|
|
2019-07-12 17:20:30 +00:00
|
|
|
// TestParseConfigEntry is the 'api' mirror image of
|
|
|
|
// agent/structs/config_entry_test.go:TestDecodeConfigEntry
|
2019-06-28 16:35:35 +00:00
|
|
|
func TestParseConfigEntry(t *testing.T) {
|
2019-07-12 17:20:30 +00:00
|
|
|
t.Parallel()
|
2019-06-28 16:35:35 +00:00
|
|
|
for _, tc := range []struct {
|
2019-08-07 21:41:33 +00:00
|
|
|
name string
|
|
|
|
camel, camelJSON string
|
|
|
|
snake, snakeJSON string
|
|
|
|
expect api.ConfigEntry
|
|
|
|
expectJSON api.ConfigEntry
|
|
|
|
expectErr string
|
2019-06-28 16:35:35 +00:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "proxy-defaults: extra fields or typo",
|
|
|
|
snake: `
|
|
|
|
kind = "proxy-defaults"
|
|
|
|
name = "main"
|
|
|
|
cornfig {
|
|
|
|
"foo" = 19
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camel: `
|
|
|
|
Kind = "proxy-defaults"
|
|
|
|
Name = "main"
|
|
|
|
Cornfig {
|
|
|
|
"foo" = 19
|
|
|
|
}
|
|
|
|
`,
|
2019-08-07 21:41:33 +00:00
|
|
|
snakeJSON: `
|
|
|
|
{
|
|
|
|
"kind": "proxy-defaults",
|
|
|
|
"name": "main",
|
|
|
|
"cornfig": {
|
|
|
|
"foo": 19
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
|
|
|
"Kind": "proxy-defaults",
|
|
|
|
"Name": "main",
|
|
|
|
"Cornfig": {
|
|
|
|
"foo": 19
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2019-06-28 16:35:35 +00:00
|
|
|
expectErr: `invalid config key "cornfig"`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "proxy-defaults",
|
|
|
|
snake: `
|
|
|
|
kind = "proxy-defaults"
|
|
|
|
name = "main"
|
2020-09-02 19:10:25 +00:00
|
|
|
meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
2019-06-28 16:35:35 +00:00
|
|
|
config {
|
|
|
|
"foo" = 19
|
|
|
|
"bar" = "abc"
|
|
|
|
"moreconfig" {
|
|
|
|
"moar" = "config"
|
|
|
|
}
|
|
|
|
}
|
2019-07-02 22:15:30 +00:00
|
|
|
mesh_gateway {
|
|
|
|
mode = "remote"
|
|
|
|
}
|
2021-04-12 15:35:14 +00:00
|
|
|
mode = "direct"
|
|
|
|
transparent_proxy = {
|
|
|
|
outbound_listener_port = 10101
|
2021-06-09 20:34:17 +00:00
|
|
|
dialed_directly = true
|
2021-04-12 15:35:14 +00:00
|
|
|
}
|
2019-06-28 16:35:35 +00:00
|
|
|
`,
|
|
|
|
camel: `
|
|
|
|
Kind = "proxy-defaults"
|
|
|
|
Name = "main"
|
2020-09-02 19:10:25 +00:00
|
|
|
Meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
2019-06-28 16:35:35 +00:00
|
|
|
Config {
|
|
|
|
"foo" = 19
|
|
|
|
"bar" = "abc"
|
|
|
|
"moreconfig" {
|
|
|
|
"moar" = "config"
|
|
|
|
}
|
|
|
|
}
|
2019-07-02 22:15:30 +00:00
|
|
|
MeshGateway {
|
|
|
|
Mode = "remote"
|
|
|
|
}
|
2021-04-12 15:35:14 +00:00
|
|
|
Mode = "direct"
|
|
|
|
TransparentProxy = {
|
|
|
|
outbound_listener_port = 10101
|
2021-06-09 20:34:17 +00:00
|
|
|
dialed_directly = true
|
2021-04-12 15:35:14 +00:00
|
|
|
}
|
2019-06-28 16:35:35 +00:00
|
|
|
`,
|
2019-08-07 21:41:33 +00:00
|
|
|
snakeJSON: `
|
|
|
|
{
|
|
|
|
"kind": "proxy-defaults",
|
|
|
|
"name": "main",
|
2020-09-02 19:10:25 +00:00
|
|
|
"meta" : {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
2019-08-07 21:41:33 +00:00
|
|
|
"config": {
|
|
|
|
"foo": 19,
|
|
|
|
"bar": "abc",
|
|
|
|
"moreconfig": {
|
|
|
|
"moar": "config"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"mesh_gateway": {
|
|
|
|
"mode": "remote"
|
2021-03-11 06:08:41 +00:00
|
|
|
},
|
2021-04-12 15:35:14 +00:00
|
|
|
"mode": "direct",
|
|
|
|
"transparent_proxy": {
|
2021-06-09 20:34:17 +00:00
|
|
|
"outbound_listener_port": 10101,
|
|
|
|
"dialed_directly": true
|
2021-04-12 15:35:14 +00:00
|
|
|
}
|
2019-08-07 21:41:33 +00:00
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
|
|
|
"Kind": "proxy-defaults",
|
|
|
|
"Name": "main",
|
2020-09-02 19:10:25 +00:00
|
|
|
"Meta" : {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
2019-08-07 21:41:33 +00:00
|
|
|
"Config": {
|
|
|
|
"foo": 19,
|
|
|
|
"bar": "abc",
|
|
|
|
"moreconfig": {
|
|
|
|
"moar": "config"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"MeshGateway": {
|
|
|
|
"Mode": "remote"
|
2021-03-11 06:08:41 +00:00
|
|
|
},
|
2021-04-12 15:35:14 +00:00
|
|
|
"Mode": "direct",
|
|
|
|
"TransparentProxy": {
|
2021-06-09 20:34:17 +00:00
|
|
|
"OutboundListenerPort": 10101,
|
|
|
|
"DialedDirectly": true
|
2021-04-12 15:35:14 +00:00
|
|
|
}
|
2019-08-07 21:41:33 +00:00
|
|
|
}
|
|
|
|
`,
|
2019-06-28 16:35:35 +00:00
|
|
|
expect: &api.ProxyConfigEntry{
|
|
|
|
Kind: "proxy-defaults",
|
|
|
|
Name: "main",
|
2020-09-02 19:10:25 +00:00
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim",
|
|
|
|
},
|
2019-06-28 16:35:35 +00:00
|
|
|
Config: map[string]interface{}{
|
|
|
|
"foo": 19,
|
|
|
|
"bar": "abc",
|
|
|
|
"moreconfig": map[string]interface{}{
|
|
|
|
"moar": "config",
|
|
|
|
},
|
|
|
|
},
|
2019-07-02 22:15:30 +00:00
|
|
|
MeshGateway: api.MeshGatewayConfig{
|
|
|
|
Mode: api.MeshGatewayModeRemote,
|
|
|
|
},
|
2021-04-12 15:35:14 +00:00
|
|
|
Mode: api.ProxyModeDirect,
|
2021-04-13 17:54:56 +00:00
|
|
|
TransparentProxy: &api.TransparentProxyConfig{
|
2021-04-12 15:35:14 +00:00
|
|
|
OutboundListenerPort: 10101,
|
2021-06-09 20:34:17 +00:00
|
|
|
DialedDirectly: true,
|
2021-04-12 15:35:14 +00:00
|
|
|
},
|
2019-06-28 16:35:35 +00:00
|
|
|
},
|
2019-08-07 21:41:33 +00:00
|
|
|
expectJSON: &api.ProxyConfigEntry{
|
|
|
|
Kind: "proxy-defaults",
|
|
|
|
Name: "main",
|
2020-09-02 19:10:25 +00:00
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim",
|
|
|
|
},
|
2019-08-07 21:41:33 +00:00
|
|
|
Config: map[string]interface{}{
|
|
|
|
"foo": float64(19), // json decoding gives float64 instead of int here
|
|
|
|
"bar": "abc",
|
|
|
|
"moreconfig": map[string]interface{}{
|
|
|
|
"moar": "config",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
MeshGateway: api.MeshGatewayConfig{
|
|
|
|
Mode: api.MeshGatewayModeRemote,
|
|
|
|
},
|
2021-04-12 15:35:14 +00:00
|
|
|
Mode: api.ProxyModeDirect,
|
2021-04-13 17:54:56 +00:00
|
|
|
TransparentProxy: &api.TransparentProxyConfig{
|
2021-04-12 15:35:14 +00:00
|
|
|
OutboundListenerPort: 10101,
|
2021-06-09 20:34:17 +00:00
|
|
|
DialedDirectly: true,
|
2021-04-12 15:35:14 +00:00
|
|
|
},
|
2019-08-07 21:41:33 +00:00
|
|
|
},
|
2019-06-28 16:35:35 +00:00
|
|
|
},
|
2020-03-31 19:27:32 +00:00
|
|
|
{
|
|
|
|
name: "terminating-gateway",
|
|
|
|
snake: `
|
|
|
|
kind = "terminating-gateway"
|
|
|
|
name = "terminating-gw-west"
|
|
|
|
namespace = "default"
|
2020-09-02 19:10:25 +00:00
|
|
|
meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
2020-03-31 19:27:32 +00:00
|
|
|
services = [
|
|
|
|
{
|
|
|
|
name = "billing"
|
|
|
|
namespace = "biz"
|
|
|
|
ca_file = "/etc/ca.crt"
|
|
|
|
cert_file = "/etc/client.crt"
|
|
|
|
key_file = "/etc/tls.key"
|
2020-04-27 22:25:37 +00:00
|
|
|
sni = "mydomain"
|
2020-03-31 19:27:32 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "*"
|
|
|
|
namespace = "ops"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
`,
|
|
|
|
camel: `
|
|
|
|
Kind = "terminating-gateway"
|
|
|
|
Name = "terminating-gw-west"
|
|
|
|
Namespace = "default"
|
2020-09-02 19:10:25 +00:00
|
|
|
Meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
2020-03-31 19:27:32 +00:00
|
|
|
Services = [
|
|
|
|
{
|
|
|
|
Name = "billing"
|
|
|
|
Namespace = "biz"
|
|
|
|
CAFile = "/etc/ca.crt"
|
|
|
|
CertFile = "/etc/client.crt"
|
|
|
|
KeyFile = "/etc/tls.key"
|
2020-04-27 22:25:37 +00:00
|
|
|
SNI = "mydomain"
|
2020-03-31 19:27:32 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "*"
|
|
|
|
Namespace = "ops"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
`,
|
|
|
|
snakeJSON: `
|
|
|
|
{
|
|
|
|
"kind": "terminating-gateway",
|
|
|
|
"name": "terminating-gw-west",
|
|
|
|
"namespace": "default",
|
2020-09-02 19:10:25 +00:00
|
|
|
"meta" : {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
2020-03-31 19:27:32 +00:00
|
|
|
"services": [
|
|
|
|
{
|
|
|
|
"name": "billing",
|
|
|
|
"namespace": "biz",
|
|
|
|
"ca_file": "/etc/ca.crt",
|
|
|
|
"cert_file": "/etc/client.crt",
|
2020-04-27 22:25:37 +00:00
|
|
|
"key_file": "/etc/tls.key",
|
|
|
|
"sni": "mydomain"
|
2020-03-31 19:27:32 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "*",
|
|
|
|
"namespace": "ops"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
|
|
|
"Kind": "terminating-gateway",
|
|
|
|
"Name": "terminating-gw-west",
|
|
|
|
"Namespace": "default",
|
2020-09-02 19:10:25 +00:00
|
|
|
"Meta" : {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
2020-03-31 19:27:32 +00:00
|
|
|
"Services": [
|
|
|
|
{
|
|
|
|
"Name": "billing",
|
|
|
|
"Namespace": "biz",
|
|
|
|
"CAFile": "/etc/ca.crt",
|
|
|
|
"CertFile": "/etc/client.crt",
|
2020-04-27 22:25:37 +00:00
|
|
|
"KeyFile": "/etc/tls.key",
|
|
|
|
"SNI": "mydomain"
|
2020-03-31 19:27:32 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "*",
|
|
|
|
"Namespace": "ops"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
expect: &api.TerminatingGatewayConfigEntry{
|
|
|
|
Kind: "terminating-gateway",
|
|
|
|
Name: "terminating-gw-west",
|
|
|
|
Namespace: "default",
|
2020-09-02 19:10:25 +00:00
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim",
|
|
|
|
},
|
2020-03-31 19:27:32 +00:00
|
|
|
Services: []api.LinkedService{
|
|
|
|
{
|
|
|
|
Name: "billing",
|
|
|
|
Namespace: "biz",
|
|
|
|
CAFile: "/etc/ca.crt",
|
|
|
|
CertFile: "/etc/client.crt",
|
|
|
|
KeyFile: "/etc/tls.key",
|
2020-04-27 22:25:37 +00:00
|
|
|
SNI: "mydomain",
|
2020-03-31 19:27:32 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "*",
|
|
|
|
Namespace: "ops",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expectJSON: &api.TerminatingGatewayConfigEntry{
|
|
|
|
Kind: "terminating-gateway",
|
|
|
|
Name: "terminating-gw-west",
|
|
|
|
Namespace: "default",
|
2020-09-02 19:10:25 +00:00
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim",
|
|
|
|
},
|
2020-03-31 19:27:32 +00:00
|
|
|
Services: []api.LinkedService{
|
|
|
|
{
|
|
|
|
Name: "billing",
|
|
|
|
Namespace: "biz",
|
|
|
|
CAFile: "/etc/ca.crt",
|
|
|
|
CertFile: "/etc/client.crt",
|
|
|
|
KeyFile: "/etc/tls.key",
|
2020-04-27 22:25:37 +00:00
|
|
|
SNI: "mydomain",
|
2020-03-31 19:27:32 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "*",
|
|
|
|
Namespace: "ops",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-06-28 16:35:35 +00:00
|
|
|
{
|
2021-03-09 05:10:27 +00:00
|
|
|
name: "service-defaults: kitchen sink",
|
2019-06-28 16:35:35 +00:00
|
|
|
snake: `
|
|
|
|
kind = "service-defaults"
|
|
|
|
name = "main"
|
2020-09-02 19:10:25 +00:00
|
|
|
meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
2019-06-28 16:35:35 +00:00
|
|
|
protocol = "http"
|
2019-08-19 17:19:44 +00:00
|
|
|
external_sni = "abc-123"
|
2019-07-02 22:15:30 +00:00
|
|
|
mesh_gateway {
|
|
|
|
mode = "remote"
|
|
|
|
}
|
2021-04-12 15:35:14 +00:00
|
|
|
mode = "direct"
|
|
|
|
transparent_proxy = {
|
|
|
|
outbound_listener_port = 10101
|
2021-06-09 20:34:17 +00:00
|
|
|
dialed_directly = true
|
2021-04-12 15:35:14 +00:00
|
|
|
}
|
2021-04-15 19:21:44 +00:00
|
|
|
upstream_config {
|
|
|
|
overrides = [
|
|
|
|
{
|
|
|
|
name = "redis"
|
2021-03-09 05:10:27 +00:00
|
|
|
passive_health_check {
|
|
|
|
max_failures = 3
|
|
|
|
interval = "2s"
|
|
|
|
}
|
2021-04-15 19:21:44 +00:00
|
|
|
envoy_listener_json = "{ \"listener-foo\": 5 }"
|
|
|
|
envoy_cluster_json = "{ \"cluster-bar\": 5 }"
|
|
|
|
protocol = "grpc"
|
|
|
|
connect_timeout_ms = 6543
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "finance--billing"
|
2021-03-09 05:10:27 +00:00
|
|
|
mesh_gateway {
|
|
|
|
mode = "remote"
|
|
|
|
}
|
2021-04-15 19:21:44 +00:00
|
|
|
limits {
|
|
|
|
max_connections = 1111
|
|
|
|
max_pending_requests = 2222
|
|
|
|
max_concurrent_requests = 3333
|
|
|
|
}
|
2021-03-09 05:10:27 +00:00
|
|
|
}
|
2021-04-15 19:21:44 +00:00
|
|
|
]
|
|
|
|
defaults {
|
2021-03-15 20:12:57 +00:00
|
|
|
envoy_cluster_json = "zip"
|
|
|
|
envoy_listener_json = "zop"
|
2021-03-09 05:10:27 +00:00
|
|
|
connect_timeout_ms = 5000
|
|
|
|
protocol = "http"
|
|
|
|
limits {
|
|
|
|
max_connections = 3
|
|
|
|
max_pending_requests = 4
|
|
|
|
max_concurrent_requests = 5
|
|
|
|
}
|
|
|
|
passive_health_check {
|
|
|
|
max_failures = 5
|
|
|
|
interval = "4s"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-06-28 16:35:35 +00:00
|
|
|
`,
|
|
|
|
camel: `
|
|
|
|
Kind = "service-defaults"
|
|
|
|
Name = "main"
|
2020-09-02 19:10:25 +00:00
|
|
|
Meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
2019-06-28 16:35:35 +00:00
|
|
|
Protocol = "http"
|
2019-08-19 17:19:44 +00:00
|
|
|
ExternalSNI = "abc-123"
|
2019-07-02 22:15:30 +00:00
|
|
|
MeshGateway {
|
|
|
|
Mode = "remote"
|
|
|
|
}
|
2021-04-12 15:35:14 +00:00
|
|
|
Mode = "direct"
|
|
|
|
TransparentProxy = {
|
|
|
|
outbound_listener_port = 10101
|
2021-06-09 20:34:17 +00:00
|
|
|
dialed_directly = true
|
2021-04-12 15:35:14 +00:00
|
|
|
}
|
2021-04-15 19:21:44 +00:00
|
|
|
UpstreamConfig {
|
|
|
|
Overrides = [
|
|
|
|
{
|
|
|
|
Name = "redis"
|
|
|
|
PassiveHealthCheck {
|
|
|
|
MaxFailures = 3
|
|
|
|
Interval = "2s"
|
2021-03-09 05:10:27 +00:00
|
|
|
}
|
2021-04-15 19:21:44 +00:00
|
|
|
EnvoyListenerJson = "{ \"listener-foo\": 5 }"
|
|
|
|
EnvoyClusterJson = "{ \"cluster-bar\": 5 }"
|
|
|
|
Protocol = "grpc"
|
|
|
|
ConnectTimeoutMs = 6543
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "finance--billing"
|
|
|
|
MeshGateway {
|
|
|
|
Mode = "remote"
|
|
|
|
}
|
|
|
|
Limits {
|
|
|
|
MaxConnections = 1111
|
|
|
|
MaxPendingRequests = 2222
|
|
|
|
MaxConcurrentRequests = 3333
|
2021-03-09 05:10:27 +00:00
|
|
|
}
|
|
|
|
}
|
2021-04-15 19:21:44 +00:00
|
|
|
]
|
|
|
|
Defaults {
|
|
|
|
EnvoyClusterJson = "zip"
|
|
|
|
EnvoyListenerJson = "zop"
|
|
|
|
ConnectTimeoutMs = 5000
|
|
|
|
Protocol = "http"
|
|
|
|
Limits {
|
|
|
|
MaxConnections = 3
|
|
|
|
MaxPendingRequests = 4
|
|
|
|
MaxConcurrentRequests = 5
|
2021-03-09 05:10:27 +00:00
|
|
|
}
|
2021-04-15 19:21:44 +00:00
|
|
|
PassiveHealthCheck {
|
|
|
|
MaxFailures = 5
|
|
|
|
Interval = "4s"
|
2021-03-09 05:10:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-06-28 16:35:35 +00:00
|
|
|
`,
|
2019-08-07 21:41:33 +00:00
|
|
|
snakeJSON: `
|
|
|
|
{
|
|
|
|
"kind": "service-defaults",
|
|
|
|
"name": "main",
|
2020-09-02 19:10:25 +00:00
|
|
|
"meta" : {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
2019-08-07 21:41:33 +00:00
|
|
|
"protocol": "http",
|
2019-08-19 17:19:44 +00:00
|
|
|
"external_sni": "abc-123",
|
2019-08-07 21:41:33 +00:00
|
|
|
"mesh_gateway": {
|
|
|
|
"mode": "remote"
|
2021-03-09 05:10:27 +00:00
|
|
|
},
|
2021-04-12 15:35:14 +00:00
|
|
|
"mode": "direct",
|
|
|
|
"transparent_proxy": {
|
2021-06-09 20:34:17 +00:00
|
|
|
"outbound_listener_port": 10101,
|
|
|
|
"dialed_directly": true
|
2021-04-12 15:35:14 +00:00
|
|
|
},
|
2021-04-15 19:21:44 +00:00
|
|
|
"upstream_config": {
|
|
|
|
"overrides": [
|
|
|
|
{
|
|
|
|
"name": "redis",
|
2021-03-09 05:10:27 +00:00
|
|
|
"passive_health_check": {
|
|
|
|
"max_failures": 3,
|
|
|
|
"interval": "2s"
|
2021-04-15 19:21:44 +00:00
|
|
|
},
|
|
|
|
"envoy_listener_json": "{ \"listener-foo\": 5 }",
|
|
|
|
"envoy_cluster_json": "{ \"cluster-bar\": 5 }",
|
|
|
|
"protocol": "grpc",
|
|
|
|
"connect_timeout_ms": 6543
|
2021-03-09 05:10:27 +00:00
|
|
|
},
|
2021-04-15 19:21:44 +00:00
|
|
|
{
|
|
|
|
"name": "finance--billing",
|
2021-03-09 05:10:27 +00:00
|
|
|
"mesh_gateway": {
|
|
|
|
"mode": "remote"
|
2021-04-15 19:21:44 +00:00
|
|
|
},
|
|
|
|
"limits": {
|
|
|
|
"max_connections": 1111,
|
|
|
|
"max_pending_requests": 2222,
|
|
|
|
"max_concurrent_requests": 3333
|
2021-03-09 05:10:27 +00:00
|
|
|
}
|
|
|
|
}
|
2021-04-15 19:21:44 +00:00
|
|
|
],
|
|
|
|
"defaults": {
|
2021-03-15 20:12:57 +00:00
|
|
|
"envoy_cluster_json": "zip",
|
|
|
|
"envoy_listener_json": "zop",
|
2021-03-09 05:10:27 +00:00
|
|
|
"connect_timeout_ms": 5000,
|
|
|
|
"protocol": "http",
|
|
|
|
"limits": {
|
|
|
|
"max_connections": 3,
|
|
|
|
"max_pending_requests": 4,
|
|
|
|
"max_concurrent_requests": 5
|
|
|
|
},
|
|
|
|
"passive_health_check": {
|
|
|
|
"max_failures": 5,
|
|
|
|
"interval": "4s"
|
|
|
|
}
|
|
|
|
}
|
2019-08-07 21:41:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
|
|
|
"Kind": "service-defaults",
|
|
|
|
"Name": "main",
|
2020-09-02 19:10:25 +00:00
|
|
|
"Meta" : {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
2019-08-07 21:41:33 +00:00
|
|
|
"Protocol": "http",
|
2019-08-19 17:19:44 +00:00
|
|
|
"ExternalSNI": "abc-123",
|
2019-08-07 21:41:33 +00:00
|
|
|
"MeshGateway": {
|
|
|
|
"Mode": "remote"
|
2021-03-09 05:10:27 +00:00
|
|
|
},
|
2021-04-12 15:35:14 +00:00
|
|
|
"Mode": "direct",
|
|
|
|
"TransparentProxy": {
|
2021-06-09 20:34:17 +00:00
|
|
|
"OutboundListenerPort": 10101,
|
|
|
|
"DialedDirectly": true
|
2021-04-12 15:35:14 +00:00
|
|
|
},
|
2021-04-15 19:21:44 +00:00
|
|
|
"UpstreamConfig": {
|
|
|
|
"Overrides": [
|
|
|
|
{
|
|
|
|
"Name": "redis",
|
2021-03-09 05:10:27 +00:00
|
|
|
"PassiveHealthCheck": {
|
|
|
|
"MaxFailures": 3,
|
|
|
|
"Interval": "2s"
|
2021-04-15 19:21:44 +00:00
|
|
|
},
|
|
|
|
"EnvoyListenerJson": "{ \"listener-foo\": 5 }",
|
|
|
|
"EnvoyClusterJson": "{ \"cluster-bar\": 5 }",
|
|
|
|
"Protocol": "grpc",
|
|
|
|
"ConnectTimeoutMs": 6543
|
2021-03-09 05:10:27 +00:00
|
|
|
},
|
2021-04-15 19:21:44 +00:00
|
|
|
{
|
|
|
|
"Name": "finance--billing",
|
2021-03-09 05:10:27 +00:00
|
|
|
"MeshGateway": {
|
|
|
|
"Mode": "remote"
|
2021-04-15 19:21:44 +00:00
|
|
|
},
|
|
|
|
"Limits": {
|
|
|
|
"MaxConnections": 1111,
|
|
|
|
"MaxPendingRequests": 2222,
|
|
|
|
"MaxConcurrentRequests": 3333
|
2021-03-09 05:10:27 +00:00
|
|
|
}
|
|
|
|
}
|
2021-04-15 19:21:44 +00:00
|
|
|
],
|
|
|
|
"Defaults": {
|
|
|
|
"EnvoyClusterJson": "zip",
|
|
|
|
"EnvoyListenerJson": "zop",
|
2021-03-09 05:10:27 +00:00
|
|
|
"ConnectTimeoutMs": 5000,
|
|
|
|
"Protocol": "http",
|
|
|
|
"Limits": {
|
|
|
|
"MaxConnections": 3,
|
|
|
|
"MaxPendingRequests": 4,
|
|
|
|
"MaxConcurrentRequests": 5
|
|
|
|
},
|
|
|
|
"PassiveHealthCheck": {
|
2021-04-15 19:21:44 +00:00
|
|
|
"MaxFailures": 5,
|
|
|
|
"Interval": "4s"
|
2021-03-09 05:10:27 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-07 21:41:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2019-06-28 16:35:35 +00:00
|
|
|
expect: &api.ServiceConfigEntry{
|
2020-09-02 19:10:25 +00:00
|
|
|
Kind: "service-defaults",
|
|
|
|
Name: "main",
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim",
|
|
|
|
},
|
2019-08-19 17:19:44 +00:00
|
|
|
Protocol: "http",
|
|
|
|
ExternalSNI: "abc-123",
|
2019-07-02 22:15:30 +00:00
|
|
|
MeshGateway: api.MeshGatewayConfig{
|
|
|
|
Mode: api.MeshGatewayModeRemote,
|
|
|
|
},
|
2021-04-12 15:35:14 +00:00
|
|
|
Mode: api.ProxyModeDirect,
|
2021-04-13 17:54:56 +00:00
|
|
|
TransparentProxy: &api.TransparentProxyConfig{
|
2021-04-12 15:35:14 +00:00
|
|
|
OutboundListenerPort: 10101,
|
2021-06-09 20:34:17 +00:00
|
|
|
DialedDirectly: true,
|
2021-04-12 15:35:14 +00:00
|
|
|
},
|
2021-04-15 19:21:44 +00:00
|
|
|
UpstreamConfig: &api.UpstreamConfiguration{
|
|
|
|
Overrides: []*api.UpstreamConfig{
|
|
|
|
{
|
|
|
|
Name: "redis",
|
2021-03-11 18:04:40 +00:00
|
|
|
PassiveHealthCheck: &api.PassiveHealthCheck{
|
2021-03-09 05:10:27 +00:00
|
|
|
MaxFailures: 3,
|
|
|
|
Interval: 2 * time.Second,
|
|
|
|
},
|
2021-04-15 19:21:44 +00:00
|
|
|
EnvoyListenerJSON: `{ "listener-foo": 5 }`,
|
|
|
|
EnvoyClusterJSON: `{ "cluster-bar": 5 }`,
|
|
|
|
Protocol: "grpc",
|
|
|
|
ConnectTimeoutMs: 6543,
|
2021-03-09 05:10:27 +00:00
|
|
|
},
|
2021-04-15 19:21:44 +00:00
|
|
|
{
|
|
|
|
Name: "finance--billing",
|
2021-03-09 05:10:27 +00:00
|
|
|
MeshGateway: api.MeshGatewayConfig{
|
|
|
|
Mode: "remote",
|
|
|
|
},
|
2021-04-15 19:21:44 +00:00
|
|
|
Limits: &api.UpstreamLimits{
|
|
|
|
MaxConnections: intPointer(1111),
|
|
|
|
MaxPendingRequests: intPointer(2222),
|
|
|
|
MaxConcurrentRequests: intPointer(3333),
|
|
|
|
},
|
2021-03-09 05:10:27 +00:00
|
|
|
},
|
|
|
|
},
|
2021-04-15 19:21:44 +00:00
|
|
|
Defaults: &api.UpstreamConfig{
|
2021-03-15 20:12:57 +00:00
|
|
|
EnvoyClusterJSON: "zip",
|
|
|
|
EnvoyListenerJSON: "zop",
|
|
|
|
Protocol: "http",
|
|
|
|
ConnectTimeoutMs: 5000,
|
2021-03-11 18:04:40 +00:00
|
|
|
Limits: &api.UpstreamLimits{
|
2021-04-15 19:21:44 +00:00
|
|
|
MaxConnections: intPointer(3),
|
|
|
|
MaxPendingRequests: intPointer(4),
|
|
|
|
MaxConcurrentRequests: intPointer(5),
|
2021-03-09 05:10:27 +00:00
|
|
|
},
|
2021-03-11 18:04:40 +00:00
|
|
|
PassiveHealthCheck: &api.PassiveHealthCheck{
|
2021-03-09 05:10:27 +00:00
|
|
|
MaxFailures: 5,
|
|
|
|
Interval: 4 * time.Second,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-06-28 16:35:35 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "service-router: kitchen sink",
|
|
|
|
snake: `
|
|
|
|
kind = "service-router"
|
|
|
|
name = "main"
|
2021-12-06 18:58:33 +00:00
|
|
|
partition = "pepper"
|
2020-09-02 19:10:25 +00:00
|
|
|
meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
2019-06-28 16:35:35 +00:00
|
|
|
routes = [
|
|
|
|
{
|
|
|
|
match {
|
|
|
|
http {
|
|
|
|
path_exact = "/foo"
|
|
|
|
header = [
|
|
|
|
{
|
|
|
|
name = "debug1"
|
|
|
|
present = true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "debug2"
|
|
|
|
present = false
|
|
|
|
invert = true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "debug3"
|
|
|
|
exact = "1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "debug4"
|
|
|
|
prefix = "aaa"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "debug5"
|
|
|
|
suffix = "bbb"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "debug6"
|
|
|
|
regex = "a.*z"
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
destination {
|
2021-12-06 18:58:33 +00:00
|
|
|
service = "carrot"
|
|
|
|
service_subset = "kale"
|
|
|
|
namespace = "leek"
|
|
|
|
partition = "chard"
|
|
|
|
prefix_rewrite = "/alternate"
|
|
|
|
request_timeout = "99s"
|
|
|
|
num_retries = 12345
|
2019-06-28 16:35:35 +00:00
|
|
|
retry_on_connect_failure = true
|
|
|
|
retry_on_status_codes = [401, 209]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
match {
|
|
|
|
http {
|
|
|
|
path_prefix = "/foo"
|
2019-07-24 01:56:39 +00:00
|
|
|
methods = [ "GET", "DELETE" ]
|
2019-06-28 16:35:35 +00:00
|
|
|
query_param = [
|
|
|
|
{
|
|
|
|
name = "hack1"
|
2019-07-24 01:55:26 +00:00
|
|
|
present = true
|
2019-06-28 16:35:35 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "hack2"
|
2019-07-24 01:55:26 +00:00
|
|
|
exact = "1"
|
2019-06-28 16:35:35 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "hack3"
|
2019-07-24 01:55:26 +00:00
|
|
|
regex = "a.*z"
|
2019-06-28 16:35:35 +00:00
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
match {
|
|
|
|
http {
|
|
|
|
path_regex = "/foo"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
]
|
|
|
|
`,
|
|
|
|
camel: `
|
|
|
|
Kind = "service-router"
|
|
|
|
Name = "main"
|
2021-12-06 18:58:33 +00:00
|
|
|
Partition = "pepper"
|
2020-09-02 19:10:25 +00:00
|
|
|
Meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
2019-06-28 16:35:35 +00:00
|
|
|
Routes = [
|
|
|
|
{
|
|
|
|
Match {
|
|
|
|
HTTP {
|
|
|
|
PathExact = "/foo"
|
|
|
|
Header = [
|
|
|
|
{
|
|
|
|
Name = "debug1"
|
|
|
|
Present = true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "debug2"
|
|
|
|
Present = false
|
|
|
|
Invert = true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "debug3"
|
|
|
|
Exact = "1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "debug4"
|
|
|
|
Prefix = "aaa"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "debug5"
|
|
|
|
Suffix = "bbb"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "debug6"
|
|
|
|
Regex = "a.*z"
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Destination {
|
|
|
|
Service = "carrot"
|
|
|
|
ServiceSubset = "kale"
|
|
|
|
Namespace = "leek"
|
2021-12-06 18:58:33 +00:00
|
|
|
Partition = "chard"
|
2019-06-28 16:35:35 +00:00
|
|
|
PrefixRewrite = "/alternate"
|
|
|
|
RequestTimeout = "99s"
|
|
|
|
NumRetries = 12345
|
|
|
|
RetryOnConnectFailure = true
|
|
|
|
RetryOnStatusCodes = [401, 209]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Match {
|
|
|
|
HTTP {
|
|
|
|
PathPrefix = "/foo"
|
2019-07-24 01:56:39 +00:00
|
|
|
Methods = [ "GET", "DELETE" ]
|
2019-06-28 16:35:35 +00:00
|
|
|
QueryParam = [
|
|
|
|
{
|
|
|
|
Name = "hack1"
|
2019-07-24 01:55:26 +00:00
|
|
|
Present = true
|
2019-06-28 16:35:35 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "hack2"
|
2019-07-24 01:55:26 +00:00
|
|
|
Exact = "1"
|
2019-06-28 16:35:35 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "hack3"
|
2019-07-24 01:55:26 +00:00
|
|
|
Regex = "a.*z"
|
2019-06-28 16:35:35 +00:00
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Match {
|
|
|
|
HTTP {
|
|
|
|
PathRegex = "/foo"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
]
|
|
|
|
`,
|
2019-08-07 21:41:33 +00:00
|
|
|
snakeJSON: `
|
|
|
|
{
|
|
|
|
"kind": "service-router",
|
|
|
|
"name": "main",
|
2021-12-06 18:58:33 +00:00
|
|
|
"partition": "pepper",
|
2020-09-02 19:10:25 +00:00
|
|
|
"meta" : {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
2019-08-07 21:41:33 +00:00
|
|
|
"routes": [
|
|
|
|
{
|
|
|
|
"match": {
|
|
|
|
"http": {
|
|
|
|
"path_exact": "/foo",
|
|
|
|
"header": [
|
|
|
|
{
|
|
|
|
"name": "debug1",
|
|
|
|
"present": true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "debug2",
|
|
|
|
"present": false,
|
|
|
|
"invert": true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "debug3",
|
|
|
|
"exact": "1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "debug4",
|
|
|
|
"prefix": "aaa"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "debug5",
|
|
|
|
"suffix": "bbb"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "debug6",
|
|
|
|
"regex": "a.*z"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"destination": {
|
|
|
|
"service": "carrot",
|
|
|
|
"service_subset": "kale",
|
|
|
|
"namespace": "leek",
|
2021-12-06 18:58:33 +00:00
|
|
|
"partition": "chard",
|
2019-08-07 21:41:33 +00:00
|
|
|
"prefix_rewrite": "/alternate",
|
|
|
|
"request_timeout": "99s",
|
|
|
|
"num_retries": 12345,
|
|
|
|
"retry_on_connect_failure": true,
|
|
|
|
"retry_on_status_codes": [
|
|
|
|
401,
|
|
|
|
209
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"match": {
|
|
|
|
"http": {
|
|
|
|
"path_prefix": "/foo",
|
|
|
|
"methods": [
|
|
|
|
"GET",
|
|
|
|
"DELETE"
|
|
|
|
],
|
|
|
|
"query_param": [
|
|
|
|
{
|
|
|
|
"name": "hack1",
|
|
|
|
"present": true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "hack2",
|
|
|
|
"exact": "1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "hack3",
|
|
|
|
"regex": "a.*z"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"match": {
|
|
|
|
"http": {
|
|
|
|
"path_regex": "/foo"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
|
|
|
"Kind": "service-router",
|
|
|
|
"Name": "main",
|
2021-12-06 18:58:33 +00:00
|
|
|
"Partition": "pepper",
|
2020-09-02 19:10:25 +00:00
|
|
|
"Meta" : {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
2019-08-07 21:41:33 +00:00
|
|
|
"Routes": [
|
|
|
|
{
|
|
|
|
"Match": {
|
|
|
|
"HTTP": {
|
|
|
|
"PathExact": "/foo",
|
|
|
|
"Header": [
|
|
|
|
{
|
|
|
|
"Name": "debug1",
|
|
|
|
"Present": true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "debug2",
|
|
|
|
"Present": false,
|
|
|
|
"Invert": true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "debug3",
|
|
|
|
"Exact": "1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "debug4",
|
|
|
|
"Prefix": "aaa"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "debug5",
|
|
|
|
"Suffix": "bbb"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "debug6",
|
|
|
|
"Regex": "a.*z"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"Destination": {
|
|
|
|
"Service": "carrot",
|
|
|
|
"ServiceSubset": "kale",
|
|
|
|
"Namespace": "leek",
|
2021-12-06 18:58:33 +00:00
|
|
|
"Partition": "chard",
|
2019-08-07 21:41:33 +00:00
|
|
|
"PrefixRewrite": "/alternate",
|
|
|
|
"RequestTimeout": "99s",
|
|
|
|
"NumRetries": 12345,
|
|
|
|
"RetryOnConnectFailure": true,
|
|
|
|
"RetryOnStatusCodes": [
|
|
|
|
401,
|
|
|
|
209
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Match": {
|
|
|
|
"HTTP": {
|
|
|
|
"PathPrefix": "/foo",
|
|
|
|
"Methods": [
|
|
|
|
"GET",
|
|
|
|
"DELETE"
|
|
|
|
],
|
|
|
|
"QueryParam": [
|
|
|
|
{
|
|
|
|
"Name": "hack1",
|
|
|
|
"Present": true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "hack2",
|
|
|
|
"Exact": "1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "hack3",
|
|
|
|
"Regex": "a.*z"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Match": {
|
|
|
|
"HTTP": {
|
|
|
|
"PathRegex": "/foo"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`,
|
2019-06-28 16:35:35 +00:00
|
|
|
expect: &api.ServiceRouterConfigEntry{
|
2021-12-06 18:58:33 +00:00
|
|
|
Kind: "service-router",
|
|
|
|
Name: "main",
|
|
|
|
Partition: "pepper",
|
2020-09-02 19:10:25 +00:00
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim",
|
|
|
|
},
|
2019-06-28 16:35:35 +00:00
|
|
|
Routes: []api.ServiceRoute{
|
|
|
|
{
|
|
|
|
Match: &api.ServiceRouteMatch{
|
|
|
|
HTTP: &api.ServiceRouteHTTPMatch{
|
|
|
|
PathExact: "/foo",
|
|
|
|
Header: []api.ServiceRouteHTTPMatchHeader{
|
|
|
|
{
|
|
|
|
Name: "debug1",
|
|
|
|
Present: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "debug2",
|
|
|
|
Present: false,
|
|
|
|
Invert: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "debug3",
|
|
|
|
Exact: "1",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "debug4",
|
|
|
|
Prefix: "aaa",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "debug5",
|
|
|
|
Suffix: "bbb",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "debug6",
|
|
|
|
Regex: "a.*z",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Destination: &api.ServiceRouteDestination{
|
|
|
|
Service: "carrot",
|
|
|
|
ServiceSubset: "kale",
|
|
|
|
Namespace: "leek",
|
2021-12-06 18:58:33 +00:00
|
|
|
Partition: "chard",
|
2019-06-28 16:35:35 +00:00
|
|
|
PrefixRewrite: "/alternate",
|
|
|
|
RequestTimeout: 99 * time.Second,
|
|
|
|
NumRetries: 12345,
|
|
|
|
RetryOnConnectFailure: true,
|
|
|
|
RetryOnStatusCodes: []uint32{401, 209},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Match: &api.ServiceRouteMatch{
|
|
|
|
HTTP: &api.ServiceRouteHTTPMatch{
|
|
|
|
PathPrefix: "/foo",
|
2019-07-24 01:56:39 +00:00
|
|
|
Methods: []string{"GET", "DELETE"},
|
2019-06-28 16:35:35 +00:00
|
|
|
QueryParam: []api.ServiceRouteHTTPMatchQueryParam{
|
|
|
|
{
|
2019-07-24 01:55:26 +00:00
|
|
|
Name: "hack1",
|
|
|
|
Present: true,
|
2019-06-28 16:35:35 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "hack2",
|
2019-07-24 01:55:26 +00:00
|
|
|
Exact: "1",
|
2019-06-28 16:35:35 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "hack3",
|
2019-07-24 01:55:26 +00:00
|
|
|
Regex: "a.*z",
|
2019-06-28 16:35:35 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Match: &api.ServiceRouteMatch{
|
|
|
|
HTTP: &api.ServiceRouteHTTPMatch{
|
|
|
|
PathRegex: "/foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "service-splitter: kitchen sink",
|
|
|
|
snake: `
|
|
|
|
kind = "service-splitter"
|
|
|
|
name = "main"
|
2021-12-06 18:58:33 +00:00
|
|
|
partition = "east"
|
2020-09-02 19:10:25 +00:00
|
|
|
meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
2019-06-28 16:35:35 +00:00
|
|
|
splits = [
|
|
|
|
{
|
2019-08-07 21:41:33 +00:00
|
|
|
weight = 97.1
|
2019-06-28 16:35:35 +00:00
|
|
|
service_subset = "v1"
|
|
|
|
},
|
2019-08-07 21:41:33 +00:00
|
|
|
{
|
|
|
|
weight = 2
|
|
|
|
service_subset = "v2"
|
|
|
|
},
|
2019-06-28 16:35:35 +00:00
|
|
|
{
|
|
|
|
weight = 0.9
|
|
|
|
service = "other"
|
|
|
|
namespace = "alt"
|
2021-12-06 18:58:33 +00:00
|
|
|
partition = "west"
|
2019-06-28 16:35:35 +00:00
|
|
|
},
|
|
|
|
]
|
|
|
|
`,
|
|
|
|
camel: `
|
|
|
|
Kind = "service-splitter"
|
|
|
|
Name = "main"
|
2021-12-06 18:58:33 +00:00
|
|
|
Partition = "east"
|
2020-09-02 19:10:25 +00:00
|
|
|
Meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
2019-06-28 16:35:35 +00:00
|
|
|
Splits = [
|
|
|
|
{
|
2019-08-07 21:41:33 +00:00
|
|
|
Weight = 97.1
|
2019-06-28 16:35:35 +00:00
|
|
|
ServiceSubset = "v1"
|
|
|
|
},
|
2019-08-07 21:41:33 +00:00
|
|
|
{
|
|
|
|
Weight = 2,
|
|
|
|
ServiceSubset = "v2"
|
|
|
|
},
|
2019-06-28 16:35:35 +00:00
|
|
|
{
|
|
|
|
Weight = 0.9
|
|
|
|
Service = "other"
|
|
|
|
Namespace = "alt"
|
2021-12-06 18:58:33 +00:00
|
|
|
Partition = "west"
|
2019-06-28 16:35:35 +00:00
|
|
|
},
|
|
|
|
]
|
|
|
|
`,
|
2019-08-07 21:41:33 +00:00
|
|
|
snakeJSON: `
|
|
|
|
{
|
|
|
|
"kind": "service-splitter",
|
|
|
|
"name": "main",
|
2021-12-06 18:58:33 +00:00
|
|
|
"partition": "east",
|
2020-09-02 19:10:25 +00:00
|
|
|
"meta" : {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
2019-08-07 21:41:33 +00:00
|
|
|
"splits": [
|
|
|
|
{
|
|
|
|
"weight": 97.1,
|
|
|
|
"service_subset": "v1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"weight": 2,
|
|
|
|
"service_subset": "v2"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"weight": 0.9,
|
|
|
|
"service": "other",
|
2021-12-06 18:58:33 +00:00
|
|
|
"namespace": "alt",
|
|
|
|
"partition": "west"
|
2019-08-07 21:41:33 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
|
|
|
"Kind": "service-splitter",
|
|
|
|
"Name": "main",
|
2021-12-06 18:58:33 +00:00
|
|
|
"Partition": "east",
|
2020-09-02 19:10:25 +00:00
|
|
|
"Meta" : {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
2019-08-07 21:41:33 +00:00
|
|
|
"Splits": [
|
|
|
|
{
|
|
|
|
"Weight": 97.1,
|
|
|
|
"ServiceSubset": "v1"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Weight": 2,
|
|
|
|
"ServiceSubset": "v2"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Weight": 0.9,
|
|
|
|
"Service": "other",
|
2021-12-06 18:58:33 +00:00
|
|
|
"Namespace": "alt",
|
|
|
|
"Partition": "west"
|
2019-08-07 21:41:33 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`,
|
2019-06-28 16:35:35 +00:00
|
|
|
expect: &api.ServiceSplitterConfigEntry{
|
2021-12-06 18:58:33 +00:00
|
|
|
Kind: api.ServiceSplitter,
|
|
|
|
Name: "main",
|
|
|
|
Partition: "east",
|
2020-09-02 19:10:25 +00:00
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim",
|
|
|
|
},
|
2019-06-28 16:35:35 +00:00
|
|
|
Splits: []api.ServiceSplit{
|
|
|
|
{
|
2019-08-07 21:41:33 +00:00
|
|
|
Weight: 97.1,
|
2019-06-28 16:35:35 +00:00
|
|
|
ServiceSubset: "v1",
|
|
|
|
},
|
2019-08-07 21:41:33 +00:00
|
|
|
{
|
|
|
|
Weight: 2,
|
|
|
|
ServiceSubset: "v2",
|
|
|
|
},
|
2019-06-28 16:35:35 +00:00
|
|
|
{
|
|
|
|
Weight: 0.9,
|
|
|
|
Service: "other",
|
|
|
|
Namespace: "alt",
|
2021-12-06 18:58:33 +00:00
|
|
|
Partition: "west",
|
2019-06-28 16:35:35 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "service-resolver: subsets with failover",
|
|
|
|
snake: `
|
|
|
|
kind = "service-resolver"
|
|
|
|
name = "main"
|
2020-09-02 19:10:25 +00:00
|
|
|
meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
2019-06-28 16:35:35 +00:00
|
|
|
default_subset = "v1"
|
|
|
|
connect_timeout = "15s"
|
|
|
|
subsets = {
|
|
|
|
"v1" = {
|
|
|
|
filter = "Service.Meta.version == v1"
|
|
|
|
},
|
|
|
|
"v2" = {
|
|
|
|
filter = "Service.Meta.version == v2"
|
|
|
|
only_passing = true
|
|
|
|
},
|
|
|
|
}
|
|
|
|
failover = {
|
|
|
|
"v2" = {
|
|
|
|
service = "failcopy"
|
|
|
|
service_subset = "sure"
|
|
|
|
namespace = "neighbor"
|
|
|
|
datacenters = ["dc5", "dc14"]
|
|
|
|
},
|
|
|
|
"*" = {
|
|
|
|
datacenters = ["dc7"]
|
|
|
|
}
|
|
|
|
}`,
|
|
|
|
camel: `
|
|
|
|
Kind = "service-resolver"
|
|
|
|
Name = "main"
|
2020-09-02 19:10:25 +00:00
|
|
|
Meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
2019-06-28 16:35:35 +00:00
|
|
|
DefaultSubset = "v1"
|
|
|
|
ConnectTimeout = "15s"
|
|
|
|
Subsets = {
|
|
|
|
"v1" = {
|
|
|
|
Filter = "Service.Meta.version == v1"
|
|
|
|
},
|
|
|
|
"v2" = {
|
|
|
|
Filter = "Service.Meta.version == v2"
|
|
|
|
OnlyPassing = true
|
|
|
|
},
|
|
|
|
}
|
|
|
|
Failover = {
|
|
|
|
"v2" = {
|
|
|
|
Service = "failcopy"
|
|
|
|
ServiceSubset = "sure"
|
|
|
|
Namespace = "neighbor"
|
|
|
|
Datacenters = ["dc5", "dc14"]
|
|
|
|
},
|
|
|
|
"*" = {
|
|
|
|
Datacenters = ["dc7"]
|
|
|
|
}
|
|
|
|
}`,
|
2019-08-07 21:41:33 +00:00
|
|
|
snakeJSON: `
|
|
|
|
{
|
|
|
|
"kind": "service-resolver",
|
|
|
|
"name": "main",
|
2020-09-02 19:10:25 +00:00
|
|
|
"meta" : {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
2019-08-07 21:41:33 +00:00
|
|
|
"default_subset": "v1",
|
|
|
|
"connect_timeout": "15s",
|
|
|
|
"subsets": {
|
|
|
|
"v1": {
|
|
|
|
"filter": "Service.Meta.version == v1"
|
|
|
|
},
|
|
|
|
"v2": {
|
|
|
|
"filter": "Service.Meta.version == v2",
|
|
|
|
"only_passing": true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"failover": {
|
|
|
|
"v2": {
|
|
|
|
"service": "failcopy",
|
|
|
|
"service_subset": "sure",
|
|
|
|
"namespace": "neighbor",
|
|
|
|
"datacenters": [
|
|
|
|
"dc5",
|
|
|
|
"dc14"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"*": {
|
|
|
|
"datacenters": [
|
|
|
|
"dc7"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
|
|
|
"Kind": "service-resolver",
|
|
|
|
"Name": "main",
|
2020-09-02 19:10:25 +00:00
|
|
|
"Meta" : {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
2019-08-07 21:41:33 +00:00
|
|
|
"DefaultSubset": "v1",
|
|
|
|
"ConnectTimeout": "15s",
|
|
|
|
"Subsets": {
|
|
|
|
"v1": {
|
|
|
|
"Filter": "Service.Meta.version == v1"
|
|
|
|
},
|
|
|
|
"v2": {
|
|
|
|
"Filter": "Service.Meta.version == v2",
|
|
|
|
"OnlyPassing": true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"Failover": {
|
|
|
|
"v2": {
|
|
|
|
"Service": "failcopy",
|
|
|
|
"ServiceSubset": "sure",
|
|
|
|
"Namespace": "neighbor",
|
|
|
|
"Datacenters": [
|
|
|
|
"dc5",
|
|
|
|
"dc14"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"*": {
|
|
|
|
"Datacenters": [
|
|
|
|
"dc7"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2019-06-28 16:35:35 +00:00
|
|
|
expect: &api.ServiceResolverConfigEntry{
|
2020-09-02 19:10:25 +00:00
|
|
|
Kind: "service-resolver",
|
|
|
|
Name: "main",
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim",
|
|
|
|
},
|
2019-06-28 16:35:35 +00:00
|
|
|
DefaultSubset: "v1",
|
|
|
|
ConnectTimeout: 15 * time.Second,
|
|
|
|
Subsets: map[string]api.ServiceResolverSubset{
|
|
|
|
"v1": {
|
|
|
|
Filter: "Service.Meta.version == v1",
|
|
|
|
},
|
|
|
|
"v2": {
|
|
|
|
Filter: "Service.Meta.version == v2",
|
|
|
|
OnlyPassing: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Failover: map[string]api.ServiceResolverFailover{
|
|
|
|
"v2": {
|
2019-08-02 20:34:54 +00:00
|
|
|
Service: "failcopy",
|
|
|
|
ServiceSubset: "sure",
|
|
|
|
Namespace: "neighbor",
|
|
|
|
Datacenters: []string{"dc5", "dc14"},
|
2019-06-28 16:35:35 +00:00
|
|
|
},
|
|
|
|
"*": {
|
|
|
|
Datacenters: []string{"dc7"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "service-resolver: redirect",
|
|
|
|
snake: `
|
|
|
|
kind = "service-resolver"
|
|
|
|
name = "main"
|
2021-12-06 18:58:33 +00:00
|
|
|
partition = "east"
|
2019-06-28 16:35:35 +00:00
|
|
|
redirect {
|
|
|
|
service = "other"
|
|
|
|
service_subset = "backup"
|
|
|
|
namespace = "alt"
|
2021-12-06 18:58:33 +00:00
|
|
|
partition = "west"
|
2019-06-28 16:35:35 +00:00
|
|
|
datacenter = "dc9"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camel: `
|
|
|
|
Kind = "service-resolver"
|
|
|
|
Name = "main"
|
2021-12-06 18:58:33 +00:00
|
|
|
Partition = "east"
|
2019-06-28 16:35:35 +00:00
|
|
|
Redirect {
|
|
|
|
Service = "other"
|
|
|
|
ServiceSubset = "backup"
|
|
|
|
Namespace = "alt"
|
2021-12-06 18:58:33 +00:00
|
|
|
Partition = "west"
|
2019-06-28 16:35:35 +00:00
|
|
|
Datacenter = "dc9"
|
|
|
|
}
|
|
|
|
`,
|
2019-08-07 21:41:33 +00:00
|
|
|
snakeJSON: `
|
|
|
|
{
|
|
|
|
"kind": "service-resolver",
|
|
|
|
"name": "main",
|
2021-12-06 18:58:33 +00:00
|
|
|
"partition": "east",
|
2019-08-07 21:41:33 +00:00
|
|
|
"redirect": {
|
|
|
|
"service": "other",
|
|
|
|
"service_subset": "backup",
|
|
|
|
"namespace": "alt",
|
2021-12-06 18:58:33 +00:00
|
|
|
"partition": "west",
|
2019-08-07 21:41:33 +00:00
|
|
|
"datacenter": "dc9"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
|
|
|
"Kind": "service-resolver",
|
|
|
|
"Name": "main",
|
2021-12-06 18:58:33 +00:00
|
|
|
"Partition": "east",
|
2019-08-07 21:41:33 +00:00
|
|
|
"Redirect": {
|
|
|
|
"Service": "other",
|
|
|
|
"ServiceSubset": "backup",
|
|
|
|
"Namespace": "alt",
|
2021-12-06 18:58:33 +00:00
|
|
|
"Partition": "west",
|
2019-08-07 21:41:33 +00:00
|
|
|
"Datacenter": "dc9"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2019-06-28 16:35:35 +00:00
|
|
|
expect: &api.ServiceResolverConfigEntry{
|
2021-12-06 18:58:33 +00:00
|
|
|
Kind: "service-resolver",
|
|
|
|
Name: "main",
|
|
|
|
Partition: "east",
|
2019-06-28 16:35:35 +00:00
|
|
|
Redirect: &api.ServiceResolverRedirect{
|
|
|
|
Service: "other",
|
|
|
|
ServiceSubset: "backup",
|
|
|
|
Namespace: "alt",
|
2021-12-06 18:58:33 +00:00
|
|
|
Partition: "west",
|
2019-06-28 16:35:35 +00:00
|
|
|
Datacenter: "dc9",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "service-resolver: default",
|
|
|
|
snake: `
|
|
|
|
kind = "service-resolver"
|
|
|
|
name = "main"
|
|
|
|
`,
|
|
|
|
camel: `
|
|
|
|
Kind = "service-resolver"
|
|
|
|
Name = "main"
|
|
|
|
`,
|
2019-08-07 21:41:33 +00:00
|
|
|
snakeJSON: `
|
|
|
|
{
|
|
|
|
"kind": "service-resolver",
|
|
|
|
"name": "main"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
|
|
|
"Kind": "service-resolver",
|
|
|
|
"Name": "main"
|
|
|
|
}
|
|
|
|
`,
|
2019-06-28 16:35:35 +00:00
|
|
|
expect: &api.ServiceResolverConfigEntry{
|
|
|
|
Kind: "service-resolver",
|
|
|
|
Name: "main",
|
|
|
|
},
|
|
|
|
},
|
2020-09-02 15:10:50 +00:00
|
|
|
{
|
|
|
|
name: "service-resolver: envoy hash lb kitchen sink",
|
|
|
|
snake: `
|
|
|
|
kind = "service-resolver"
|
|
|
|
name = "main"
|
|
|
|
load_balancer = {
|
2020-09-11 15:21:43 +00:00
|
|
|
policy = "ring_hash"
|
|
|
|
ring_hash_config = {
|
|
|
|
minimum_ring_size = 1
|
|
|
|
maximum_ring_size = 2
|
2020-09-02 15:10:50 +00:00
|
|
|
}
|
2020-09-11 15:21:43 +00:00
|
|
|
hash_policies = [
|
|
|
|
{
|
|
|
|
field = "cookie"
|
|
|
|
field_value = "good-cookie"
|
|
|
|
cookie_config = {
|
|
|
|
ttl = "1s"
|
|
|
|
path = "/oven"
|
|
|
|
}
|
|
|
|
terminal = true
|
|
|
|
},
|
2020-09-12 00:34:03 +00:00
|
|
|
{
|
|
|
|
field = "cookie"
|
|
|
|
field_value = "less-good-cookie"
|
|
|
|
cookie_config = {
|
|
|
|
session = true
|
|
|
|
path = "/toaster"
|
|
|
|
}
|
|
|
|
terminal = true
|
|
|
|
},
|
2020-09-11 15:21:43 +00:00
|
|
|
{
|
|
|
|
field = "header"
|
|
|
|
field_value = "x-user-id"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
source_ip = true
|
|
|
|
}
|
|
|
|
]
|
2020-09-02 15:10:50 +00:00
|
|
|
}
|
|
|
|
`,
|
|
|
|
camel: `
|
|
|
|
Kind = "service-resolver"
|
|
|
|
Name = "main"
|
|
|
|
LoadBalancer = {
|
2020-09-11 15:21:43 +00:00
|
|
|
Policy = "ring_hash"
|
|
|
|
RingHashConfig = {
|
|
|
|
MinimumRingSize = 1
|
|
|
|
MaximumRingSize = 2
|
2020-09-02 15:10:50 +00:00
|
|
|
}
|
2020-09-11 15:21:43 +00:00
|
|
|
HashPolicies = [
|
|
|
|
{
|
|
|
|
Field = "cookie"
|
|
|
|
FieldValue = "good-cookie"
|
|
|
|
CookieConfig = {
|
|
|
|
TTL = "1s"
|
|
|
|
Path = "/oven"
|
|
|
|
}
|
|
|
|
Terminal = true
|
|
|
|
},
|
2020-09-12 00:34:03 +00:00
|
|
|
{
|
|
|
|
Field = "cookie"
|
|
|
|
FieldValue = "less-good-cookie"
|
|
|
|
CookieConfig = {
|
|
|
|
Session = true
|
|
|
|
Path = "/toaster"
|
|
|
|
}
|
|
|
|
Terminal = true
|
|
|
|
},
|
2020-09-11 15:21:43 +00:00
|
|
|
{
|
|
|
|
Field = "header"
|
|
|
|
FieldValue = "x-user-id"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
SourceIP = true
|
|
|
|
}
|
|
|
|
]
|
2020-09-02 15:10:50 +00:00
|
|
|
}
|
|
|
|
`,
|
|
|
|
snakeJSON: `
|
|
|
|
{
|
|
|
|
"kind": "service-resolver",
|
|
|
|
"name": "main",
|
|
|
|
"load_balancer": {
|
2020-09-11 15:21:43 +00:00
|
|
|
"policy": "ring_hash",
|
|
|
|
"ring_hash_config": {
|
|
|
|
"minimum_ring_size": 1,
|
|
|
|
"maximum_ring_size": 2
|
|
|
|
},
|
|
|
|
"hash_policies": [
|
|
|
|
{
|
|
|
|
"field": "cookie",
|
|
|
|
"field_value": "good-cookie",
|
|
|
|
"cookie_config": {
|
|
|
|
"ttl": "1s",
|
|
|
|
"path": "/oven"
|
2020-09-02 15:10:50 +00:00
|
|
|
},
|
2020-09-11 15:21:43 +00:00
|
|
|
"terminal": true
|
|
|
|
},
|
2020-09-12 00:34:03 +00:00
|
|
|
{
|
|
|
|
"field": "cookie",
|
|
|
|
"field_value": "less-good-cookie",
|
|
|
|
"cookie_config": {
|
|
|
|
"session": true,
|
|
|
|
"path": "/toaster"
|
|
|
|
},
|
|
|
|
"terminal": true
|
|
|
|
},
|
2020-09-11 15:21:43 +00:00
|
|
|
{
|
|
|
|
"field": "header",
|
|
|
|
"field_value": "x-user-id"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"source_ip": true
|
|
|
|
}
|
|
|
|
]
|
2020-09-02 15:10:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
|
|
|
"Kind": "service-resolver",
|
|
|
|
"Name": "main",
|
|
|
|
"LoadBalancer": {
|
2020-09-11 15:21:43 +00:00
|
|
|
"Policy": "ring_hash",
|
|
|
|
"RingHashConfig": {
|
|
|
|
"MinimumRingSize": 1,
|
|
|
|
"MaximumRingSize": 2
|
|
|
|
},
|
|
|
|
"HashPolicies": [
|
|
|
|
{
|
|
|
|
"Field": "cookie",
|
|
|
|
"FieldValue": "good-cookie",
|
|
|
|
"CookieConfig": {
|
|
|
|
"TTL": "1s",
|
|
|
|
"Path": "/oven"
|
2020-09-02 15:10:50 +00:00
|
|
|
},
|
2020-09-11 15:21:43 +00:00
|
|
|
"Terminal": true
|
|
|
|
},
|
2020-09-12 00:34:03 +00:00
|
|
|
{
|
|
|
|
"Field": "cookie",
|
|
|
|
"FieldValue": "less-good-cookie",
|
|
|
|
"CookieConfig": {
|
|
|
|
"Session": true,
|
|
|
|
"Path": "/toaster"
|
|
|
|
},
|
|
|
|
"Terminal": true
|
|
|
|
},
|
2020-09-11 15:21:43 +00:00
|
|
|
{
|
|
|
|
"Field": "header",
|
|
|
|
"FieldValue": "x-user-id"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"SourceIP": true
|
|
|
|
}
|
|
|
|
]
|
2020-09-02 15:10:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
expect: &api.ServiceResolverConfigEntry{
|
|
|
|
Kind: "service-resolver",
|
|
|
|
Name: "main",
|
|
|
|
LoadBalancer: &api.LoadBalancer{
|
2020-09-11 15:21:43 +00:00
|
|
|
Policy: structs.LBPolicyRingHash,
|
|
|
|
RingHashConfig: &api.RingHashConfig{
|
|
|
|
MinimumRingSize: 1,
|
|
|
|
MaximumRingSize: 2,
|
|
|
|
},
|
|
|
|
HashPolicies: []api.HashPolicy{
|
|
|
|
{
|
|
|
|
Field: structs.HashPolicyCookie,
|
|
|
|
FieldValue: "good-cookie",
|
|
|
|
CookieConfig: &api.CookieConfig{
|
|
|
|
TTL: 1 * time.Second,
|
|
|
|
Path: "/oven",
|
2020-09-02 15:10:50 +00:00
|
|
|
},
|
2020-09-11 15:21:43 +00:00
|
|
|
Terminal: true,
|
|
|
|
},
|
2020-09-12 00:34:03 +00:00
|
|
|
{
|
|
|
|
Field: structs.HashPolicyCookie,
|
|
|
|
FieldValue: "less-good-cookie",
|
|
|
|
CookieConfig: &api.CookieConfig{
|
|
|
|
Session: true,
|
|
|
|
Path: "/toaster",
|
|
|
|
},
|
|
|
|
Terminal: true,
|
|
|
|
},
|
2020-09-11 15:21:43 +00:00
|
|
|
{
|
|
|
|
Field: structs.HashPolicyHeader,
|
|
|
|
FieldValue: "x-user-id",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
SourceIP: true,
|
2020-09-02 15:10:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "service-resolver: envoy least request kitchen sink",
|
|
|
|
snake: `
|
|
|
|
kind = "service-resolver"
|
|
|
|
name = "main"
|
|
|
|
load_balancer = {
|
2020-09-11 15:21:43 +00:00
|
|
|
policy = "least_request"
|
|
|
|
least_request_config = {
|
|
|
|
choice_count = 2
|
2020-09-02 15:10:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camel: `
|
|
|
|
Kind = "service-resolver"
|
|
|
|
Name = "main"
|
|
|
|
LoadBalancer = {
|
2020-09-11 15:21:43 +00:00
|
|
|
Policy = "least_request"
|
|
|
|
LeastRequestConfig = {
|
|
|
|
ChoiceCount = 2
|
2020-09-02 15:10:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
snakeJSON: `
|
|
|
|
{
|
|
|
|
"kind": "service-resolver",
|
|
|
|
"name": "main",
|
|
|
|
"load_balancer": {
|
2020-09-11 15:21:43 +00:00
|
|
|
"policy": "least_request",
|
|
|
|
"least_request_config": {
|
|
|
|
"choice_count": 2
|
2020-09-02 15:10:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
|
|
|
"Kind": "service-resolver",
|
|
|
|
"Name": "main",
|
|
|
|
"LoadBalancer": {
|
2020-09-11 15:21:43 +00:00
|
|
|
"Policy": "least_request",
|
|
|
|
"LeastRequestConfig": {
|
|
|
|
"ChoiceCount": 2
|
2020-09-02 15:10:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
expect: &api.ServiceResolverConfigEntry{
|
|
|
|
Kind: "service-resolver",
|
|
|
|
Name: "main",
|
|
|
|
LoadBalancer: &api.LoadBalancer{
|
2020-09-11 15:21:43 +00:00
|
|
|
Policy: structs.LBPolicyLeastRequest,
|
|
|
|
LeastRequestConfig: &api.LeastRequestConfig{
|
|
|
|
ChoiceCount: 2,
|
2020-09-02 15:10:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-26 02:55:52 +00:00
|
|
|
{
|
|
|
|
name: "expose paths: kitchen sink proxy defaults",
|
|
|
|
snake: `
|
|
|
|
kind = "proxy-defaults"
|
|
|
|
name = "global"
|
|
|
|
expose = {
|
|
|
|
checks = true
|
|
|
|
paths = [
|
|
|
|
{
|
|
|
|
local_path_port = 8080
|
|
|
|
listener_port = 21500
|
|
|
|
path = "/healthz"
|
|
|
|
protocol = "http2"
|
2020-04-08 01:37:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
local_path_port = 8000
|
|
|
|
listener_port = 21501
|
|
|
|
path = "/metrics"
|
|
|
|
protocol = "http"
|
2019-09-26 02:55:52 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}`,
|
|
|
|
camel: `
|
|
|
|
Kind = "proxy-defaults"
|
|
|
|
Name = "global"
|
|
|
|
Expose = {
|
|
|
|
Checks = true
|
|
|
|
Paths = [
|
|
|
|
{
|
|
|
|
LocalPathPort = 8080
|
|
|
|
ListenerPort = 21500
|
|
|
|
Path = "/healthz"
|
|
|
|
Protocol = "http2"
|
2020-04-08 01:37:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
LocalPathPort = 8000
|
|
|
|
ListenerPort = 21501
|
|
|
|
Path = "/metrics"
|
|
|
|
Protocol = "http"
|
2019-09-26 02:55:52 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}`,
|
|
|
|
snakeJSON: `
|
|
|
|
{
|
|
|
|
"kind": "proxy-defaults",
|
|
|
|
"name": "global",
|
|
|
|
"expose": {
|
|
|
|
"checks": true,
|
|
|
|
"paths": [
|
|
|
|
{
|
|
|
|
"local_path_port": 8080,
|
|
|
|
"listener_port": 21500,
|
|
|
|
"path": "/healthz",
|
|
|
|
"protocol": "http2"
|
2020-04-08 01:37:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"local_path_port": 8000,
|
|
|
|
"listener_port": 21501,
|
|
|
|
"path": "/metrics",
|
|
|
|
"protocol": "http"
|
2019-09-26 02:55:52 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
|
|
|
"Kind": "proxy-defaults",
|
|
|
|
"Name": "global",
|
|
|
|
"Expose": {
|
|
|
|
"Checks": true,
|
|
|
|
"Paths": [
|
|
|
|
{
|
|
|
|
"LocalPathPort": 8080,
|
|
|
|
"ListenerPort": 21500,
|
|
|
|
"Path": "/healthz",
|
|
|
|
"Protocol": "http2"
|
2020-04-08 01:37:47 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"LocalPathPort": 8000,
|
|
|
|
"ListenerPort": 21501,
|
|
|
|
"Path": "/metrics",
|
|
|
|
"Protocol": "http"
|
2019-09-26 02:55:52 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
expect: &api.ProxyConfigEntry{
|
|
|
|
Kind: "proxy-defaults",
|
|
|
|
Name: "global",
|
|
|
|
Expose: api.ExposeConfig{
|
|
|
|
Checks: true,
|
|
|
|
Paths: []api.ExposePath{
|
|
|
|
{
|
|
|
|
ListenerPort: 21500,
|
|
|
|
Path: "/healthz",
|
|
|
|
LocalPathPort: 8080,
|
|
|
|
Protocol: "http2",
|
|
|
|
},
|
2020-04-08 01:37:47 +00:00
|
|
|
{
|
|
|
|
ListenerPort: 21501,
|
|
|
|
Path: "/metrics",
|
|
|
|
LocalPathPort: 8000,
|
|
|
|
Protocol: "http",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "expose paths: kitchen sink service defaults",
|
|
|
|
snake: `
|
|
|
|
kind = "service-defaults"
|
|
|
|
name = "web"
|
|
|
|
expose = {
|
|
|
|
checks = true
|
|
|
|
paths = [
|
|
|
|
{
|
|
|
|
local_path_port = 8080
|
|
|
|
listener_port = 21500
|
|
|
|
path = "/healthz"
|
|
|
|
protocol = "http2"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
local_path_port = 8000
|
|
|
|
listener_port = 21501
|
|
|
|
path = "/metrics"
|
|
|
|
protocol = "http"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}`,
|
|
|
|
camel: `
|
|
|
|
Kind = "service-defaults"
|
|
|
|
Name = "web"
|
|
|
|
Expose = {
|
|
|
|
Checks = true
|
|
|
|
Paths = [
|
|
|
|
{
|
|
|
|
LocalPathPort = 8080
|
|
|
|
ListenerPort = 21500
|
|
|
|
Path = "/healthz"
|
|
|
|
Protocol = "http2"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
LocalPathPort = 8000
|
|
|
|
ListenerPort = 21501
|
|
|
|
Path = "/metrics"
|
|
|
|
Protocol = "http"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}`,
|
|
|
|
snakeJSON: `
|
|
|
|
{
|
|
|
|
"kind": "service-defaults",
|
|
|
|
"name": "web",
|
|
|
|
"expose": {
|
|
|
|
"checks": true,
|
|
|
|
"paths": [
|
|
|
|
{
|
|
|
|
"local_path_port": 8080,
|
|
|
|
"listener_port": 21500,
|
|
|
|
"path": "/healthz",
|
|
|
|
"protocol": "http2"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"local_path_port": 8000,
|
|
|
|
"listener_port": 21501,
|
|
|
|
"path": "/metrics",
|
|
|
|
"protocol": "http"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
|
|
|
"Kind": "service-defaults",
|
|
|
|
"Name": "web",
|
|
|
|
"Expose": {
|
|
|
|
"Checks": true,
|
|
|
|
"Paths": [
|
|
|
|
{
|
|
|
|
"LocalPathPort": 8080,
|
|
|
|
"ListenerPort": 21500,
|
|
|
|
"Path": "/healthz",
|
|
|
|
"Protocol": "http2"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"LocalPathPort": 8000,
|
|
|
|
"ListenerPort": 21501,
|
|
|
|
"Path": "/metrics",
|
|
|
|
"Protocol": "http"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
expect: &api.ServiceConfigEntry{
|
|
|
|
Kind: "service-defaults",
|
|
|
|
Name: "web",
|
|
|
|
Expose: api.ExposeConfig{
|
|
|
|
Checks: true,
|
|
|
|
Paths: []api.ExposePath{
|
|
|
|
{
|
|
|
|
ListenerPort: 21500,
|
|
|
|
Path: "/healthz",
|
|
|
|
LocalPathPort: 8080,
|
|
|
|
Protocol: "http2",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ListenerPort: 21501,
|
|
|
|
Path: "/metrics",
|
|
|
|
LocalPathPort: 8000,
|
|
|
|
Protocol: "http",
|
|
|
|
},
|
2019-09-26 02:55:52 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-03-31 16:59:10 +00:00
|
|
|
{
|
2022-01-11 16:46:42 +00:00
|
|
|
// TODO(rb): test SDS stuff here in both places (global/service)
|
2020-03-31 16:59:10 +00:00
|
|
|
name: "ingress-gateway: kitchen sink",
|
|
|
|
snake: `
|
|
|
|
kind = "ingress-gateway"
|
|
|
|
name = "ingress-web"
|
2020-09-02 19:10:25 +00:00
|
|
|
meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
2020-04-30 20:50:25 +00:00
|
|
|
tls {
|
|
|
|
enabled = true
|
2022-01-11 16:46:42 +00:00
|
|
|
tls_min_version = "TLSv1_1"
|
|
|
|
tls_max_version = "TLSv1_2"
|
|
|
|
cipher_suites = [
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
|
|
|
|
]
|
2020-04-30 20:50:25 +00:00
|
|
|
}
|
2020-03-31 16:59:10 +00:00
|
|
|
listeners = [
|
|
|
|
{
|
|
|
|
port = 8080
|
|
|
|
protocol = "http"
|
|
|
|
services = [
|
|
|
|
{
|
|
|
|
name = "web"
|
2020-04-23 15:06:19 +00:00
|
|
|
hosts = ["test.example.com"]
|
2020-03-31 16:59:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "db"
|
|
|
|
namespace = "foo"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
`,
|
|
|
|
camel: `
|
|
|
|
Kind = "ingress-gateway"
|
|
|
|
Name = "ingress-web"
|
2020-09-02 19:10:25 +00:00
|
|
|
Meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
2020-04-30 20:50:25 +00:00
|
|
|
Tls {
|
|
|
|
Enabled = true
|
2022-01-11 16:46:42 +00:00
|
|
|
TLSMinVersion = "TLSv1_1"
|
|
|
|
TLSMaxVersion = "TLSv1_2"
|
|
|
|
CipherSuites = [
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
|
|
|
|
]
|
2020-04-30 20:50:25 +00:00
|
|
|
}
|
2020-03-31 16:59:10 +00:00
|
|
|
Listeners = [
|
|
|
|
{
|
|
|
|
Port = 8080
|
|
|
|
Protocol = "http"
|
|
|
|
Services = [
|
|
|
|
{
|
|
|
|
Name = "web"
|
2020-04-23 15:06:19 +00:00
|
|
|
Hosts = ["test.example.com"]
|
2020-03-31 16:59:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "db"
|
|
|
|
Namespace = "foo"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
`,
|
|
|
|
snakeJSON: `
|
|
|
|
{
|
|
|
|
"kind": "ingress-gateway",
|
|
|
|
"name": "ingress-web",
|
2020-09-02 19:10:25 +00:00
|
|
|
"meta" : {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
2020-04-30 20:50:25 +00:00
|
|
|
"tls": {
|
2022-01-11 16:46:42 +00:00
|
|
|
"enabled": true,
|
|
|
|
"tls_min_version": "TLSv1_1",
|
|
|
|
"tls_max_version": "TLSv1_2",
|
|
|
|
"cipher_suites": [
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
|
|
|
|
]
|
2020-04-30 20:50:25 +00:00
|
|
|
},
|
2020-03-31 16:59:10 +00:00
|
|
|
"listeners": [
|
|
|
|
{
|
|
|
|
"port": 8080,
|
|
|
|
"protocol": "http",
|
|
|
|
"services": [
|
|
|
|
{
|
2020-04-23 15:06:19 +00:00
|
|
|
"name": "web",
|
|
|
|
"hosts": ["test.example.com"]
|
2020-03-31 16:59:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "db",
|
|
|
|
"namespace": "foo"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
|
|
|
"Kind": "ingress-gateway",
|
|
|
|
"Name": "ingress-web",
|
2020-09-02 19:10:25 +00:00
|
|
|
"Meta" : {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
2022-01-11 16:46:42 +00:00
|
|
|
"TLS": {
|
|
|
|
"Enabled": true,
|
|
|
|
"TLSMinVersion": "TLSv1_1",
|
|
|
|
"TLSMaxVersion": "TLSv1_2",
|
|
|
|
"CipherSuites": [
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
|
|
|
|
]
|
2020-04-30 20:50:25 +00:00
|
|
|
},
|
2020-03-31 16:59:10 +00:00
|
|
|
"Listeners": [
|
|
|
|
{
|
|
|
|
"Port": 8080,
|
|
|
|
"Protocol": "http",
|
|
|
|
"Services": [
|
|
|
|
{
|
2020-04-23 15:06:19 +00:00
|
|
|
"Name": "web",
|
|
|
|
"Hosts": ["test.example.com"]
|
2020-03-31 16:59:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "db",
|
|
|
|
"Namespace": "foo"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
expect: &api.IngressGatewayConfigEntry{
|
|
|
|
Kind: "ingress-gateway",
|
|
|
|
Name: "ingress-web",
|
2020-09-02 19:10:25 +00:00
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim",
|
|
|
|
},
|
2020-04-30 20:50:25 +00:00
|
|
|
TLS: api.GatewayTLSConfig{
|
2022-01-11 16:46:42 +00:00
|
|
|
Enabled: true,
|
|
|
|
TLSMinVersion: "TLSv1_1",
|
|
|
|
TLSMaxVersion: "TLSv1_2",
|
|
|
|
CipherSuites: []string{
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
},
|
2020-04-30 20:50:25 +00:00
|
|
|
},
|
2020-03-31 16:59:10 +00:00
|
|
|
Listeners: []api.IngressListener{
|
|
|
|
{
|
|
|
|
Port: 8080,
|
|
|
|
Protocol: "http",
|
|
|
|
Services: []api.IngressService{
|
|
|
|
{
|
2020-04-23 15:06:19 +00:00
|
|
|
Name: "web",
|
|
|
|
Hosts: []string{"test.example.com"},
|
2020-03-31 16:59:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "db",
|
|
|
|
Namespace: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-10-06 18:24:05 +00:00
|
|
|
{
|
|
|
|
name: "service-intentions: kitchen sink",
|
|
|
|
snake: `
|
|
|
|
kind = "service-intentions"
|
|
|
|
name = "web"
|
|
|
|
meta {
|
2020-10-06 22:09:13 +00:00
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
2020-10-06 18:24:05 +00:00
|
|
|
}
|
|
|
|
sources = [
|
|
|
|
{
|
|
|
|
name = "foo"
|
|
|
|
action = "deny"
|
|
|
|
type = "consul"
|
|
|
|
description = "foo desc"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "bar"
|
|
|
|
action = "allow"
|
|
|
|
description = "bar desc"
|
2020-10-06 22:09:13 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "l7"
|
|
|
|
permissions = [
|
|
|
|
{
|
|
|
|
action = "deny"
|
|
|
|
http {
|
|
|
|
path_exact = "/admin"
|
|
|
|
header = [
|
|
|
|
{
|
|
|
|
name = "hdr-present"
|
|
|
|
present = true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "hdr-exact"
|
|
|
|
exact = "exact"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "hdr-prefix"
|
|
|
|
prefix = "prefix"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "hdr-suffix"
|
|
|
|
suffix = "suffix"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "hdr-regex"
|
|
|
|
regex = "regex"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "hdr-absent"
|
|
|
|
present = true
|
|
|
|
invert = true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
action = "allow"
|
|
|
|
http {
|
|
|
|
path_prefix = "/v3/"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
action = "allow"
|
|
|
|
http {
|
|
|
|
path_regex = "/v[12]/.*"
|
|
|
|
methods = ["GET", "POST"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2020-10-06 18:24:05 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
sources {
|
|
|
|
name = "*"
|
|
|
|
action = "deny"
|
|
|
|
description = "wild desc"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camel: `
|
|
|
|
Kind = "service-intentions"
|
|
|
|
Name = "web"
|
|
|
|
Meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
|
|
|
Sources = [
|
|
|
|
{
|
|
|
|
Name = "foo"
|
|
|
|
Action = "deny"
|
|
|
|
Type = "consul"
|
|
|
|
Description = "foo desc"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "bar"
|
|
|
|
Action = "allow"
|
|
|
|
Description = "bar desc"
|
2020-10-06 22:09:13 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "l7"
|
|
|
|
Permissions = [
|
|
|
|
{
|
|
|
|
Action = "deny"
|
|
|
|
HTTP {
|
|
|
|
PathExact = "/admin"
|
|
|
|
Header = [
|
|
|
|
{
|
|
|
|
Name = "hdr-present"
|
|
|
|
Present = true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "hdr-exact"
|
|
|
|
Exact = "exact"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "hdr-prefix"
|
|
|
|
Prefix = "prefix"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "hdr-suffix"
|
|
|
|
Suffix = "suffix"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "hdr-regex"
|
|
|
|
Regex = "regex"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "hdr-absent"
|
|
|
|
Present = true
|
|
|
|
Invert = true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Action = "allow"
|
|
|
|
HTTP {
|
|
|
|
PathPrefix = "/v3/"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Action = "allow"
|
|
|
|
HTTP {
|
|
|
|
PathRegex = "/v[12]/.*"
|
|
|
|
Methods = ["GET", "POST"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2020-10-06 18:24:05 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
Sources {
|
|
|
|
Name = "*"
|
|
|
|
Action = "deny"
|
|
|
|
Description = "wild desc"
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
snakeJSON: `
|
|
|
|
{
|
|
|
|
"kind": "service-intentions",
|
|
|
|
"name": "web",
|
2020-10-06 22:09:13 +00:00
|
|
|
"meta": {
|
2020-10-06 18:24:05 +00:00
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
|
|
|
"sources": [
|
|
|
|
{
|
|
|
|
"name": "foo",
|
|
|
|
"action": "deny",
|
|
|
|
"type": "consul",
|
|
|
|
"description": "foo desc"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "bar",
|
|
|
|
"action": "allow",
|
|
|
|
"description": "bar desc"
|
|
|
|
},
|
2020-10-06 22:09:13 +00:00
|
|
|
{
|
|
|
|
"name": "l7",
|
|
|
|
"permissions": [
|
|
|
|
{
|
|
|
|
"action": "deny",
|
|
|
|
"http": {
|
|
|
|
"path_exact": "/admin",
|
|
|
|
"header": [
|
|
|
|
{
|
|
|
|
"name": "hdr-present",
|
|
|
|
"present": true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "hdr-exact",
|
|
|
|
"exact": "exact"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "hdr-prefix",
|
|
|
|
"prefix": "prefix"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "hdr-suffix",
|
|
|
|
"suffix": "suffix"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "hdr-regex",
|
|
|
|
"regex": "regex"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "hdr-absent",
|
|
|
|
"present": true,
|
|
|
|
"invert": true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"action": "allow",
|
|
|
|
"http": {
|
|
|
|
"path_prefix": "/v3/"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"action": "allow",
|
|
|
|
"http": {
|
|
|
|
"path_regex": "/v[12]/.*",
|
|
|
|
"methods": [
|
|
|
|
"GET",
|
|
|
|
"POST"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2020-10-06 18:24:05 +00:00
|
|
|
{
|
|
|
|
"name": "*",
|
|
|
|
"action": "deny",
|
|
|
|
"description": "wild desc"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
|
|
|
"Kind": "service-intentions",
|
|
|
|
"Name": "web",
|
|
|
|
"Meta" : {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
|
|
|
"Sources": [
|
|
|
|
{
|
|
|
|
"Name": "foo",
|
|
|
|
"Action": "deny",
|
|
|
|
"Type": "consul",
|
|
|
|
"Description": "foo desc"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "bar",
|
|
|
|
"Action": "allow",
|
|
|
|
"Description": "bar desc"
|
|
|
|
},
|
2020-10-06 22:09:13 +00:00
|
|
|
{
|
|
|
|
"Name": "l7",
|
|
|
|
"Permissions": [
|
|
|
|
{
|
|
|
|
"Action": "deny",
|
|
|
|
"HTTP": {
|
|
|
|
"PathExact": "/admin",
|
|
|
|
"Header": [
|
|
|
|
{
|
|
|
|
"Name": "hdr-present",
|
|
|
|
"Present": true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "hdr-exact",
|
|
|
|
"Exact": "exact"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "hdr-prefix",
|
|
|
|
"Prefix": "prefix"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "hdr-suffix",
|
|
|
|
"Suffix": "suffix"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "hdr-regex",
|
|
|
|
"Regex": "regex"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "hdr-absent",
|
|
|
|
"Present": true,
|
|
|
|
"Invert": true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Action": "allow",
|
|
|
|
"HTTP": {
|
|
|
|
"PathPrefix": "/v3/"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Action": "allow",
|
|
|
|
"HTTP": {
|
|
|
|
"PathRegex": "/v[12]/.*",
|
|
|
|
"Methods": [
|
|
|
|
"GET",
|
|
|
|
"POST"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2020-10-06 18:24:05 +00:00
|
|
|
{
|
|
|
|
"Name": "*",
|
|
|
|
"Action": "deny",
|
|
|
|
"Description": "wild desc"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
expect: &api.ServiceIntentionsConfigEntry{
|
|
|
|
Kind: "service-intentions",
|
|
|
|
Name: "web",
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim",
|
|
|
|
},
|
|
|
|
Sources: []*api.SourceIntention{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Action: "deny",
|
|
|
|
Type: "consul",
|
|
|
|
Description: "foo desc",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bar",
|
|
|
|
Action: "allow",
|
|
|
|
Description: "bar desc",
|
|
|
|
},
|
2020-10-06 22:09:13 +00:00
|
|
|
{
|
|
|
|
Name: "l7",
|
|
|
|
Permissions: []*api.IntentionPermission{
|
|
|
|
{
|
|
|
|
Action: "deny",
|
|
|
|
HTTP: &api.IntentionHTTPPermission{
|
|
|
|
PathExact: "/admin",
|
|
|
|
Header: []api.IntentionHTTPHeaderPermission{
|
|
|
|
{
|
|
|
|
Name: "hdr-present",
|
|
|
|
Present: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "hdr-exact",
|
|
|
|
Exact: "exact",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "hdr-prefix",
|
|
|
|
Prefix: "prefix",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "hdr-suffix",
|
|
|
|
Suffix: "suffix",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "hdr-regex",
|
|
|
|
Regex: "regex",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "hdr-absent",
|
|
|
|
Present: true,
|
|
|
|
Invert: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Action: "allow",
|
|
|
|
HTTP: &api.IntentionHTTPPermission{
|
|
|
|
PathPrefix: "/v3/",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Action: "allow",
|
|
|
|
HTTP: &api.IntentionHTTPPermission{
|
|
|
|
PathRegex: "/v[12]/.*",
|
|
|
|
Methods: []string{"GET", "POST"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-10-06 18:24:05 +00:00
|
|
|
{
|
|
|
|
Name: "*",
|
|
|
|
Action: "deny",
|
|
|
|
Description: "wild desc",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "service-intentions: wildcard destination",
|
|
|
|
snake: `
|
|
|
|
kind = "service-intentions"
|
|
|
|
name = "*"
|
|
|
|
sources {
|
|
|
|
name = "foo"
|
|
|
|
action = "deny"
|
|
|
|
# should be parsed, but we'll ignore it later
|
|
|
|
precedence = 6
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camel: `
|
|
|
|
Kind = "service-intentions"
|
|
|
|
Name = "*"
|
|
|
|
Sources {
|
|
|
|
Name = "foo"
|
|
|
|
Action = "deny"
|
|
|
|
# should be parsed, but we'll ignore it later
|
|
|
|
Precedence = 6
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
snakeJSON: `
|
|
|
|
{
|
|
|
|
"kind": "service-intentions",
|
|
|
|
"name": "*",
|
|
|
|
"sources": [
|
|
|
|
{
|
|
|
|
"name": "foo",
|
|
|
|
"action": "deny",
|
|
|
|
"precedence": 6
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
|
|
|
"Kind": "service-intentions",
|
|
|
|
"Name": "*",
|
|
|
|
"Sources": [
|
|
|
|
{
|
|
|
|
"Name": "foo",
|
|
|
|
"Action": "deny",
|
|
|
|
"Precedence": 6
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
expect: &api.ServiceIntentionsConfigEntry{
|
|
|
|
Kind: "service-intentions",
|
|
|
|
Name: "*",
|
|
|
|
Sources: []*api.SourceIntention{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Action: "deny",
|
|
|
|
Precedence: 6,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-04-06 18:19:59 +00:00
|
|
|
{
|
2021-04-28 22:13:29 +00:00
|
|
|
name: "mesh",
|
2021-04-06 18:19:59 +00:00
|
|
|
snake: `
|
2021-04-28 22:13:29 +00:00
|
|
|
kind = "mesh"
|
2021-04-06 18:19:59 +00:00
|
|
|
meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
|
|
|
transparent_proxy {
|
2021-06-14 20:15:09 +00:00
|
|
|
mesh_destinations_only = true
|
2021-04-06 18:19:59 +00:00
|
|
|
}
|
2022-03-30 18:43:59 +00:00
|
|
|
tls {
|
|
|
|
incoming {
|
|
|
|
tls_min_version = "TLSv1_1"
|
|
|
|
tls_max_version = "TLSv1_2"
|
|
|
|
cipher_suites = [
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
outgoing {
|
|
|
|
tls_min_version = "TLSv1_1"
|
|
|
|
tls_max_version = "TLSv1_2"
|
|
|
|
cipher_suites = [
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
2021-04-06 18:19:59 +00:00
|
|
|
`,
|
|
|
|
camel: `
|
2021-04-28 22:13:29 +00:00
|
|
|
Kind = "mesh"
|
2021-04-06 18:19:59 +00:00
|
|
|
Meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
|
|
|
TransparentProxy {
|
2021-06-14 20:15:09 +00:00
|
|
|
MeshDestinationsOnly = true
|
2021-04-06 18:19:59 +00:00
|
|
|
}
|
2022-03-30 18:43:59 +00:00
|
|
|
TLS {
|
|
|
|
Incoming {
|
|
|
|
TLSMinVersion = "TLSv1_1"
|
|
|
|
TLSMaxVersion = "TLSv1_2"
|
|
|
|
CipherSuites = [
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
Outgoing {
|
|
|
|
TLSMinVersion = "TLSv1_1"
|
|
|
|
TLSMaxVersion = "TLSv1_2"
|
|
|
|
CipherSuites = [
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
2021-04-06 18:19:59 +00:00
|
|
|
`,
|
|
|
|
snakeJSON: `
|
|
|
|
{
|
2021-04-28 22:13:29 +00:00
|
|
|
"kind": "mesh",
|
2021-04-06 18:19:59 +00:00
|
|
|
"meta" : {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
|
|
|
"transparent_proxy": {
|
2021-06-14 20:15:09 +00:00
|
|
|
"mesh_destinations_only": true
|
2022-03-30 18:43:59 +00:00
|
|
|
},
|
|
|
|
"tls": {
|
|
|
|
"incoming": {
|
|
|
|
"tls_min_version": "TLSv1_1",
|
|
|
|
"tls_max_version": "TLSv1_2",
|
|
|
|
"cipher_suites": [
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"outgoing": {
|
|
|
|
"tls_min_version": "TLSv1_1",
|
|
|
|
"tls_max_version": "TLSv1_2",
|
|
|
|
"cipher_suites": [
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
|
|
|
|
]
|
|
|
|
}
|
2021-04-06 18:19:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
2021-04-28 22:13:29 +00:00
|
|
|
"Kind": "mesh",
|
2021-04-06 18:19:59 +00:00
|
|
|
"Meta" : {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
|
|
|
"TransparentProxy": {
|
2021-06-14 20:15:09 +00:00
|
|
|
"MeshDestinationsOnly": true
|
2022-03-30 18:43:59 +00:00
|
|
|
},
|
|
|
|
"TLS": {
|
|
|
|
"Incoming": {
|
|
|
|
"TLSMinVersion": "TLSv1_1",
|
|
|
|
"TLSMaxVersion": "TLSv1_2",
|
|
|
|
"CipherSuites": [
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"Outgoing": {
|
|
|
|
"TLSMinVersion": "TLSv1_1",
|
|
|
|
"TLSMaxVersion": "TLSv1_2",
|
|
|
|
"CipherSuites": [
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
|
|
|
|
]
|
|
|
|
}
|
2021-04-06 18:19:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
2021-04-28 22:13:29 +00:00
|
|
|
expect: &api.MeshConfigEntry{
|
2021-04-06 18:19:59 +00:00
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim",
|
|
|
|
},
|
2021-04-28 22:13:29 +00:00
|
|
|
TransparentProxy: api.TransparentProxyMeshConfig{
|
2021-06-14 20:15:09 +00:00
|
|
|
MeshDestinationsOnly: true,
|
2021-04-06 18:19:59 +00:00
|
|
|
},
|
2022-03-30 18:43:59 +00:00
|
|
|
TLS: &api.MeshTLSConfig{
|
|
|
|
Incoming: &api.MeshDirectionalTLSConfig{
|
|
|
|
TLSMinVersion: "TLSv1_1",
|
|
|
|
TLSMaxVersion: "TLSv1_2",
|
|
|
|
CipherSuites: []string{
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Outgoing: &api.MeshDirectionalTLSConfig{
|
|
|
|
TLSMinVersion: "TLSv1_1",
|
|
|
|
TLSMaxVersion: "TLSv1_2",
|
|
|
|
CipherSuites: []string{
|
|
|
|
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-04-06 18:19:59 +00:00
|
|
|
},
|
|
|
|
},
|
2021-10-20 19:24:18 +00:00
|
|
|
{
|
2021-12-03 06:50:38 +00:00
|
|
|
name: "exported-services",
|
2021-10-20 19:24:18 +00:00
|
|
|
snake: `
|
2021-12-03 06:50:38 +00:00
|
|
|
kind = "exported-services"
|
2021-10-22 16:11:03 +00:00
|
|
|
name = "foo"
|
2021-10-20 19:24:18 +00:00
|
|
|
meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
|
|
|
services = [
|
|
|
|
{
|
|
|
|
name = "web"
|
|
|
|
namespace = "foo"
|
|
|
|
consumers = [
|
|
|
|
{
|
|
|
|
partition = "bar"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
partition = "baz"
|
2022-04-27 15:27:21 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
peer_name = "flarm"
|
2021-10-20 19:24:18 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "db"
|
|
|
|
namespace = "bar"
|
|
|
|
consumers = [
|
|
|
|
{
|
|
|
|
partition = "zoo"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
`,
|
|
|
|
camel: `
|
2021-12-03 06:50:38 +00:00
|
|
|
Kind = "exported-services"
|
2021-10-22 16:11:03 +00:00
|
|
|
Name = "foo"
|
2021-10-20 19:24:18 +00:00
|
|
|
Meta {
|
|
|
|
"foo" = "bar"
|
|
|
|
"gir" = "zim"
|
|
|
|
}
|
|
|
|
Services = [
|
|
|
|
{
|
|
|
|
Name = "web"
|
|
|
|
Namespace = "foo"
|
|
|
|
Consumers = [
|
|
|
|
{
|
|
|
|
Partition = "bar"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Partition = "baz"
|
2022-04-27 15:27:21 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
PeerName = "flarm"
|
2021-10-20 19:24:18 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name = "db"
|
|
|
|
Namespace = "bar"
|
|
|
|
Consumers = [
|
|
|
|
{
|
|
|
|
Partition = "zoo"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
`,
|
|
|
|
snakeJSON: `
|
|
|
|
{
|
2021-12-03 06:50:38 +00:00
|
|
|
"kind": "exported-services",
|
2021-10-22 16:11:03 +00:00
|
|
|
"name": "foo",
|
2021-10-20 19:24:18 +00:00
|
|
|
"meta": {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
|
|
|
"services": [
|
|
|
|
{
|
|
|
|
"name": "web",
|
|
|
|
"namespace": "foo",
|
|
|
|
"consumers": [
|
|
|
|
{
|
|
|
|
"partition": "bar"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"partition": "baz"
|
2022-04-27 15:27:21 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"peer_name": "flarm"
|
2021-10-20 19:24:18 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "db",
|
|
|
|
"namespace": "bar",
|
|
|
|
"consumers": [
|
|
|
|
{
|
|
|
|
"partition": "zoo"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
camelJSON: `
|
|
|
|
{
|
2021-12-03 06:50:38 +00:00
|
|
|
"Kind": "exported-services",
|
2021-10-22 16:11:03 +00:00
|
|
|
"Name": "foo",
|
2021-10-20 19:24:18 +00:00
|
|
|
"Meta": {
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim"
|
|
|
|
},
|
|
|
|
"Services": [
|
|
|
|
{
|
|
|
|
"Name": "web",
|
|
|
|
"Namespace": "foo",
|
|
|
|
"Consumers": [
|
|
|
|
{
|
|
|
|
"Partition": "bar"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Partition": "baz"
|
2022-04-27 15:27:21 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"PeerName": "flarm"
|
2021-10-20 19:24:18 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Name": "db",
|
|
|
|
"Namespace": "bar",
|
|
|
|
"Consumers": [
|
|
|
|
{
|
|
|
|
"Partition": "zoo"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`,
|
2021-12-03 06:50:38 +00:00
|
|
|
expect: &api.ExportedServicesConfigEntry{
|
2021-10-22 16:11:03 +00:00
|
|
|
Name: "foo",
|
2021-10-20 19:24:18 +00:00
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
"gir": "zim",
|
|
|
|
},
|
|
|
|
Services: []api.ExportedService{
|
|
|
|
{
|
|
|
|
Name: "web",
|
|
|
|
Namespace: "foo",
|
|
|
|
Consumers: []api.ServiceConsumer{
|
|
|
|
{
|
|
|
|
Partition: "bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Partition: "baz",
|
|
|
|
},
|
2022-04-27 15:27:21 +00:00
|
|
|
{
|
|
|
|
PeerName: "flarm",
|
|
|
|
},
|
2021-10-20 19:24:18 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "db",
|
|
|
|
Namespace: "bar",
|
|
|
|
Consumers: []api.ServiceConsumer{
|
|
|
|
{
|
|
|
|
Partition: "zoo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-06-28 16:35:35 +00:00
|
|
|
} {
|
|
|
|
tc := tc
|
|
|
|
|
2019-08-07 21:41:33 +00:00
|
|
|
testbody := func(t *testing.T, body string, expect api.ConfigEntry) {
|
2019-06-28 16:35:35 +00:00
|
|
|
t.Helper()
|
|
|
|
got, err := parseConfigEntry(body)
|
|
|
|
if tc.expectErr != "" {
|
|
|
|
require.Nil(t, got)
|
|
|
|
require.Error(t, err)
|
|
|
|
requireContainsLower(t, err.Error(), tc.expectErr)
|
|
|
|
} else {
|
|
|
|
require.NoError(t, err)
|
2019-08-07 21:41:33 +00:00
|
|
|
require.Equal(t, expect, got)
|
2019-06-28 16:35:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-07 21:41:33 +00:00
|
|
|
t.Run(tc.name+" (hcl snake case)", func(t *testing.T) {
|
|
|
|
testbody(t, tc.snake, tc.expect)
|
2019-06-28 16:35:35 +00:00
|
|
|
})
|
2019-08-07 21:41:33 +00:00
|
|
|
t.Run(tc.name+" (hcl camel case)", func(t *testing.T) {
|
|
|
|
testbody(t, tc.camel, tc.expect)
|
2019-06-28 16:35:35 +00:00
|
|
|
})
|
2019-08-07 21:41:33 +00:00
|
|
|
if tc.snakeJSON != "" {
|
|
|
|
t.Run(tc.name+" (json snake case)", func(t *testing.T) {
|
|
|
|
if tc.expectJSON != nil {
|
|
|
|
testbody(t, tc.snakeJSON, tc.expectJSON)
|
|
|
|
} else {
|
|
|
|
testbody(t, tc.snakeJSON, tc.expect)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if tc.camelJSON != "" {
|
|
|
|
t.Run(tc.name+" (json camel case)", func(t *testing.T) {
|
|
|
|
if tc.expectJSON != nil {
|
|
|
|
testbody(t, tc.camelJSON, tc.expectJSON)
|
|
|
|
} else {
|
|
|
|
testbody(t, tc.camelJSON, tc.expect)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2019-06-28 16:35:35 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-30 23:27:16 +00:00
|
|
|
|
2019-06-28 16:35:35 +00:00
|
|
|
func requireContainsLower(t *testing.T, haystack, needle string) {
|
|
|
|
t.Helper()
|
|
|
|
require.Contains(t, strings.ToLower(haystack), strings.ToLower(needle))
|
2019-04-30 23:27:16 +00:00
|
|
|
}
|
2021-04-15 19:21:44 +00:00
|
|
|
|
|
|
|
func intPointer(v int) *int {
|
|
|
|
return &v
|
|
|
|
}
|