Patch (or create) cannot take input from stdin
Opened this issue · 2 comments
I would like to send input from a command to the codefresh
CLI tool. The help text says I can do this:
$ codefresh --help | grep stdin
codefresh patch Patch a resource by filename or stdin.
codefresh create Create a resource from a file or stdin.
In this particular example, I have a file that I've encrypted with SOPS, but this could be any command that outputs YAML.
$ sops --decrypt my-context.yaml
apiVersion: v1
kind: context
metadata:
default: false
system: false
name: my-context
type: secret
spec:
type: secret
data:
foo: bar
Unfortunately, none of these work:
$ sops --decrypt my-context.yaml | codefresh patch context
Error: Missing name in metadata
$ sops --decrypt my-context.yaml | codefresh patch context -f -
Error: Failed to read file; caused by Error: ENOENT: no such file or directory, open '/tmp/-'
$ sops --decrypt my-context.yaml | codefresh patch context -f /dev/stdin
Error: Failed to read file; caused by Error: File extension is not recognized
$ codefresh patch context -f <(sops --decrypt my-context.yaml)
Error: Failed to read file; caused by Error: File extension is not recognized
I must write to a file with a name ending in .yaml
:
$ sops --decrypt my-context.yaml >cleartext.yaml && codefresh patch context -f cleartext.yaml && rm cleartext.yaml
Context: my-context patched
I'd really prefer not to write the decrypted data to disk, for security reasons.
One thing I didn't address here is that input filenames can also end in .json
, which causes them to be parsed as JSON instead of YAML. Suggestion: similar to how there is a -o yaml
option for commands that produce output, commands that consume input could have a -i yaml
option to specify the format of data either on stdin or in a file without an extension (such as /dev/stdin
or /dev/fd/*
, in my examples). Then JSON users could have this functionality too.
I can confirm this doesn't work with create pipeline
either. The "you can send things in from stdin" part seems not to work.