Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Allow unstructed schema for config in ProxyDefaults #921

Merged
merged 4 commits into from Apr 20, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
## Unreleased

BUG FIXES:
* CRDs: Fix a bug where the `config` field in `ProxyDefaults` CR was not synced to Consul because
`apiextensions.k8s.io/v1` requires CRD spec to have structured schema. [[GH-921](https://github.com/hashicorp/consul-helm/pull/921)]

## 0.32.0-beta1 (Apr 16, 2021)

IMPROVEMENTS:
Expand Down
1 change: 1 addition & 0 deletions templates/crd-proxydefaults.yaml
Expand Up @@ -54,6 +54,7 @@ spec:
config:
description: Config is an arbitrary map of configuration values used by Connect proxies. Any values that your proxy allows can be configured globally here. Supports JSON config values. See https://www.consul.io/docs/connect/proxies/envoy#configuration-formatting
type: object
x-kubernetes-preserve-unknown-fields: true
expose:
description: Expose controls the default expose path configuration for Envoy.
properties:
Expand Down
8 changes: 8 additions & 0 deletions test/acceptance/tests/controller/controller_test.go
Expand Up @@ -92,6 +92,14 @@ func TestController(t *testing.T) {
proxyDefaultEntry, ok := entry.(*api.ProxyConfigEntry)
require.True(r, ok, "could not cast to ProxyConfigEntry")
require.Equal(r, api.MeshGatewayModeLocal, proxyDefaultEntry.MeshGateway.Mode)
require.Equal(r, "tcp", proxyDefaultEntry.Config["protocol"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's also test foo and member for completeness. Or we can remove those from the fixture. I like testing multiple types, so maybe bool, array, map, string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good call. I think I've made an assumption that these are going to be ignored by consul, but they're not!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

require.Equal(r, float64(3), proxyDefaultEntry.Config["number"])
require.Equal(r, true, proxyDefaultEntry.Config["bool"])
require.Equal(r, []interface{}{"item1", "item2"}, proxyDefaultEntry.Config["array"])
require.Equal(r, map[string]interface{}{"key": "value"}, proxyDefaultEntry.Config["map"])
require.Equal(r, "/health", proxyDefaultEntry.Expose.Paths[0].Path)
require.Equal(r, 22000, proxyDefaultEntry.Expose.Paths[0].ListenerPort)
require.Equal(r, 8080, proxyDefaultEntry.Expose.Paths[0].LocalPathPort)

// service-router
entry, _, err = consulClient.ConfigEntries().Get(api.ServiceRouter, "router", nil)
Expand Down
15 changes: 13 additions & 2 deletions test/acceptance/tests/fixtures/crds/proxydefaults.yaml
Expand Up @@ -4,7 +4,18 @@ metadata:
name: global
spec:
config:
foo: '{"http":{"name":"envoy.zipkin","config":{"collector_cluster":"zipkin","collector_endpoint":"/api/v1/spans","shared_span_context":false}}}'
members: 3
protocol: "tcp"
number: 3
bool: true
array:
- item1
- item2
map:
key: value
meshGateway:
mode: local
expose:
paths:
- path: /health
listenerPort: 22000
localPathPort: 8080