vmware-tanzu / tanzu-framework

Tanzu Framework provides a set of building blocks to build atop of the Tanzu platform and leverages Carvel packaging and plugins to provide users with a much stronger, more integrated experience than the loose coupling and stand-alone commands of the previous generation of tools.
Apache License 2.0
197 stars 193 forks source link

Allow overriding installation directory for `tanzu` CLI plugins #447

Open nrb opened 3 years ago

nrb commented 3 years ago

Describe the feature request

Currently, the tanzu CLI only looks in ${XDG_HOME} for plugins, and this location is hardcoded.

For developers iterating on plugins, this means that versions in their local clone will overwrite or conflict with installed GA plugins; only one version of a given plugin can exist on a system at any time.

Ideally, the location for plugins would be configurable, but keep the current default of ${XDG_HOME}. This way, developers can keep GA releases of plugins on their system, as well as in-development binaries.

This has the following benefits:

Describe alternatives you've considered

A few possibilities I can think of for implementation:

Affected product area (please put an X in all that apply)

Additional context

This request mostly comes out of my own frustration in testing GA builds then going back to my own development versions. Having to completely wipe out my installations each time adds time to my inner loop. However, I think the solution to that particular annoyance also provides other benefits for developers and users.

pbarker commented 3 years ago

This is definitely a problem we want to solve. I'm thinking on how this will map into the context aware work, which changes how plugins are stored locally.

Context-aware plugins will need to be namespaced by likely both their repository and version.

Let me try and walk through a use case:

Cluster A has foo plugin at v1.2 Cluster B has foo plugin at v0.9

When I login to Cluster A I want to execute against the v1.2 binary, and if I switch to login to Cluster B I need to execute against the v0.9 binary.

This means we'll need to store these plugins locally as tanzu.repo.com/foo/v1.2 and tanzu.repo.com/foo/v0.9 with a map for the servers on which plugins to use.

With this in mind, I wonder how it may affect our approach to the problem. Could we have a different repo space for local plugins e.g. local/foo/v1.2 or maybe use versions tanzu.repo.com/foo/v1.2-dev?

giri-varma commented 3 years ago

Prefer the local/foo/v1.2 approach since -dev could be used as a pre-release version.

zjs commented 3 years ago

I wonder if (hidden?) --plugin-root and --config-root flags that take directories — with corresponding env vars or config settings — could help with this?

nrb commented 3 years ago

@pbarker Thanks for mentioning the repo space aspect, I honestly didn't think about that. I was more thinking about where things landed on the local machine after install, but it's totally possible that one might want to have a dev vs GA repo configuration as well.

@zjs I think that's reasonable, yes. I'm not sure if we want a full env/config/arg hierarchy for this particular feature, but a config setting that is context-aware like Patrick is mentioning sounds like a good middle ground.

nrb commented 2 years ago

Reviewing the Homebrew script for installing TCE, this is more important than I first realized.

When Homebrew installs a package, it creates a child process that is sandboxed only to /usr/local/Cellar/tce/, and cannot access the user's home directory. @seemiller's implementation writes out an install.sh to the Cellar directory and asks the user to run it before plugins can be used.

We should allow plugins to be located within /usr/local/tce/* so that Homebrew and other package managers can work as they're expected to.