You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I am trying to parametrize an entire block of k8s trigger using payload. the payload converted to string with backslashes and can't be injected to overwrite the block. Workflows CRD getting cannot unmarshall spec: cannot restore struct from: string.
Here is an example of the sensor:
kind: Sensor
metadata:
name: example
namespace: argocd
spec:
template:
serviceAccountName: argo-wf
dependencies:
- name: example-dep
eventSourceName: example-event-source
eventName: event-test
triggers:
- template:
name: example-template
k8s:
operation: create
source:
resource:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: injected-block-
spec:
entrypoint: main
arguments:
parameters:
- name: message
value: hello world
serviceAccountName: argo-wf
templates:
- name: main
container:
image: docker/whalesay:latest
command: [cowsay]
args:
- "hello world"
parameters:
- src:
dependencyName: example-dep
dataKey: body.injected
dest: spec.templates.0.container```
After debugging the sensor I have found that in line 124 sensors/triggers/params.go get serialized json with backslashes:
Describe the bug
I am trying to parametrize an entire block of k8s trigger using payload. the payload converted to string with backslashes and can't be injected to overwrite the block. Workflows CRD getting
cannot unmarshall spec: cannot restore struct from: string.
Here is an example of the sensor:
func ApplyParams(jsonObj []byte, params []v1alpha1.TriggerParameter, events map[string]*v1alpha1.Event) ([]byte, error) {
...
tmp, err := sjson.SetBytes(jsonObj, param.Dest, *value)
...
*values values is:
The source of that serialization in github.com/cloudevents/sdk-go/v2 that used in eventbus/stan/sensor.(*STANTriggerConn).Subscribe.func1.
Better option would be to use this differently and use sjson.SetRawBytes function instead of sjson.SetBytes in sensors/triggers/params.go
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Create a workflow that marshal spec right.
Screenshots
Environment (please complete the following information):
Additional context
Add any other context about the problem here.
Message from the maintainers:
If you wish to see this enhancement implemented please add a 👍 reaction to this issue! We often sort issues this way to know what to prioritize.
The text was updated successfully, but these errors were encountered: