Skip to content

Read CE from stdin, or file given by --from optionΒ #30

@rhuss

Description

@rhuss

Summary

Introduce the --from option for build and send commands, which a user can use to load CE from a file. The option defaults to -, which means the STDIN. Introduce the --from-format option as well, which defaults to json.

Description

The send and build commands may read the STDIN by default and expect there an event in JSON format.

This creates a nice and clean Unix-friendly flow:

$ kn event build --field a.b.c=foo | kn event send --to event-display

User might change that behavior with a new --from option:

$ kn event build --field a.b.c=foo -o json > event.json
# and later
$ kn event send --from event.json --to event-display

By adding the new --from option to the build sub-command as well, we could remove the event building options from send sub-command and keep nice and easy flow even for complex things (also with detecting tty on stdin/stdout we can automatically use json format instead of human-readable format):

$ kn event build --field a.b.c=foo
  | some-ce-modifing-command
  | kn event build --field a.d=bar
  | kn event send --to pod:event-sender

(The above example will build a basic CE with a.b.c=foo data, pass it to some command in JSON format, then add a.d=bar fields, and finally send it to K8s pod called event-sender)

Original description by @rhuss:

For users who don't know the CE spec very well, it feels strange to specify the payload of an event with --field event.data=something (also too long). Also we should allow to pick up the date from a file (which is not needed for other fields).

So from a UX pov I propose to introduce something like a --data and --data-from option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage/acceptedIssues which should be fixed (post-triage)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions