Skip to content

Commit e66ceb6

Browse files
committed
Upgrade controller-runtime, hack fix for gen
controller-runtime 0.4.1 fixed the issue where they generated types as Any which was an invalid type (kubernetes-sigs/controller-tools#505) however that results in the type for proxy-defaults.config being "byte" which fails when creating proxy-defaults. I played around a long time trying to find a type that generates the CRD as expected and can be unmarshalled as expected and nothing worked so for now I think it's best to keep it as json.RawMessage and then patch the generated CRD.
1 parent a6222b7 commit e66ceb6

8 files changed

+20
-13
lines changed

config/crd/bases/consul.hashicorp.com_proxydefaults.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1beta1
44
kind: CustomResourceDefinition
55
metadata:
66
annotations:
7-
controller-gen.kubebuilder.io/version: v0.4.0
7+
controller-gen.kubebuilder.io/version: v0.4.1
88
creationTimestamp: null
99
name: proxydefaults.consul.hashicorp.com
1010
spec:
@@ -43,7 +43,8 @@ spec:
4343
properties:
4444
config:
4545
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
46-
type: Any
46+
format: byte
47+
type: string
4748
expose:
4849
description: Expose controls the default expose path configuration for Envoy.
4950
properties:

config/crd/bases/consul.hashicorp.com_servicedefaults.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1beta1
44
kind: CustomResourceDefinition
55
metadata:
66
annotations:
7-
controller-gen.kubebuilder.io/version: v0.4.0
7+
controller-gen.kubebuilder.io/version: v0.4.1
88
creationTimestamp: null
99
name: servicedefaults.consul.hashicorp.com
1010
spec:

config/crd/bases/consul.hashicorp.com_serviceintentions.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1beta1
44
kind: CustomResourceDefinition
55
metadata:
66
annotations:
7-
controller-gen.kubebuilder.io/version: v0.4.0
7+
controller-gen.kubebuilder.io/version: v0.4.1
88
creationTimestamp: null
99
name: serviceintentions.consul.hashicorp.com
1010
spec:

config/crd/bases/consul.hashicorp.com_serviceresolvers.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1beta1
44
kind: CustomResourceDefinition
55
metadata:
66
annotations:
7-
controller-gen.kubebuilder.io/version: v0.4.0
7+
controller-gen.kubebuilder.io/version: v0.4.1
88
creationTimestamp: null
99
name: serviceresolvers.consul.hashicorp.com
1010
spec:

config/crd/bases/consul.hashicorp.com_servicerouters.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1beta1
44
kind: CustomResourceDefinition
55
metadata:
66
annotations:
7-
controller-gen.kubebuilder.io/version: v0.4.0
7+
controller-gen.kubebuilder.io/version: v0.4.1
88
creationTimestamp: null
99
name: servicerouters.consul.hashicorp.com
1010
spec:

config/crd/bases/consul.hashicorp.com_servicesplitters.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apiVersion: apiextensions.k8s.io/v1beta1
44
kind: CustomResourceDefinition
55
metadata:
66
annotations:
7-
controller-gen.kubebuilder.io/version: v0.4.0
7+
controller-gen.kubebuilder.io/version: v0.4.1
88
creationTimestamp: null
99
name: servicesplitters.consul.hashicorp.com
1010
spec:

config/webhook/manifests.v1beta1.yaml

-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ metadata:
77
name: mutating-webhook-configuration
88
webhooks:
99
- clientConfig:
10-
caBundle: Cg==
1110
service:
1211
name: webhook-service
1312
namespace: system
@@ -26,7 +25,6 @@ webhooks:
2625
- proxydefaults
2726
sideEffects: None
2827
- clientConfig:
29-
caBundle: Cg==
3028
service:
3129
name: webhook-service
3230
namespace: system
@@ -45,7 +43,6 @@ webhooks:
4543
- servicedefaults
4644
sideEffects: None
4745
- clientConfig:
48-
caBundle: Cg==
4946
service:
5047
name: webhook-service
5148
namespace: system
@@ -64,7 +61,6 @@ webhooks:
6461
- serviceintentions
6562
sideEffects: None
6663
- clientConfig:
67-
caBundle: Cg==
6864
service:
6965
name: webhook-service
7066
namespace: system
@@ -83,7 +79,6 @@ webhooks:
8379
- serviceresolvers
8480
sideEffects: None
8581
- clientConfig:
86-
caBundle: Cg==
8782
service:
8883
name: webhook-service
8984
namespace: system
@@ -102,7 +97,6 @@ webhooks:
10297
- servicerouters
10398
sideEffects: None
10499
- clientConfig:
105-
caBundle: Cg==
106100
service:
107101
name: webhook-service
108102
namespace: system

hack/crds-to-consul-helm/main.go

+12
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ func realMain(helmPathAbs string) error {
6262
// Add {{- if .Values.controller.enabled }} {{- end }} wrapper.
6363
contents = fmt.Sprintf("{{- if .Values.controller.enabled }}\n%s{{- end }}\n", contents)
6464

65+
// Hack: handle an issue where controller-gen generates the wrong type
66+
// for the proxydefaults.config struct.
67+
contents = strings.Replace(contents, proxyDefaultsSearch, proxyDefaultsReplace, 1)
68+
6569
// Add labels, this is hacky because we're relying on the line number
6670
// but it means we don't need to regex or yaml parse.
6771
splitOnNewlines := strings.Split(contents, "\n")
@@ -87,6 +91,14 @@ func realMain(helmPathAbs string) error {
8791
})
8892
}
8993

94+
var proxyDefaultsSearch = ` 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
95+
format: byte
96+
type: string
97+
`
98+
var proxyDefaultsReplace = ` 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
99+
type: object
100+
`
101+
90102
func printf(format string, args ...interface{}) {
91103
fmt.Println(fmt.Sprintf(format, args...))
92104
}

0 commit comments

Comments
 (0)