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

fcli tool: Recognize cached tool installations #675

Open
rsenden opened this issue Jan 30, 2025 · 0 comments
Open

fcli tool: Recognize cached tool installations #675

rsenden opened this issue Jan 30, 2025 · 0 comments
Labels
effort:low Easy to implement/fix enhancement New feature or request fcli-tool Issue related to 'fcli tool' commands prio:medium Medium priority

Comments

@rsenden
Copy link
Contributor

rsenden commented Jan 30, 2025

Enhancement Request

Some CI systems allow for caching tool installations, however such cached installations may not be recognized by fcli as being a previously installed tool.

For example, suppose a CI pipeline invokes fcli tool <tool> install -v x.y --install-dir <directory cached by CI>. The first pipeline run will install the tool and it will be cached by the CI system. On the next pipeline run, the fcli state data from the first run is likely lost, so fcli isn't aware of this tool installation. So, if the tool install command is run by the second pipeline run, fcli will detect that the installation directory already exists (as it was cached by the CI system), and thus the tool install command will fail (if no -y option is specified), or delete the cached installation directory and re-install the tool (if -y option is specified).

We can easily work around this issue by copying the tool installation descriptor JSON file into the tool installation directory. In the scenario above, if the tool install command detects that the installation directory already exists, it can check whether it contains the tool installation descriptor, and if so:

  • Don't throw an error or do a re-installation, but just use the existing installation, i.e., same behavior as if the installation descriptor existed in the fcli state directory
  • Copy that installation descriptor into the fcli state folder to allow other fcli tool commands to detect this installation

For this to work, we need to know the tool name and version that's installed in the installation directory, both to detect that the installation directory contains the same tool & version as what the user is trying to install (otherwise we should still fail/overwrite), and because we need tool name and version when copying the descriptor into the fcli state directory. However, the descriptor itself currently doesn't include the tool name and version, so we can either:

  • Add these properties to the tool descriptor
  • Include the tool name & version in the tool descriptor file name in the tool installation directory, for example fcli-tool-descriptor-<tool-name>-<tool-version>
  • Include the tool name & version in the tool descriptor path in the tool installation directory, for example fcli-tool-descriptor/<tool-name>/<tool-version> or maybe fcli-state/<tool-name>/<tool-version>

I think the latter option is best, sticking to the same directory structure as in the fcli state directory for consistency. If the fcli tool <tool> install -v <version> --install-dir <target> command detects that <target> already exists, we can simply check whether fcli-tool-descriptor/<tool>/<version> exists. If so, <target> matches the tool name and version that the user is trying to install, thus we don't need to re-install. If it doesn't exist, either the target directory doesn't contain an fcli tool installation, or the user is trying to install a different tool or version in an existing fcli tool installation directory. In both cases, we would either fail or delete & install into the target directory, depending on presence of -y option.

@rsenden rsenden added effort:low Easy to implement/fix enhancement New feature or request fcli-tool Issue related to 'fcli tool' commands prio:medium Medium priority labels Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort:low Easy to implement/fix enhancement New feature or request fcli-tool Issue related to 'fcli tool' commands prio:medium Medium priority
Projects
None yet
Development

No branches or pull requests

1 participant