kong icon indicating copy to clipboard operation
kong copied to clipboard

`filecontent` argument fields appear to accept multiple arguments

Open negz opened this issue 3 years ago • 4 comments

I just updated to the latest commit (919e70103f7a7068ebccb991e24836f2933529fd) because I wanted to use the new type:"filecontent" feature (thank you!). It works as expected, but I notice in the help output the argument is followed by ..., which I believe implies multiple arguments could be supplied. Is this an artifact of the field type being []byte?

See <function-io> in the help output below.

$ _output/bin/linux_arm64/xfn run negz/xfn-nop:latest ~/fnio.yaml moo
Usage: crossplane run <image> <function-io> ...

Run a Composition Function.

Arguments:
  <image>              OCI image to run.
  <function-io> ...    YAML encoded FunctionIO to pass to the function.

Flags:
  -h, --help                   Show context-sensitive help.
  -d, --debug                  Print verbose logging statements.
  -v, --version                Print version and quit.

  -c, --cache-dir="/xfn"       Directory used for caching function images and containers.
      --timeout=30s            Maximum time for which the function may run before being killed.
      --map-root-uid=100000    UID that will map to 0 in the function's user namespace. The following 65336 UIDs must be available. Ignored if xfn does not have CAP_SETUID and CAP_SETGID.
      --map-root-gid=100000    GID that will map to 0 in the function's user namespace. The following 65336 GIDs must be available. Ignored if xfn does not have CAP_SETUID and CAP_SETGID.
// Command runs a Composition function.
type Command struct {
	CacheDir   string        `short:"c" help:"Directory used for caching function images and containers." default:"/xfn"`
	Timeout    time.Duration `help:"Maximum time for which the function may run before being killed." default:"30s"`
	MapRootUID int           `help:"UID that will map to 0 in the function's user namespace. The following 65336 UIDs must be available. Ignored if xfn does not have CAP_SETUID and CAP_SETGID." default:"100000"`
	MapRootGID int           `help:"GID that will map to 0 in the function's user namespace. The following 65336 GIDs must be available. Ignored if xfn does not have CAP_SETUID and CAP_SETGID." default:"100000"`

	Image      string `arg:"" help:"OCI image to run."`
	FunctionIO []byte `arg:"" help:"YAML encoded FunctionIO to pass to the function." type:"filecontent"`
}

negz avatar Dec 22 '22 06:12 negz

Yes that's exactly the problem!

alecthomas avatar Dec 23 '22 07:12 alecthomas

Is there a way to instruct Kong to only accept a single argument for a []byte field?

raxod502 avatar Mar 29 '23 04:03 raxod502

If you use kong.FileContentFlag as the type it'll correctly identify it and not add the "..." - it's an alias for []byte.

shakefu avatar Oct 11 '23 00:10 shakefu

I am also confused what is the difference between filecontent and kong.FileContentFlag? Currently it looks the same, but filecontent appends .... So I assumed that filecontent works with string then, but this is also not the case?

I suggest filecontent is made to work with string field while kong.FileContentFlag is used when you need []byte field. Then also there will be no issue with ....

mitar avatar Aug 03 '24 05:08 mitar