From d8708cadd68e01890c822f4f20ffe2a9501a75d7 Mon Sep 17 00:00:00 2001 From: Antonin Stefanutti Date: Fri, 3 Jul 2020 19:31:46 +0200 Subject: [PATCH] fix(api): Declare integration Flow as json.RawMessage --- deploy/crd-integration.yaml | 4 +- .../integrations.camel.apache.org.crd.yaml | 4 +- deploy/resources.go | 4 +- e2e/knative/knative_platform_test.go | 20 +++-- go.sum | 4 + helm/camel-k/crds/crd-integration.yaml | 4 +- pkg/apis/camel/go.mod | 3 +- pkg/apis/camel/go.sum | 2 + pkg/apis/camel/v1/common_types.go | 7 +- pkg/apis/camel/v1/zz_generated.deepcopy.go | 27 ++++++- pkg/client/camel/go.sum | 1 + pkg/cmd/run.go | 7 +- pkg/trait/init.go | 13 +++- pkg/util/digest/digest.go | 9 ++- pkg/util/flow/flow.go | 76 +++++++++++++++++++ pkg/util/flow/flow_test.go | 53 +++++++++++++ 16 files changed, 210 insertions(+), 28 deletions(-) create mode 100644 pkg/util/flow/flow.go create mode 100644 pkg/util/flow/flow_test.go diff --git a/deploy/crd-integration.yaml b/deploy/crd-integration.yaml index 0366bde436..6157ce4d3e 100644 --- a/deploy/crd-integration.yaml +++ b/deploy/crd-integration.yaml @@ -88,9 +88,7 @@ spec: type: array flows: items: - description: Flow is an unstructured object representing a Camel Flow - in YAML/JSON DSL - type: string + type: object type: array kit: type: string diff --git a/deploy/olm-catalog/camel-k-dev/1.1.0-snapshot/integrations.camel.apache.org.crd.yaml b/deploy/olm-catalog/camel-k-dev/1.1.0-snapshot/integrations.camel.apache.org.crd.yaml index 0366bde436..6157ce4d3e 100644 --- a/deploy/olm-catalog/camel-k-dev/1.1.0-snapshot/integrations.camel.apache.org.crd.yaml +++ b/deploy/olm-catalog/camel-k-dev/1.1.0-snapshot/integrations.camel.apache.org.crd.yaml @@ -88,9 +88,7 @@ spec: type: array flows: items: - description: Flow is an unstructured object representing a Camel Flow - in YAML/JSON DSL - type: string + type: object type: array kit: type: string diff --git a/deploy/resources.go b/deploy/resources.go index 573461fe09..307bd13388 100644 --- a/deploy/resources.go +++ b/deploy/resources.go @@ -140,9 +140,9 @@ var assets = func() http.FileSystem { "/crd-integration.yaml": &vfsgen۰CompressedFileInfo{ name: "crd-integration.yaml", modTime: time.Time{}, - uncompressedSize: 11649, + uncompressedSize: 11528, - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x1a\x4d\x6f\xe3\xb8\xf5\xae\x5f\xf1\x10\x1f\x66\x17\x88\xed\xce\xee\xa5\x70\x4f\xae\x27\x41\xdd\xc9\x38\x81\xe5\xd9\xc5\x1c\x69\xe9\x59\x66\x43\x91\x2a\x49\xd9\x49\x8b\xfe\xf7\xe2\x91\x92\x2c\xc9\x92\xe3\x38\x33\x58\x60\x11\xdd\x2c\xbe\xef\x6f\x3e\x79\x00\xc3\xef\xf7\x04\x03\xb8\xe3\x11\x4a\x83\x31\x58\x05\x76\x8b\x30\xcd\x58\xb4\x45\x08\xd5\xc6\xee\x99\x46\xb8\x55\xb9\x8c\x99\xe5\x4a\xc2\x4f\xd3\xf0\xf6\x67\xc8\x65\x8c\x1a\x94\x44\x50\x1a\x52\xa5\x31\x18\x40\xa4\xa4\xd5\x7c\x9d\x5b\xa5\x41\x78\x82\xc0\x12\x8d\x98\xa2\xb4\x66\x04\x10\x22\x3a\xea\x8b\xfb\xd5\x7c\x76\x03\x1b\x2e\x10\x62\x6e\x3c\x12\xc6\xb0\xe7\x76\x1b\x0c\xc0\x6e\xb9\x81\xbd\xd2\x8f\xb0\x51\x1a\x58\x1c\x73\x62\xcc\x04\x70\xb9\x51\x3a\xf5\x62\x68\x4c\x98\x8e\xb9\x4c\x20\x52\xd9\xb3\xe6\xc9\xd6\x82\xda\x4b\xd4\x66\xcb\xb3\x51\x30\x80\x15\xa9\x11\xde\x96\x92\x18\x4f\xd6\xf1\xb4\x0a\xbe\xa9\xbc\xd0\xa1\xa6\x6e\x61\x85\x6b\xf8\x0d\xb5\x21\x26\xbf\x8c\xfe\x12\x0c\xe0\x27\x02\xb9\x2a\x0e\xaf\x7e\xfe\x1b\x3c\xab\x1c\x52\xf6\x0c\x52\x59\xc8\x0d\xd6\x28\xe3\x53\x84\x99\x05\x2e\x21\x52\x69\x26\x38\x93\x11\x1e\xd4\xaa\x38\x8c\xc0\x09\x40\x34\xd4\xda\x32\x2e\x81\x39\x35\x40\x6d\xea\x60\xc0\x6c\x30\x08\x06\xe0\x9e\xad\xb5\xd9\x64\x3c\xde\xef\xf7\x23\xe6\xc4\x1d\x29\x9d\x8c\x4b\xed\xc6\x77\xf3\xd9\xcd\x22\xbc\x19\x3a\x91\x83\x01\x7c\x95\x02\x8d\x01\x8d\xff\xce\xb9\xc6\x18\xd6\xcf\xc0\xb2\x4c\xf0\x88\xad\x05\x82\x60\x7b\x72\x9c\xf3\x8e\x73\x3a\x97\xb0\xd7\xdc\x72\x99\x5c\x83\x29\xbc\x1e\x0c\x1a\xde\x39\x98\xab\x14\x8f\x9b\x06\x80\x92\xc0\x24\x5c\x4d\x43\x98\x87\x57\xf0\xf7\x69\x38\x0f\xaf\x83\x01\xfc\x3e\x5f\xfd\xe3\xfe\xeb\x0a\x7e\x9f\x2e\x97\xd3\xc5\x6a\x7e\x13\xc2\xfd\x12\x66\xf7\x8b\x4f\xf3\xd5\xfc\x7e\x11\xc2\xfd\x2d\x4c\x17\xdf\xe0\xf3\x7c\xf1\xe9\x1a\x90\xdb\x2d\x6a\xc0\xa7\x4c\x93\xfc\x4a\x03\x27\x43\x62\x4c\x3e\x2d\x03\xa8\x14\x80\xe2\x83\x7e\x9b\x0c\x23\xbe\xe1\x11\x08\x26\x93\x9c\x25\x08\x89\xda\xa1\x96\x14\x1e\x19\xea\x94\x1b\x72\xa7\x01\x26\xe3\x60\x00\x82\xa7\xdc\xba\x28\x32\xc7\x4a\x11\x9b\xef\x99\x5b\x01\xcb\x78\x11\x4e\x13\x60\x19\xc7\x27\x8b\xd2\x49\x33\x7a\xfc\xab\x19\x71\x35\xde\x7d\x5c\xa3\x65\x1f\x83\x47\x2e\xe3\x09\xcc\x72\x63\x55\xba\x44\xa3\x72\x1d\xe1\x27\xdc\x70\xe9\xc2\x3f\x48\xd1\xb2\x98\x59\x36\x09\x00\x24\x4b\x71\x02\x5c\x5a\x4c\xb4\x57\x64\x14\xb1\x14\x45\x2d\x32\x02\x00\xc1\xd6\x28\x0c\xc1\x03\xf9\x7e\x02\x57\x0e\x68\xf8\x78\x15\x90\xc1\xe8\xe0\x90\x5c\x0f\x9a\xc8\xe9\x99\x12\x79\x2a\x0b\xa4\x21\xfc\x33\xbc\x5f\x3c\x30\xbb\x9d\xc0\xc8\x58\x66\x73\x33\xca\xb6\xcc\x60\xe0\x43\x32\x46\x13\x69\x9e\x59\xa7\x1b\xe5\x5b\x4d\x22\xa8\x03\x7a\x79\x1f\x6a\x6f\xec\x73\x86\x13\xa0\xd8\x91\x49\x2f\xaf\x47\x6e\xcf\xe1\x74\x00\xf3\x7c\x3e\x57\xbf\xcf\xe2\xa2\xd1\xa5\x85\xe9\x63\x25\xf3\x74\x4d\xb5\x6e\x03\x99\x8a\x4d\x83\xd3\xb2\x89\xea\xd9\x39\xd1\x50\x07\x00\x89\x56\x79\x36\x81\x0e\xd7\x10\x7a\x61\x64\xef\xf6\xf9\x41\x1f\xf7\x56\x70\x63\x3f\xb7\x4f\xee\xb8\xf1\x9a\x65\x22\xd7\x4c\x34\x23\xc0\x1d\x98\xad\xd2\x76\x71\x20\x4e\x1a\x17\xd6\x30\x5c\x26\xb9\x60\xba\x81\x15\x00\x98\x48\x91\xd4\x0e\x29\x63\x11\xc6\xf4\x2e\x5f\xeb\x22\x02\x0b\x42\x26\x62\x02\x4b\x9a\x2e\xb0\x42\x14\x18\x59\xa5\x9b\xc6\x34\xc5\xdb\x02\x92\xe2\xac\x34\x52\x09\x98\x61\xd4\xb6\xb9\x47\x6e\x03\x76\xb8\xc7\xbf\x9b\xc0\x7f\xff\x17\x00\xec\x98\xe0\xbe\x29\x79\xc1\x54\x86\x72\xfa\x30\xff\xed\xd7\x30\xda\x62\xca\x26\x5d\x0e\xad\x59\x93\xca\x17\x25\xbe\x87\xae\x6a\x49\xdd\xa6\x30\x7d\x98\x17\x54\x32\xad\x32\xd4\x96\x1f\x2c\x4b\x49\x55\xa5\x76\xf5\xae\xc5\xef\x03\x09\x54\x74\x93\x98\x92\x19\x3d\xd3\x9d\x7f\x87\x31\x18\xcf\xde\x55\x7e\x4e\x05\x9b\x0a\x1f\x4a\x7b\x88\x85\xf2\x51\x1b\xaa\xaf\x6a\xfd\x2f\x8c\xec\x08\x42\xd4\x44\x84\x5c\x9e\x8b\x98\x9a\xef\x0e\xb5\x05\x8d\x91\x4a\x24\xff\x4f\x45\xd9\x94\x3d\x5d\x30\x8b\xc6\x36\x28\xba\x94\xa7\xce\xba\x63\x22\xc7\x6b\xaa\x8f\xae\x29\x69\x24\x1e\x90\xcb\x1a\x35\x07\x62\x46\xf0\x45\x69\x74\x9d\x78\xe2\x5a\x92\x99\x8c\xc7\x09\xb7\x65\x31\x8b\x54\x9a\xe6\x92\xdb\xe7\x71\x6d\x1a\x30\xe3\x18\x77\x28\xc6\x86\x27\x43\xa6\xa3\x2d\xb7\x18\xd9\x5c\xe3\x98\x65\x7c\xe8\x04\x97\xbe\x88\xa5\xf1\xa0\x8a\xbb\x0f\x35\x49\x8f\xf2\xb8\x4a\x9c\x5e\xbb\x53\xf2\x90\x87\x59\x81\xe6\xe5\x3f\x98\x97\x5e\x91\x55\x96\x37\xe1\x0a\x4a\xa6\xce\x05\x4d\x9b\x3b\x6b\x1f\xd0\xcc\xc1\xf0\x64\x28\x2e\x37\xae\x7d\x50\xff\xd7\x2a\x75\x14\x51\xc6\x99\xe2\xd2\xba\x1f\x91\xe0\x28\x9b\x46\x37\xf9\x3a\xe5\xd6\xb7\x66\x34\x96\xfc\x33\x82\x19\x93\x34\x4d\xac\x11\xf2\x2c\x66\x16\xe3\x11\xcc\x25\xcc\xa8\x72\xcc\x18\x0d\x0c\x3f\xd8\xec\x64\x61\x33\x24\x93\xbe\x6c\xf8\x7a\x27\x6a\x02\x7a\x6b\x55\xaf\xcb\x2e\xd3\xe9\xa1\x5a\x26\x86\x19\x46\x8d\xec\x88\xd1\xb8\xa1\x85\xd2\x1d\x29\xee\xdb\xe5\xb1\x3f\x27\xe9\x89\x94\xdc\xf0\x24\xd7\xb5\xda\x50\x8b\x79\x8b\xa9\x69\xbf\x6c\xc9\x36\xab\x13\x70\xd2\x0d\x87\x47\x18\x7d\xdc\x6b\x06\xe9\x78\xdf\x63\xd3\xc3\xe3\xe2\xf4\x02\xcc\x72\xd2\xeb\x42\x1d\x3a\xd4\xce\x03\xc7\xee\xe8\xa4\xd3\x9d\xf5\x23\xa6\x35\x7b\x6e\x9c\xc4\x98\xa1\x8c\x51\x46\x1d\x06\xe9\xb1\xf9\x09\x7d\xfa\xb8\x6c\x84\xda\x9f\x4b\xbe\xe1\xd2\x5b\xa1\xf6\xae\x1e\x48\xc8\xa5\xb1\x3a\x77\xa9\x10\x1f\x25\x38\xd5\x05\xe6\x13\xcf\xe1\x74\x18\x8d\x4b\xf8\x36\xfd\x72\x37\xa6\x51\x02\x3e\x85\x77\xdf\x43\xaf\x47\x6e\xdb\x0a\xf4\x52\xc9\xb4\xa2\xcb\x46\x1b\xbe\x39\xb8\x68\xc6\xed\x83\x07\xac\x55\x2f\x37\x57\x18\xd7\x6c\x08\x80\xb2\x8d\x59\xa0\x1b\x1e\x4a\xba\x18\xc4\x47\xba\x1c\x8d\xd8\x5c\x1a\xcb\x84\x70\xa9\x31\xe6\x9d\x79\x79\x52\xfa\xb2\x9f\xb7\xc5\xf7\x57\x3b\x37\x9d\xfc\xfa\x4b\x27\xb1\xc3\x60\xd5\xa0\xa6\x0c\xb7\x4a\xff\xd0\xa8\x6b\x0d\x43\x2f\xb2\x68\xb8\xa2\x9c\xe5\x2f\xab\x23\x74\x8f\xa4\x9b\x50\x47\x25\xab\xcb\xbc\x56\x4a\x20\x6b\x3b\xc1\x13\x90\x16\xe5\x51\x74\xbd\x68\x8b\x1a\xee\x67\x7c\x7e\x0b\xfa\x12\x37\x17\xa1\xa7\x2a\x97\xd6\x0d\x83\x97\x60\xbb\x09\xfd\x12\xc4\xfe\xca\xdd\xe9\xd6\xd5\x73\x86\x5d\x6e\x7d\x91\xd3\x05\x35\xd6\xa0\xde\xf1\x08\xa7\x51\x44\xa6\x59\x74\x68\xd8\xcb\xf1\x0d\x01\x1c\xbe\x87\xef\x25\xe8\x6e\xb8\x8e\x30\xa3\x49\xec\x8c\x78\x9a\xd7\xc0\x5d\x45\x56\x59\xb9\xf6\x8a\xa9\x2f\x6d\x38\x0d\x9d\x54\x8a\x95\x4e\xca\xdb\xa4\xbf\x5a\x3e\x8e\x96\x2a\xb7\x68\xee\x14\x8b\x5b\xf5\xf1\xf0\xe4\x6e\x07\xa6\x20\xd3\x38\xce\x94\xb1\xe4\xb8\x08\x8d\x29\x23\xa3\x13\xad\x27\x3c\xce\xd2\xbf\x3f\x8c\xfd\x53\xee\x6a\xce\xb0\xcd\x5d\xb9\xd6\xb9\x24\xcf\x00\x84\xb3\xcb\x39\x7c\x1c\x60\x31\x26\xd4\xec\x5f\xee\xe5\x2e\xb3\xbc\xeb\xb1\x7b\x2e\x84\x0f\x89\x4c\xa3\xf5\x57\x86\xe2\xd2\xc1\x2c\xe8\x5c\x5a\x9e\x76\x4d\x68\x3f\xaa\xce\x5d\x50\x7d\xfc\xc8\xd0\xe6\x55\x5f\x21\xf5\x57\x82\x86\x99\xa7\x7e\x3c\x71\x15\x85\x92\x8c\x71\xe9\x23\xbb\x31\xb8\xbb\xfb\xae\x67\xfa\xea\xa2\x73\x62\xfe\x7f\x8d\xd4\x67\xd8\xf1\x05\x5b\x9e\x61\xe8\xa3\xa3\xee\xbb\x94\xdf\x7c\x9c\x73\x9b\x72\x90\x8d\xfb\x94\x5a\x53\xe7\x78\xc3\x85\x8a\x65\x6c\xcd\x05\xef\xb2\xd2\xf7\x9b\xb2\x22\x25\xbd\x53\x2e\xea\x52\x35\x8d\x66\x25\xa1\x02\x62\x5d\x98\xa1\xd2\x9e\x55\x13\x5d\x87\x3f\x69\x20\x86\x08\xb5\xdb\xcb\xbb\x9b\xfc\xe8\x95\xf1\x27\x98\xb1\x2b\xcd\xa4\x71\x42\xac\x78\x5f\x82\xb6\x6a\x9c\xb1\x40\x45\xa0\xcc\x84\x42\x05\x5b\x11\xc2\xd8\x2f\x19\x94\xc4\x22\x1c\xfa\x02\x56\x01\x93\xca\x6e\x51\x1f\x4b\x0e\xb5\x51\x3b\x66\x16\x87\x97\xd6\x1d\x52\xf2\xab\xdb\x55\x9c\xa9\xe0\xca\xed\xa0\x0e\x4a\x72\x53\xd3\x72\xcf\x4c\xb5\xf9\xf8\x71\x32\xa7\x68\xcc\x79\x1d\x67\x0a\xdb\x3c\x65\x12\x34\xb2\xd8\x7d\x31\x29\x50\x81\xcb\x98\x47\xcc\x5d\x13\x63\xb4\x8c\x0b\x03\x6c\xad\xf2\xe3\xbc\x2f\x04\xda\x62\xcd\x83\xdd\xaa\xbd\x20\xb4\x46\x66\xfa\xca\xd8\x91\x81\x3d\x70\x75\x6b\xab\x0c\xfc\xc1\x14\xb6\x7f\x9b\x2c\xc7\x55\xa8\x47\x96\xa2\x08\x15\x7d\xb3\x12\xe3\xda\x7f\x32\xdc\xc0\x4a\xe7\x78\x0d\xb7\x4c\x18\xbc\x86\xaf\xf2\x51\xaa\xfd\x65\x12\x9d\x39\xad\xbb\x29\x5d\x6d\x1a\xdf\x0d\x2a\xa9\x2e\x60\x7c\x7a\xdb\xd2\x9b\x9d\x3d\x8b\x98\x0b\x9a\xf1\xfb\x8e\xab\xf5\xfc\x79\x76\x5c\x31\x4f\xd0\x9c\xbf\x0e\xda\x30\x2e\x72\x7d\x7a\x1d\x74\xeb\x61\x8e\x5d\x7c\xca\xc1\xfd\x85\xe7\x05\x27\x45\x6a\x87\xba\xf3\xce\xd5\x25\xd4\xb2\x80\xef\x1e\xee\x4f\x47\x20\x75\x6b\x8b\x69\xd6\x73\x3f\x3c\xb5\x39\x6a\x11\xf8\xc2\x9e\xde\x4c\xa3\xbf\x11\x9e\xdb\xbf\xce\x68\x06\xfd\x19\x40\xa1\x5e\x48\x72\xfa\xf4\x0b\x7b\xea\x75\x6a\xdf\x14\xdb\xa3\xda\x39\x6a\x9d\x50\xa9\x5f\x9d\x61\x11\x7e\x9d\x07\x3e\x60\x3a\x8e\x3a\x24\xe8\x55\x2b\x41\x89\x9a\x06\x8e\xe5\xfb\x76\xef\x0f\x58\x8f\xbc\x6f\xf7\xda\x75\xbf\x0a\xc8\xf0\x7d\x57\x77\x21\xfa\xfb\xae\xee\x6d\x3b\x8c\xf7\x5d\xdd\x9f\x64\x57\xc7\xd3\x0e\x6f\xf5\x32\x79\xd5\xd7\xc7\x2d\x33\xa7\x87\xcd\xda\x26\xc6\xfd\xe5\xeb\x38\x12\xfa\x89\x0b\x66\x69\xa4\x78\xff\x16\x7a\xc9\xb7\x50\x1f\x98\x0f\x5a\xed\x78\x47\x0e\x35\xfb\x5b\x13\xf6\x15\x2e\x2a\xb8\x74\xfc\xf1\xe9\x24\x5a\xf9\xc7\xb0\xb3\x11\x76\xaf\x62\xd0\x91\x22\xad\x57\x25\x3d\xd8\x7d\x3c\xfc\xaa\xfe\xe8\xe8\xff\xcf\xe7\x8e\xa0\xf8\xd0\x86\xf1\x04\xac\xae\x2e\x8e\xc6\x2a\x4d\x39\xe5\xdf\xfd\x3f\x00\x00\xff\xff\xd4\x20\x19\xbf\x81\x2d\x00\x00"), + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x1a\x4d\x73\xe2\x38\xf6\xee\x5f\xf1\x2a\x1c\x7a\xa6\x2a\xc0\xf6\xcc\x65\x8b\x3d\xb1\x74\x52\xcb\x76\x9a\xa4\x80\x9e\xa9\x39\x0a\xfb\x61\xb4\x91\x25\xad\x24\x43\xb2\x5b\xfb\xdf\xb7\x9e\x64\x1b\x1b\x6c\x42\x48\x77\x4d\x55\x57\x7c\xc3\x7a\xdf\xdf\x7a\xa6\x07\xfd\x6f\xf7\x44\x3d\xb8\xe3\x31\x4a\x8b\x09\x38\x05\x6e\x83\x30\xd6\x2c\xde\x20\x2c\xd4\xda\xed\x98\x41\xb8\x55\xb9\x4c\x98\xe3\x4a\xc2\x4f\xe3\xc5\xed\xcf\x90\xcb\x04\x0d\x28\x89\xa0\x0c\x64\xca\x60\xd4\x83\x58\x49\x67\xf8\x2a\x77\xca\x80\x08\x04\x81\xa5\x06\x31\x43\xe9\xec\x00\x60\x81\xe8\xa9\xcf\xee\x97\xd3\xc9\x0d\xac\xb9\x40\x48\xb8\x0d\x48\x98\xc0\x8e\xbb\x4d\xd4\x03\xb7\xe1\x16\x76\xca\x3c\xc2\x5a\x19\x60\x49\xc2\x89\x31\x13\xc0\xe5\x5a\x99\x2c\x88\x61\x30\x65\x26\xe1\x32\x85\x58\xe9\x67\xc3\xd3\x8d\x03\xb5\x93\x68\xec\x86\xeb\x41\xd4\x83\x25\xa9\xb1\xb8\x2d\x25\xb1\x81\xac\xe7\xe9\x14\xfc\xa1\xf2\x42\x87\x9a\xba\x85\x15\xae\xe1\x37\x34\x96\x98\xfc\x32\xf8\x4b\xd4\x83\x9f\x08\xe4\xaa\x38\xbc\xfa\xf9\x6f\xf0\xac\x72\xc8\xd8\x33\x48\xe5\x20\xb7\x58\xa3\x8c\x4f\x31\x6a\x07\x5c\x42\xac\x32\x2d\x38\x93\x31\xee\xd5\xaa\x38\x0c\xc0\x0b\x40\x34\xd4\xca\x31\x2e\x81\x79\x35\x40\xad\xeb\x60\xc0\x5c\xd4\x8b\x7a\xe0\x9f\x8d\x73\x7a\x34\x1c\xee\x76\xbb\x01\xf3\xe2\x0e\x94\x49\x87\xa5\x76\xc3\xbb\xe9\xe4\x66\xb6\xb8\xe9\x7b\x91\xa3\x1e\x7c\x95\x02\xad\x05\x83\xff\xce\xb9\xc1\x04\x56\xcf\xc0\xb4\x16\x3c\x66\x2b\x81\x20\xd8\x8e\x1c\xe7\xbd\xe3\x9d\xce\x25\xec\x0c\x77\x5c\xa6\xd7\x60\x0b\xaf\x47\xbd\x86\x77\xf6\xe6\x2a\xc5\xe3\xb6\x01\xa0\x24\x30\x09\x57\xe3\x05\x4c\x17\x57\xf0\xf7\xf1\x62\xba\xb8\x8e\x7a\xf0\xfb\x74\xf9\x8f\xfb\xaf\x4b\xf8\x7d\x3c\x9f\x8f\x67\xcb\xe9\xcd\x02\xee\xe7\x30\xb9\x9f\x7d\x9a\x2e\xa7\xf7\xb3\x05\xdc\xdf\xc2\x78\xf6\x07\x7c\x9e\xce\x3e\x5d\x03\x72\xb7\x41\x03\xf8\xa4\x0d\xc9\xaf\x0c\x70\x32\x24\x26\xe4\xd3\x32\x80\x4a\x01\x28\x3e\xe8\xb7\xd5\x18\xf3\x35\x8f\x41\x30\x99\xe6\x2c\x45\x48\xd5\x16\x8d\xa4\xf0\xd0\x68\x32\x6e\xc9\x9d\x16\x98\x4c\xa2\x1e\x08\x9e\x71\xe7\xa3\xc8\x1e\x2b\x45\x6c\xbe\x65\x6e\x45\x4c\xf3\x22\x9c\x46\xc0\x34\xc7\x27\x87\xd2\x4b\x33\x78\xfc\xab\x1d\x70\x35\xdc\x7e\x5c\xa1\x63\x1f\xa3\x47\x2e\x93\x11\x4c\x72\xeb\x54\x36\x47\xab\x72\x13\xe3\x27\x5c\x73\xe9\xc3\x3f\xca\xd0\xb1\x84\x39\x36\x8a\x00\x24\xcb\x70\x04\x5c\x3a\x4c\x4d\x50\x64\x10\xb3\x0c\x45\x2d\x32\x22\x00\xc1\x56\x28\x2c\xc1\x03\xf9\x7e\x04\x57\x1e\xa8\xff\x78\x15\x91\xc1\xe8\x60\x9f\x5c\x0f\x86\xc8\x99\x89\x12\x79\x26\x0b\xa4\x3e\xfc\x73\x71\x3f\x7b\x60\x6e\x33\x82\x81\x75\xcc\xe5\x76\xa0\x37\xcc\x62\x14\x42\x32\x41\x1b\x1b\xae\x9d\xd7\x8d\xf2\xad\x26\x11\xd4\x01\x83\xbc\x0f\xb5\x37\xee\x59\xe3\x08\x28\x76\x64\xda\xc9\xeb\x91\xbb\x73\x38\xed\xc1\x02\x9f\xcf\xd5\xef\xb3\xb8\x18\xf4\x69\x61\xbb\x58\xc9\x3c\x5b\x51\xad\x5b\x83\x56\x89\x6d\x70\x9a\x37\x51\x03\x3b\x2f\x1a\x9a\x08\x20\x35\x2a\xd7\x23\x68\x71\x0d\xa1\x17\x46\x0e\x6e\x9f\xee\xf5\xf1\x6f\x05\xb7\xee\xf3\xe1\xc9\x1d\xb7\x41\x33\x2d\x72\xc3\x44\x33\x02\xfc\x81\xdd\x28\xe3\x66\x7b\xe2\xa4\x71\x61\x0d\xcb\x65\x9a\x0b\x66\x1a\x58\x11\x80\x8d\x15\x49\xed\x91\x34\x8b\x31\xa1\x77\xf9\xca\x14\x11\x58\x10\xb2\x31\x13\x58\xd2\xf4\x81\xb5\x40\x81\xb1\x53\xa6\x69\x4c\x5b\xbc\x2d\x20\x29\xce\x4a\x23\x95\x80\x1a\xe3\x43\x9b\x07\xe4\x43\xc0\x16\xf7\x84\x77\x23\xf8\xef\xff\x22\x80\x2d\x13\x3c\x34\xa5\x20\x98\xd2\x28\xc7\x0f\xd3\xdf\x7e\x5d\xc4\x1b\xcc\xd8\xa8\xcd\xa1\x35\x6b\x52\xf9\xa2\xc4\x0f\xd0\x55\x2d\xa9\xdb\x14\xc6\x0f\xd3\x82\x8a\x36\x4a\xa3\x71\x7c\x6f\x59\x4a\xaa\x2a\xb5\xab\x77\x07\xfc\x3e\x90\x40\x45\x37\x49\x28\x99\x31\x30\xdd\x86\x77\x98\x80\x0d\xec\x7d\xe5\xe7\x54\xb0\xa9\xf0\xa1\x74\xfb\x58\x28\x1f\xb5\xa6\xfa\xaa\x56\xff\xc2\xd8\x0d\x60\x81\x86\x88\x90\xcb\x73\x91\x50\xf3\xdd\xa2\x71\x60\x30\x56\xa9\xe4\xff\xa9\x28\xdb\xb2\xa7\x0b\xe6\xd0\xba\x06\x45\x9f\xf2\xd4\x59\xb7\x4c\xe4\x78\x4d\xf5\xd1\x37\x25\x83\xc4\x03\x72\x59\xa3\xe6\x41\xec\x00\xbe\x28\x83\xbe\x13\x8f\x7c\x4b\xb2\xa3\xe1\x30\xe5\xae\x2c\x66\xb1\xca\xb2\x5c\x72\xf7\x3c\xac\x4d\x03\x76\x98\xe0\x16\xc5\xd0\xf2\xb4\xcf\x4c\xbc\xe1\x0e\x63\x97\x1b\x1c\x32\xcd\xfb\x5e\x70\x19\x8a\x58\x96\xf4\xaa\xb8\xfb\x50\x93\xf4\x28\x8f\xab\xc4\xe9\xb4\x3b\x25\x0f\x79\x98\x15\x68\x41\xfe\xbd\x79\xe9\x15\x59\x65\x7e\xb3\x58\x42\xc9\xd4\xbb\xa0\x69\x73\x6f\xed\x3d\x9a\xdd\x1b\x9e\x0c\xc5\xe5\xda\xb7\x0f\xea\xff\x46\x65\x9e\x22\xca\x44\x2b\x2e\x9d\xff\x11\x0b\x8e\xb2\x69\x74\x9b\xaf\x32\xee\x42\x6b\x46\xeb\xc8\x3f\x03\x98\x30\x49\xd3\xc4\x0a\x21\xd7\x09\x73\x98\x0c\x60\x2a\x61\x42\x95\x63\xc2\x68\x60\xf8\xce\x66\x27\x0b\xdb\x3e\x99\xf4\x65\xc3\xd7\x3b\x51\x13\x30\x58\xab\x7a\x5d\x76\x99\x56\x0f\xd5\x32\x71\xa1\x31\x6e\x64\x47\x82\xd6\x0f\x2d\x94\xee\x48\x71\x7f\x58\x1e\xbb\x73\x92\x9e\x58\xc9\x35\x4f\x73\x53\xab\x0d\xb5\x98\x77\x98\xd9\xc3\x97\x07\xb2\x4d\xea\x04\xbc\x74\xfd\xfe\x11\x46\x17\xf7\x9a\x41\x5a\xde\x77\xd8\x74\xff\xf8\x38\xbd\x00\xb3\x9c\xf4\xda\x50\xfb\x1e\xb5\xf5\xc0\xb3\x3b\x3a\x69\x75\x67\xfd\x88\x19\xc3\x9e\x1b\x27\x09\x6a\x94\x09\xca\xb8\xc5\x20\x1d\x36\x3f\xa1\x4f\x17\x97\xb5\x50\xbb\xd7\x91\x7f\x95\x12\x8f\xdc\x1d\xd2\xe9\x14\x52\x1b\x45\x33\xff\x21\x7c\x73\x7e\x30\x8c\xbb\x87\x00\x58\x2b\x22\xbe\xbd\x5b\x5f\xf3\x09\x80\x82\x9e\x39\xa0\x8b\x16\x4a\x9a\xcf\x93\x23\x5d\x8e\x26\x5d\x2e\xad\x63\x42\xf8\x08\x1d\xf2\xd6\xf4\x38\x29\x7d\xd9\x56\x0f\xc5\x0f\x37\x2c\x3f\x24\xfc\xfa\x4b\x2b\xb1\xfd\x7c\xd3\xa0\xa6\x2c\x77\xca\x7c\x57\xe7\x1f\xcc\x24\x2f\xb2\x68\xb8\xa2\x1c\xa9\x2f\x4b\x67\xba\xce\xd1\x85\xa4\xa5\xa0\xd4\x65\x5e\x29\x25\x90\x1d\x3a\x21\x10\x90\x0e\xe5\x51\x74\xbd\x68\x8b\x1a\xee\x67\x7c\x7e\x0b\xfa\x1c\xd7\x17\xa1\x67\x2a\x97\xce\xcf\x64\x97\x60\xfb\x41\xf9\x12\xc4\xee\x02\xda\xea\xd6\xe5\xb3\xc6\x36\xb7\xbe\xc8\xe9\x82\x2a\x61\xd1\x6c\x79\x8c\xe3\x38\x26\xd3\xcc\x5a\x34\xec\xe4\xf8\x86\x00\x5e\xbc\x87\xef\x25\xe8\x7e\xc6\x8d\x51\xd3\x40\x74\x46\x3c\x4d\x6b\xe0\xbe\x22\x2b\x5d\x6e\x9f\x12\x9a\x97\xd6\x9c\x66\x3f\x2a\xc5\xca\xa4\xe5\xa5\x2e\xdc\xf0\x1e\x07\x73\x95\x3b\xb4\x77\x8a\x25\x07\xf5\x71\xff\xe4\x7e\x15\xa5\x40\x1b\x1c\x6a\x65\x1d\x39\x2e\x46\x6b\xcb\xc8\x68\x45\xeb\x08\x8f\xb3\xf4\xef\x0e\xe3\xf0\x94\x2b\x93\x33\x6c\x73\x57\x6e\x57\x2e\xc9\x33\x00\xe1\xed\x72\x0e\x1f\x0f\xe8\xa7\x77\x59\xb7\x7f\xb9\x1e\xbb\xcc\xf2\xbe\xc7\xee\xb8\x10\x21\x24\xb4\x41\x17\x26\xf7\x62\xf6\x67\x0e\x4c\x2e\x1d\xcf\xda\x06\xa5\xef\x55\xe7\x2e\xa8\x3e\x61\x64\x38\xe4\x55\xdf\xe4\x74\x57\x82\x86\x99\xc7\x61\x3c\xf1\x15\x85\x92\x8c\x71\x19\x22\xbb\x31\x3f\xfb\x6b\x67\x60\xfa\xea\xa2\x73\x62\x0c\x7f\x8d\xd4\x67\xd8\xf1\x05\x5b\x9e\x61\xe8\xa3\xa3\xf6\x2b\x4d\x58\x40\x9c\x73\xa9\xf1\x90\x8d\x6b\x8d\x5a\x51\xe7\x78\xc3\xbd\x86\x69\xb6\xe2\x82\xb7\x59\xe9\xdb\x4d\x59\xb1\x92\xc1\x29\x17\x75\xa9\x9a\x46\x93\x92\x50\x01\xb1\x2a\xcc\x50\x69\xcf\xaa\x89\xae\xc5\x9f\x34\x10\x43\x8c\xc6\xaf\xc7\xfd\x85\x7a\xf0\xca\xf8\x13\xcc\xba\xa5\x61\xd2\x7a\x21\x96\xbc\x2b\x41\x0f\x6a\x9c\x75\x40\x45\xa0\xcc\x84\x42\x05\x57\x11\xc2\x24\xdc\xf5\x95\xc4\x22\x1c\xba\x02\x56\x01\x93\xca\x6d\xd0\x1c\x4b\x0e\xb5\x51\x9b\xee\xfb\xfd\x4b\xeb\x0e\x29\xf9\xd5\xaf\x0c\xce\x54\x70\xe9\x57\x41\x7b\x25\xb9\xad\x69\xb9\x63\xb6\x5a\x40\x7c\x3f\x99\x33\xb4\xf6\xbc\x8e\x33\x86\x4d\x9e\x31\x09\x06\x59\xe2\x3f\x5c\x14\xa8\xc0\x65\xc2\x63\xe6\xb7\x38\x09\x3a\xc6\x85\x05\xb6\x52\xf9\x71\xde\x17\x02\x6d\xb0\xe6\xc1\x76\xd5\x5e\x10\xda\x20\xb3\x5d\x65\xec\xc8\xc0\x01\xb8\xba\xb5\x55\x06\xfe\x60\x0b\xdb\xbf\x4d\x96\xe3\x2a\xd4\x21\x4b\x51\x84\x8a\xbe\x59\x89\x71\x1d\xbe\xdc\xad\x61\x69\x72\xbc\x86\x5b\x26\x2c\x5e\xc3\x57\xf9\x28\xd5\xee\x32\x89\xce\x9c\xd6\xfd\x94\xae\xd6\x8d\xf5\x7d\x25\xd5\x05\x8c\x4f\x2f\x3d\x3a\xb3\xb3\x63\x1f\x72\x41\x33\x7e\x5f\x35\x1d\x3c\x3f\xce\xaa\x29\xe1\x29\xda\xf3\xd7\x41\x6b\xc6\x45\x6e\x4e\xaf\x83\x6e\x03\xcc\xb1\x8b\x4f\x39\xb8\xbb\xf0\xbc\xe0\xa4\x58\x6d\xd1\xb4\xde\xb9\xda\x84\x9a\x17\xf0\xed\xc3\xfd\xe9\x08\xa4\x6e\xed\x30\xd3\x1d\xf7\xc3\x53\x9b\xa3\x03\x02\x5f\xd8\xd3\x9b\x69\x74\x37\xc2\x73\xfb\xd7\x19\xcd\xa0\x3b\x03\x28\xd4\x0b\x49\x4e\x9f\x7e\x61\x4f\x9d\x4e\xed\x9a\x62\x3b\x54\x3b\x47\xad\x13\x2a\x75\xab\xd3\x2f\xc2\xaf\xf5\x20\x04\x4c\xcb\x51\x8b\x04\x9d\x6a\xa5\x28\xd1\xd0\xc0\x31\x7f\xdf\xee\xfd\x09\xeb\x91\xf7\xed\xde\x61\xdd\xaf\x02\x72\xf1\xbe\xab\xbb\x10\xfd\x7d\x57\xf7\xb6\x1d\xc6\xfb\xae\xee\x07\xd9\xd5\xf1\xac\xc5\x5b\x9d\x4c\x5e\xf5\xf5\x71\xc3\xec\xe9\x61\xb3\xb6\x89\xf1\xff\xbc\x3a\x8e\x84\x6e\xe2\x82\x39\x1a\x29\xde\xbf\x85\x5e\xf2\x2d\x34\x04\xe6\x83\x51\x5b\xde\x92\x43\xcd\xfe\xd6\x84\x7d\x85\x8b\x0a\x2e\x2d\xff\x3f\x3a\x89\x56\xfe\x3f\xeb\x6c\x84\xed\xab\x18\xb4\xa4\xc8\xc1\xab\x92\x1e\x6c\x3f\xee\x7f\x55\xff\x37\x0c\x7f\xab\xf3\x47\x50\x7c\x68\xc3\x64\x04\xce\x54\x17\x47\xeb\x94\xa1\x9c\x0a\xef\xfe\x1f\x00\x00\xff\xff\xb8\x5c\x23\x74\x08\x2d\x00\x00"), }, "/operator-deployment.yaml": &vfsgen۰CompressedFileInfo{ name: "operator-deployment.yaml", diff --git a/e2e/knative/knative_platform_test.go b/e2e/knative/knative_platform_test.go index f3aa8468fe..857a72ff9b 100644 --- a/e2e/knative/knative_platform_test.go +++ b/e2e/knative/knative_platform_test.go @@ -25,11 +25,16 @@ import ( "strings" "testing" + . "github.com/onsi/gomega" + + "github.com/stretchr/testify/assert" + + corev1 "k8s.io/api/core/v1" + . "github.com/apache/camel-k/e2e/support" "github.com/apache/camel-k/pkg/apis/camel/v1" + "github.com/apache/camel-k/pkg/util/flow" "github.com/apache/camel-k/pkg/util/knative" - . "github.com/onsi/gomega" - corev1 "k8s.io/api/core/v1" ) func TestKnativePlatformTest(t *testing.T) { @@ -53,11 +58,12 @@ func TestKnativePlatformTest(t *testing.T) { // Change something in the integration to produce a redeploy Expect(UpdateIntegration(ns, "yaml", func(it *v1.Integration) { it.Spec.Profile = "" - var flows []v1.Flow - for _, flow := range it.Spec.Flows { - flows = append(flows, v1.Flow(strings.ReplaceAll(string(flow), "string!", "string!!!"))) - } - it.Spec.Flows = flows + content, err := flow.Marshal(it.Spec.Flows) + assert.NoError(t, err) + newData := strings.ReplaceAll(string(content), "string!", "string!!!") + newFlows, err := flow.UnmarshalString(newData) + assert.NoError(t, err) + it.Spec.Flows = newFlows })).To(BeNil()) // Spec profile should be reset by "kamel run" Eventually(IntegrationSpecProfile(ns, "yaml")).Should(Equal(v1.TraitProfile(""))) diff --git a/go.sum b/go.sum index c5771d783d..3f5902be39 100644 --- a/go.sum +++ b/go.sum @@ -1375,12 +1375,16 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8 rsc.io/letsencrypt v0.0.3/go.mod h1:buyQKZ6IXrRnB7TdkHP0RyEybLx18HHyOSoTyoOLqNY= sigs.k8s.io/controller-runtime v0.5.2 h1:pyXbUfoTo+HA3jeIfr0vgi+1WtmNh0CwlcnQGLXwsSw= sigs.k8s.io/controller-runtime v0.5.2/go.mod h1:JZUwSMVbxDupo0lTJSSFP5pimEyxGynROImSsqIOx1A= +sigs.k8s.io/controller-tools v0.0.0-20200528125929-5c0c6ae3b64b/go.mod h1:enhtKGfxZD1GFEoMgP8Fdbu+uKQ/cq1/WGJhdVChfvI= sigs.k8s.io/controller-tools v0.2.4/go.mod h1:m/ztfQNocGYBgTTCmFdnK94uVvgxeZeE3LtJvd/jIzA= sigs.k8s.io/controller-tools v0.2.8/go.mod h1:9VKHPszmf2DHz/QmHkcfZoewO6BL7pPs9uAiBVsaJSE= +sigs.k8s.io/controller-tools v0.3.0/go.mod h1:enhtKGfxZD1GFEoMgP8Fdbu+uKQ/cq1/WGJhdVChfvI= sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e h1:4Z09Hglb792X0kfOBBJUPFEyvVfQWrYT/l8h5EKA6JQ= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/structured-merge-diff/v2 v2.0.1/go.mod h1:Wb7vfKAodbKgf6tn1Kl0VvGj7mRH6DGaRcixXEJXTsE= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= +sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= vbom.ml/util v0.0.0-20160121211510-db5cfe13f5cc/go.mod h1:so/NYdZXCz+E3ZpW0uAoCj6uzU2+8OWDFv/HxUSs7kI= diff --git a/helm/camel-k/crds/crd-integration.yaml b/helm/camel-k/crds/crd-integration.yaml index 0366bde436..6157ce4d3e 100644 --- a/helm/camel-k/crds/crd-integration.yaml +++ b/helm/camel-k/crds/crd-integration.yaml @@ -88,9 +88,7 @@ spec: type: array flows: items: - description: Flow is an unstructured object representing a Camel Flow - in YAML/JSON DSL - type: string + type: object type: array kit: type: string diff --git a/pkg/apis/camel/go.mod b/pkg/apis/camel/go.mod index d50e11b238..c7bcb9fd86 100644 --- a/pkg/apis/camel/go.mod +++ b/pkg/apis/camel/go.mod @@ -5,6 +5,7 @@ go 1.13 require ( k8s.io/api v0.18.2 k8s.io/apimachinery v0.18.2 - sigs.k8s.io/controller-tools v0.3.0 // indirect + // Required to get https://github.com/kubernetes-sigs/controller-tools/pull/428 + sigs.k8s.io/controller-tools v0.0.0-20200528125929-5c0c6ae3b64b // indirect sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e // indirect ) diff --git a/pkg/apis/camel/go.sum b/pkg/apis/camel/go.sum index afd0e7ee00..60acd8035a 100644 --- a/pkg/apis/camel/go.sum +++ b/pkg/apis/camel/go.sum @@ -415,6 +415,8 @@ k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c/go.mod h1:GRQhZsXIAJ1xR0C k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 h1:d4vVOjXm687F1iLSP2q3lyPPuyvTUt3aVoBpi2DqRsU= k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.7/go.mod h1:PHgbrJT7lCHcxMU+mDHEm+nx46H4zuuHZkDP6icnhu0= +sigs.k8s.io/controller-tools v0.0.0-20200528125929-5c0c6ae3b64b h1:jVf/McoMd0tHALAJrr4VgEVakuOhEYQ+m00kJTseL3s= +sigs.k8s.io/controller-tools v0.0.0-20200528125929-5c0c6ae3b64b/go.mod h1:enhtKGfxZD1GFEoMgP8Fdbu+uKQ/cq1/WGJhdVChfvI= sigs.k8s.io/controller-tools v0.3.0 h1:y3YD99XOyWaXkiF1kd41uRvfp/64teWcrEZFuHxPhJ4= sigs.k8s.io/controller-tools v0.3.0/go.mod h1:enhtKGfxZD1GFEoMgP8Fdbu+uKQ/cq1/WGJhdVChfvI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e h1:4Z09Hglb792X0kfOBBJUPFEyvVfQWrYT/l8h5EKA6JQ= diff --git a/pkg/apis/camel/v1/common_types.go b/pkg/apis/camel/v1/common_types.go index ee660f722e..47d4afc1b6 100644 --- a/pkg/apis/camel/v1/common_types.go +++ b/pkg/apis/camel/v1/common_types.go @@ -18,6 +18,8 @@ limitations under the License. package v1 import ( + "encoding/json" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -133,4 +135,7 @@ type ResourceCondition interface { } // Flow is an unstructured object representing a Camel Flow in YAML/JSON DSL -type Flow string +// +kubebuilder:validation:Type=object +type Flow struct { + json.RawMessage `json:",inline"` +} diff --git a/pkg/apis/camel/v1/zz_generated.deepcopy.go b/pkg/apis/camel/v1/zz_generated.deepcopy.go index 3cd5a5fe24..f8f17f16df 100644 --- a/pkg/apis/camel/v1/zz_generated.deepcopy.go +++ b/pkg/apis/camel/v1/zz_generated.deepcopy.go @@ -5,6 +5,8 @@ package v1 import ( + json "encoding/json" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" @@ -617,6 +619,27 @@ func (in *FailureRecovery) DeepCopy() *FailureRecovery { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Flow) DeepCopyInto(out *Flow) { + *out = *in + if in.RawMessage != nil { + in, out := &in.RawMessage, &out.RawMessage + *out = make(json.RawMessage, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Flow. +func (in *Flow) DeepCopy() *Flow { + if in == nil { + return nil + } + out := new(Flow) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ImageTask) DeepCopyInto(out *ImageTask) { *out = *in @@ -1086,7 +1109,9 @@ func (in *IntegrationSpec) DeepCopyInto(out *IntegrationSpec) { if in.Flows != nil { in, out := &in.Flows, &out.Flows *out = make([]Flow, len(*in)) - copy(*out, *in) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } if in.Resources != nil { in, out := &in.Resources, &out.Resources diff --git a/pkg/client/camel/go.sum b/pkg/client/camel/go.sum index 29c91ed134..13fbe757a1 100644 --- a/pkg/client/camel/go.sum +++ b/pkg/client/camel/go.sum @@ -464,6 +464,7 @@ modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03 modernc.org/strutil v1.0.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs= modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.7/go.mod h1:PHgbrJT7lCHcxMU+mDHEm+nx46H4zuuHZkDP6icnhu0= +sigs.k8s.io/controller-tools v0.0.0-20200528125929-5c0c6ae3b64b/go.mod h1:enhtKGfxZD1GFEoMgP8Fdbu+uKQ/cq1/WGJhdVChfvI= sigs.k8s.io/controller-tools v0.3.0/go.mod h1:enhtKGfxZD1GFEoMgP8Fdbu+uKQ/cq1/WGJhdVChfvI= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e h1:4Z09Hglb792X0kfOBBJUPFEyvVfQWrYT/l8h5EKA6JQ= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go index fce05e7313..5927a47e52 100644 --- a/pkg/cmd/run.go +++ b/pkg/cmd/run.go @@ -36,6 +36,7 @@ import ( "github.com/apache/camel-k/pkg/client" "github.com/apache/camel-k/pkg/trait" "github.com/apache/camel-k/pkg/util" + "github.com/apache/camel-k/pkg/util/flow" "github.com/apache/camel-k/pkg/util/gzip" "github.com/apache/camel-k/pkg/util/kubernetes" k8slog "github.com/apache/camel-k/pkg/util/kubernetes/log" @@ -471,7 +472,11 @@ func (o *runCmdOptions) updateIntegrationCode(c client.Client, sources []string) } if o.UseFlows && (strings.HasSuffix(source, ".yaml") || strings.HasSuffix(source, ".yml")) { - integration.Spec.AddFlows(v1.Flow(data)) + flows, err := flow.UnmarshalString(data) + if err != nil { + return nil, err + } + integration.Spec.AddFlows(flows...) } else { integration.Spec.AddSources(v1.SourceSpec{ DataSpec: v1.DataSpec{ diff --git a/pkg/trait/init.go b/pkg/trait/init.go index d0600217fc..32236e93e6 100644 --- a/pkg/trait/init.go +++ b/pkg/trait/init.go @@ -25,9 +25,10 @@ import ( v1 "github.com/apache/camel-k/pkg/apis/camel/v1" "github.com/apache/camel-k/pkg/util" + "github.com/apache/camel-k/pkg/util/flow" ) -const flowsInternalSourceName = "camel-k-embedded-flow-%d.yaml" +const flowsInternalSourceName = "camel-k-embedded-flow.yaml" // Internal trait type initTrait struct { @@ -52,11 +53,15 @@ func (t *initTrait) Apply(e *Environment) error { if e.IntegrationInPhase(v1.IntegrationPhaseInitialization) { // Flows need to be turned into a generated source - for i, flow := range e.Integration.Spec.Flows { + if len(e.Integration.Spec.Flows) > 0 { + content, err := flow.Marshal(e.Integration.Spec.Flows) + if err != nil { + return err + } e.Integration.Status.AddOrReplaceGeneratedSources(v1.SourceSpec{ DataSpec: v1.DataSpec{ - Name: fmt.Sprintf(flowsInternalSourceName, i), - Content: string(flow), + Name: flowsInternalSourceName, + Content: string(content), }, }) } diff --git a/pkg/util/digest/digest.go b/pkg/util/digest/digest.go index bc4ff63aa1..1a398007fe 100644 --- a/pkg/util/digest/digest.go +++ b/pkg/util/digest/digest.go @@ -31,6 +31,7 @@ import ( v1 "github.com/apache/camel-k/pkg/apis/camel/v1" "github.com/apache/camel-k/pkg/util" "github.com/apache/camel-k/pkg/util/defaults" + "github.com/apache/camel-k/pkg/util/flow" ) // ComputeForIntegration a digest of the fields that are relevant for the deployment @@ -67,8 +68,12 @@ func ComputeForIntegration(integration *v1.Integration) (string, error) { } // Integration flows - for _, flow := range integration.Spec.Flows { - if _, err := hash.Write([]byte(flow)); err != nil { + if len(integration.Spec.Flows) > 0 { + flows, err := flow.Marshal(integration.Spec.Flows) + if err != nil { + return "", err + } + if _, err := hash.Write(flows); err != nil { return "", err } } diff --git a/pkg/util/flow/flow.go b/pkg/util/flow/flow.go new file mode 100644 index 0000000000..aaabd4d76d --- /dev/null +++ b/pkg/util/flow/flow.go @@ -0,0 +1,76 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package flow + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "io/ioutil" + + yaml2 "gopkg.in/yaml.v2" + + "k8s.io/apimachinery/pkg/util/yaml" + + v1 "github.com/apache/camel-k/pkg/apis/camel/v1" +) + +// UnmarshalString reads flows contained in a string +func UnmarshalString(flowsString string) ([]v1.Flow, error) { + return Unmarshal(bytes.NewReader([]byte(flowsString))) +} + +// Unmarshal flows from a stream +func Unmarshal(reader io.Reader) ([]v1.Flow, error) { + buffered, err := ioutil.ReadAll(reader) + if err != nil { + return nil, err + } + var flows []v1.Flow + // Using the Kubernetes decoder to turn them into JSON before unmarshal. + // This avoids having map[interface{}]interface{} objects which are not JSON compatible. + jsonData, err := yaml.ToJSON(buffered) + if err != nil { + return nil, err + } + + if err = json.Unmarshal(jsonData, &flows); err != nil { + return nil, err + } + return flows, err +} + +// Marshal flows as byte array +func Marshal(flows []v1.Flow) ([]byte, error) { + data, err := json.Marshal(&flows) + if err != nil { + return nil, err + } + jsondata := make([]map[string]interface{}, 0) + err = json.Unmarshal(data, &jsondata) + if err != nil { + return nil, fmt.Errorf("error unmarshalling json: %v", err) + } + yamldata, err := yaml2.Marshal(&jsondata) + if err != nil { + return nil, fmt.Errorf("error marshalling to yaml: %v", err) + } + + return yamldata, nil +} diff --git a/pkg/util/flow/flow_test.go b/pkg/util/flow/flow_test.go new file mode 100644 index 0000000000..4afb2ef7b8 --- /dev/null +++ b/pkg/util/flow/flow_test.go @@ -0,0 +1,53 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package flow + +import ( + "bytes" + "encoding/json" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestReadWriteYaml(t *testing.T) { + // yaml in conventional form as marshalled by the go runtime + yaml := `- from: + steps: + - to: log:info + uri: timer:tick +` + + yamlReader := bytes.NewReader([]byte(yaml)) + flows, err := Unmarshal(yamlReader) + assert.NoError(t, err) + assert.NotNil(t, flows) + assert.Len(t, flows, 1) + + flow := map[string]interface{}{} + err = json.Unmarshal(flows[0].RawMessage, &flow) + assert.NoError(t, err) + + assert.NotNil(t, flow["from"]) + assert.Nil(t, flow["xx"]) + + data, err := Marshal(flows) + assert.NoError(t, err) + assert.NotNil(t, data) + assert.Equal(t, yaml, string(data)) +}