config entry: hardcode proxy-defaults name as global (#14833)

* config entry: hardcode proxy-defaults name as global

proxy-defaults can only have the name global. Because of this,
we support not even setting the name in the config file:

```
kind = "proxy-defaults"
```

Previously, writing this would result in the output:

```
Config entry written: proxy-defaults/
```

Now it will output:

```
Config entry written: proxy-defaults/global
```

This change follows what was done for the new Mesh config entry.
This commit is contained in:
Luke Kysow 2022-10-25 10:55:15 -07:00 committed by GitHub
parent 6b1ec05470
commit 1be7b5bf35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 1 deletions

3
.changelog/14833.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
cli: always use name "global" for proxy-defaults config entries
```

View File

@ -273,7 +273,7 @@ type ProxyConfigEntry struct {
}
func (p *ProxyConfigEntry) GetKind() string { return p.Kind }
func (p *ProxyConfigEntry) GetName() string { return p.Name }
func (p *ProxyConfigEntry) GetName() string { return ProxyConfigGlobal }
func (p *ProxyConfigEntry) GetPartition() string { return p.Partition }
func (p *ProxyConfigEntry) GetNamespace() string { return p.Namespace }
func (p *ProxyConfigEntry) GetMeta() map[string]string { return p.Meta }

View File

@ -147,6 +147,25 @@ http {
require.True(t, proxy.HTTP.SanitizeXForwardedClientCert)
})
// Test that if name isn't set (which isn't required for proxy-defaults because the name defaults to
// "global"), the CLI response still says "config entry written proxy-defaults/global".
t.Run("proxy defaults config entry without name set", func(t *testing.T) {
stdin := new(bytes.Buffer)
stdin.WriteString(`
kind = "proxy-defaults"
`)
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: proxy-defaults/global`)
require.Equal(t, 0, code)
})
}
func requireContainsLower(t *testing.T, haystack, needle string) {