Skip to content

Pass mux router URI-based parameters through in event context #3424

Open
@rossigee

Description

@rossigee

Describe the bug feature request

I'm trying to configure a webhook eventsource with a parameterised route (i.e. /foobar/{username}) but I'm unable to obtain the 'username' variable for use in the sensor.

To Reproduce

  1. Create test case...
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: foobar
secrets:
- name: foobar

---
apiVersion: v1
kind: Secret
metadata:
  name: foobar
  annotations:
    kubernetes.io/service-account.name: foobar
type: kubernetes.io/service-account-token

---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: foobar
rules:
- apiGroups:
  - ""
  resources:
  - pods
  verbs:
  - create

---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: foobar
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: foobar
subjects:
- kind: ServiceAccount
  name: foobar

---
apiVersion: argoproj.io/v1alpha1
kind: EventBus
metadata:
  name: default
spec:
  jetstream:
    version: latest
    replicas: 3
---
apiVersion: argoproj.io/v1alpha1
kind: EventSource
metadata:
  name: foobar
spec:
  eventBusName: default
  service:
    ports:
      - port: 12000
        targetPort: 12000
  webhook:
    foobar-event:
      port: "12000"
      endpoint: "/foobar/{username}"
      method: POST
  template:
    container:
      env:
        - name: LOG_LEVEL
          value: debug
---
apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
  name: foobar-debug
spec:
  eventBusName: default
  template:
    serviceAccountName: foobar
    container:
      env:
        - name: LOG_LEVEL
          value: debug
  dependencies:
    - name: foobar-event
      eventSourceName: foobar
      eventName: foobar-event
  triggers:
    - template:
        name: log
        log: {}
    - template:
        name: debug
        k8s:
          group: ""
          version: "v1"
          resource: "Pod"
          operation: "create"
          source:
            resource:
              apiVersion: v1
              kind: Pod
              metadata:
                generateName: debug-
              spec:
                securityContext:
                  runAsNonRoot: true
                  runAsUser: 65534
                  seccompProfile:
                    type: RuntimeDefault
                restartPolicy: Never
                containers:
                  - name: debug
                    image: alpine
                    command:
                      - echo
                      - "N/A"
                    securityContext:
                      allowPrivilegeEscalation: false
                      capabilities:
                        drop:
                          - ALL
          parameters:
            - src:
                dependencyName: foobar-event
                contextKey: username
              dest: spec.containers.0.command.1

Create a test event...

curl -v -XPOST -H "Content-Type: application/json" -d"{\"content\":\"Test message\"}" http://foobar-eventsource-svc.default.svc.cluster.local:12000/foobar/test1

Now I can't find test1 in the context or data variables available to the sensor, or even in the eventsource or sensor debug logs. It seems to just ignore it.

Expected behavior

Given the use of mux.Router, I was kind of expecting the username to appear as a variable in the Context. However, it doesn't seem to be getting passed through anywhere.

Environment (please complete the following information):

  • Kubernetes: v1.31.1
  • Argo: ???
  • Argo Events: image: quay.io/argoproj/argo-events:v1.9.5

Additional context

N/A


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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions