`triton profile set NAME` and `TRITON_PROFILE` interaction is confusing
(From a conversation with @STRML on #joyent IRC.)
How a triton invocation determines the profile to use can be confusing. If you use the suggested eval $(triton env) technique to setup one's env for docker usage, one may not realize that the TRITON_PROFILE envvar is being set to the current profile. Subsequent attempts to "set" one's profile with triton profile set NAME will report success, but really you won't get that profile for triton commands because the TRITON_PROFILE envvar will win.
Further possible confusion is how the "env" profile works. The "env" profile automatically exists if one has SDC_ and/or TRITON_{URL|ACCOUNT|...} envvars set. So, in the case above one might not have had an "env" profile in triton profile list ... until eval $(triton env) was run. Now there is this new "env" profile. Are the SDC_ envvars now used by triton commands? The answer is: only if the "env" profile is the current one.
Suggested changes:
triton profile set-current(and itssetshortcut) are misleading. They are really about setting the default profile (if neither of a-p NAMEtop-level option orTRITON_PROFILEenvvar are used to explicitly choose the profile). We should change to theset-defaultname and have hiddensetandset-currentaliases for bwcompat (which we can remove at some later major rev).- The docs in all of
triton profile,triton env -h, andtriton profile set-default -hshould clarify how a profile is selected. triton profile set-default FOOshould emit a warning on stderr if it notices thatTRITON_PROFILEis set or if-p NAMEtop-level opt is used.
We should change to the
set-defaultname and have hiddensetandset-currentaliases for bwcompat
I actually pushed a couple commits that address this over on my fork. I renamed the command and kept the existing set-current and set alias hidden in their own file do_set_current.js for future deprecation.
I'm new around here but I guess I need to send the PR through Gerrit?
@cheapRoc That's right. There's some text in CONTRIBUTING.md about it, which also links to our guide for using the Joyent Gerrit.
@jclulow Thanks, the link to the Joyent Gerrit info was what I overlooked.
Posted to Gerrit.
FWIW My intention wasn't to solve the entire problem today but to at least get something in that might lead to clearing this up for users. Felt the confusion and wanted to see if I could help.
I've got more questions around how the env vars are loaded if that's worth posting here or somewhere else.