Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filecontent argument fields appear to accept multiple arguments #346

Open
negz opened this issue Dec 22, 2022 · 4 comments
Open

filecontent argument fields appear to accept multiple arguments #346

negz opened this issue Dec 22, 2022 · 4 comments

Comments

@negz
Copy link

negz commented Dec 22, 2022

I just updated to the latest commit (919e701) 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 negz changed the title Argument fields of type:"filecontent appear to accept multiple arguments filecontent argument fields appear to accept multiple arguments Dec 22, 2022
@alecthomas
Copy link
Owner

Yes that's exactly the problem!

@raxod502
Copy link
Contributor

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

@shakefu
Copy link

shakefu commented Oct 11, 2023

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

@mitar
Copy link
Contributor

mitar commented Aug 3, 2024

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 ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants