node-triton icon indicating copy to clipboard operation
node-triton copied to clipboard

`-o field,field,...` should be strict about allowed fields

Open trentm opened this issue 9 years ago • 4 comments

Currently it just silently fails, e.g.:

$ triton insts -o name,primaryip,package
NAME                                        PRIMARYIP  PACKAGE
nagios01                                    -          t4-standard-2G
rsyslog                                     -          t4-standard-2G
elk_logstash_1                              -          t4-standard-1G

because it is primaryIp, not primaryip.

Compare to:

[root@headnode (nightly-1) ~]# zfs list -o name,used,foobar
bad property list: invalid property 'foobar'
usage:
        list [-Hp] [-r|-d max] [-o property[,...]] [-s property]...
            [-S property]... [-t type[,...]] [filesystem|volume|snapshot] ...

The following properties are supported:

        PROPERTY       EDIT  INHERIT   VALUES

        available        NO       NO   <size>
...

trentm avatar Feb 05 '16 20:02 trentm

On 2/5/16 12:28 , Trent Mick wrote:

Currently it just silently fails, e.g.:

$ triton insts -o name,primaryip,package
NAME                                        PRIMARYIP  PACKAGE
nagios01                                    -          t4-standard-2G
rsyslog                                     -          t4-standard-2G
elk_logstash_1                              -          t4-standard-1G

because it is primaryIp, not primaryip.

Though if this ends up being that common a typo, perhaps we should be doing a case insensitive comparison on property names here in addition to the fatal erroring when passing something like foobar.

Compare to:

[root@headnode (nightly-1) ~]# zfs list -o name,used,foobar
bad property list: invalid property 'foobar'
usage:
        list [-Hp] [-r|-d max] [-o property[,...]] [-s property]...
            [-S property]... [-t type[,...]] [filesystem|volume|snapshot] ...

The following properties are supported:

        PROPERTY       EDIT  INHERIT   VALUES

        available        NO       NO   <size>
...

rmustacc avatar Feb 05 '16 21:02 rmustacc

I agree with @rmustacc on this. I can't imagine a situation where casing would be the differentiating factor for key names. Case insensitive matching + error on unknown fields would be good here.

bahamas10 avatar Feb 26 '16 23:02 bahamas10

It may contribute 'tabula'
https://github.com/trentm/node-tabula/blob/master/lib/tabula.js

how can i contribute this ?

YangYong3 avatar Mar 07 '17 01:03 YangYong3

@YangYong3 You could create a pull request against that repo to add a "caseInsensitiveLookup: true" option to node-tabula.

trentm avatar Mar 07 '17 20:03 trentm