TritonDataCenter / node-triton

Triton client tool and node.js library
56 stars 40 forks source link

profiles name mismatch #19

Closed bahamas10 closed 9 years ago

bahamas10 commented 9 years ago
$ cat ~/.triton/profiles.d/foo.json | json name
e3b
$ triton profiles
NAME  CURR  ACCOUNT               URL
env   *     dave.eddy@joyent.com  https://us-east-3b.api.joyent.com
foo         dave.eddy@joyent.com  https://us-east-3b.api.joyent.com

it uses the filename and not the name field... perhaps "name" is redundant?

trentm commented 9 years ago

it should be an error if 'name' is in the JSON file then I.e. be strict

I don't want split brain there

trentm commented 9 years ago

New example behaviour with stricter validation of these profile files:

[2015-09-10T00:25:36.989Z]  WARN: triton/59744 on danger0.local: error loading profile; skipping (profilePath=/Users/trentm/.triton/profiles.d/ams1.json, err.code=Config)
    ConfigError: error in "ams1" profile: /Users/trentm/.triton/profiles.d/ams1.json: file must not include "name" field
        at ConfigError.TritonError (/Users/trentm/joy/node-triton/lib/errors.js:38:12)
        at new ConfigError (/Users/trentm/joy/node-triton/lib/errors.js:73:17)
        at _profileFromPath (/Users/trentm/joy/node-triton/lib/config.js:232:15)
        at Object.loadAllProfiles (/Users/trentm/joy/node-triton/lib/config.js:268:27)
        at CLI._listProfiles (/Users/trentm/joy/node-triton/lib/do_profiles.js:31:31)
        at CLI.do_profiles (/Users/trentm/joy/node-triton/lib/do_profiles.js:155:5)
        at CLI.dispatch (/Users/trentm/joy/node-triton/node_modules/cmdln/lib/cmdln.js:744:13)
        at /Users/trentm/joy/node-triton/node_modules/cmdln/lib/cmdln.js:434:18
        at CLI.init (/Users/trentm/joy/node-triton/node_modules/cmdln/lib/cmdln.js:555:5)
        at CLI.init (/Users/trentm/joy/node-triton/lib/cli.js:227:26)
NAME         CURR  ACCOUNT     URL
coal-trentm        trentm      https://10.88.88.3
east1              trent.mick  https://us-east-1.api.joyent.com
...

or, e.g.:

$ triton profiles 2>&1 | bunyan
[2015-09-10T04:20:32.921Z]  WARN: triton/60218 on danger0.local: error loading profile; skipping (profilePath=/Users/trentm/.triton/profiles.d/ams1.json, err.code=Config)
    ConfigError: extraneous fields in "ams1" profile: /Users/trentm/.triton/profiles.d/ams1.json: foo
        at ConfigError.TritonError (/Users/trentm/joy/node-triton/lib/errors.js:38:12)
        at new ConfigError (/Users/trentm/joy/node-triton/lib/errors.js:73:17)
        at _validateProfile (/Users/trentm/joy/node-triton/lib/config.js:85:15)
        at _profileFromPath (/Users/trentm/joy/node-triton/lib/config.js:258:5)
        at Object.loadAllProfiles (/Users/trentm/joy/node-triton/lib/config.js:288:27)
        at CLI._listProfiles (/Users/trentm/joy/node-triton/lib/do_profiles.js:31:31)
        at CLI.do_profiles (/Users/trentm/joy/node-triton/lib/do_profiles.js:155:5)
        at CLI.dispatch (/Users/trentm/joy/node-triton/node_modules/cmdln/lib/cmdln.js:744:13)
        at /Users/trentm/joy/node-triton/node_modules/cmdln/lib/cmdln.js:434:18
        at CLI.init (/Users/trentm/joy/node-triton/node_modules/cmdln/lib/cmdln.js:555:5)
NAME         CURR  ACCOUNT     URL
coal-trentm        trentm      https://10.88.88.3
east1              trent.mick  https://us-east-1.api.joyent.com
...