@@ -78,6 +78,36 @@ func TestCRDsFromFile(t *testing.T) {
7878
7979// TestCRDsFromUrl pulls the CRD YAML file from a URL and generates it in each language
8080func TestCRDsFromUrl (t * testing.T ) {
81+ validateNodeCompiles := func (t * testing.T , path string ) {
82+ withDir (t , path , func () {
83+ runRequireNoError (t , exec .Command ("npm" , "install" ))
84+ runRequireNoError (t , exec .Command ("npm" , "run" , "build" ))
85+ })
86+ }
87+
88+ validateGolangCompiles := func (t * testing.T , path string ) {
89+ withDir (t , path , func () {
90+ runRequireNoError (t , exec .Command ("go" , "mod" , "init" , "fakepackage" ))
91+ runRequireNoError (t , exec .Command ("go" , "mod" , "tidy" ))
92+ runRequireNoError (t , exec .Command ("go" , "vet" , "./..." ))
93+ })
94+ }
95+
96+ validateDotnetCompiles := func (t * testing.T , path string ) {
97+ withDir (t , path , func () {
98+ runRequireNoError (t , exec .Command ("dotnet" , "build" ))
99+ })
100+ }
101+
102+ // TODO: Also run compilation tests for java and python.
103+ compileValidationFn := map [string ]func (t * testing.T , path string ){
104+ "nodejs" : validateNodeCompiles ,
105+ "go" : validateGolangCompiles ,
106+ "python" : nil ,
107+ "java" : nil ,
108+ "dotnet" : validateDotnetCompiles ,
109+ }
110+
81111 tests := []struct {
82112 name string
83113 url string
@@ -98,15 +128,61 @@ func TestCRDsFromUrl(t *testing.T) {
98128 name : "Contours" ,
99129 url : "https://raw.githubusercontent.com/projectcontour/contour-operator/f8c07498803d062e30c255976270cbc82cd619b0/config/crd/bases/operator.projectcontour.io_contours.yaml" ,
100130 },
131+ {
132+ // https://github.com/pulumi/crd2pulumi/issues/141
133+ name : "ElementDeployment" ,
134+ url : "https://raw.githubusercontent.com/element-hq/ess-starter-edition-core/d7e792bf8a872f06f02f59d807a1c16ee933862b/roles/elementdeployment/files/elementdeployment-schema.yaml" ,
135+ },
136+ {
137+ // https://github.com/pulumi/crd2pulumi/issues/142
138+ name : "Keycloak" ,
139+ url : "https://raw.githubusercontent.com/keycloak/keycloak-k8s-resources/25.0.4/kubernetes/keycloaks.k8s.keycloak.org-v1.yml" ,
140+ },
141+ {
142+ // https://github.com/pulumi/crd2pulumi/issues/115
143+ name : "CertManager" ,
144+ url : "https://gist.githubusercontent.com/RouxAntoine/b7dfb9ce327a4ad40a76ff6552c7fd5e/raw/4b5922da11643e14d04e6b52f7a0fca982e4dace/1-crds.yaml" ,
145+ },
146+ {
147+ // https://github.com/pulumi/crd2pulumi/issues/104
148+ name : "TracingPolicies" ,
149+ url : "https://raw.githubusercontent.com/cilium/tetragon/v1.2.0/install/kubernetes/tetragon/crds-yaml/cilium.io_tracingpolicies.yaml" ,
150+ },
151+ {
152+ // https://github.com/pulumi/crd2pulumi/issues/104
153+ name : "Argo Rollouts" ,
154+ url : "https://raw.githubusercontent.com/argoproj/argo-rollouts/74c1a947ab36670ae01a45993a0c5abb44af4677/manifests/crds/rollout-crd.yaml" ,
155+ },
156+ {
157+ // https://github.com/pulumi/crd2pulumi/issues/92
158+ name : "Grafana" ,
159+ url : "https://raw.githubusercontent.com/bitnami/charts/main/bitnami/grafana-operator/crds/grafanas.integreatly.org.yaml" ,
160+ },
161+ {
162+ // https://github.com/pulumi/crd2pulumi/issues/70
163+ name : "Percona" ,
164+ url : "https://raw.githubusercontent.com/percona/percona-server-mongodb-operator/main/deploy/crd.yaml" ,
165+ },
166+ {
167+ // https://github.com/pulumi/crd2pulumi/issues/49
168+ name : "Traefik" ,
169+ url : "https://raw.githubusercontent.com/traefik/traefik/eb99c8c/docs/content/reference/dynamic-configuration/traefik.io_traefikservices.yaml" ,
170+ },
171+ {
172+ // https://github.com/pulumi/crd2pulumi/issues/29
173+ name : "Istio" ,
174+ url : "https://raw.githubusercontent.com/istio/istio/c132663/manifests/charts/base/crds/crd-all.gen.yaml" ,
175+ },
101176 }
102177
103178 for _ , tt := range tests {
104179 t .Run (tt .name , func (t * testing.T ) {
105180 for _ , lang := range languages {
106- lang := lang
107181 t .Run (lang , func (t * testing.T ) {
108- t .Parallel ()
109- execCrd2Pulumi (t , lang , tt .url , nil )
182+ if tt .name == "CertManager" && lang == "dotnet" {
183+ t .Skip ("Skipping CertManager for dotnet. See https://github.com/pulumi/crd2pulumi/issues/17" )
184+ }
185+ execCrd2Pulumi (t , lang , tt .url , compileValidationFn [lang ])
110186 })
111187 }
112188 })
0 commit comments