Giter Site home page Giter Site logo

Comments (10)

strowi avatar strowi commented on September 25, 2024 3

Hi, just wanted to leave my 2ct here:
Using Gitlab for ci/cd.
Gitlab allows specifying a cache from the build-dir (has to be withing the build-dir!).
It would be very helpful if there was a cli-parameter to allow changing ~/.terraform.versions/ to e.g. $PWD/.terraform.versions.
This way the executables could be cached via Gitlabs mechanism, and there is no/less need to download these from external ressources in every pipeline.

In gitlab-ci.yml this would look sth like this;

.plan:
  stage: plan
  allow_failure: false
  cache:
    key: "${CI_COMMIT_REF_SLUG}"
    paths:
      - ${CI_PROJECT_PATH}/.terraform.versions
  script:
    - tfswitch -cache=$CI_PROJECT_PATH/.terraform.versions
    - terraform init
    - terraform validate
...

from terraform-switcher.

warrensbox avatar warrensbox commented on September 25, 2024
  1. Are you running tfswitch -b $HOME/bin/terraform or tfswitch -b $HOME/bin ?
  2. Do you have permission to write to the $HOME/bin directory (what do you see when you run ls -l on $HOME?

from terraform-switcher.

strowk avatar strowk commented on September 25, 2024
  1. both give same result
  2. I am owner of $HOME/bin:
whoami
tim

ls -la $HOME | grep ' bin'
drwxrwxr-x  3 tim  tim   4096 Dez 14 16:50 bin

Note:

I've uninstalled tfswitch installed using Troubleshooting guilde and installed snap package again to reproduce it again

from terraform-switcher.

strowk avatar strowk commented on September 25, 2024

From what I see here
https://snapcraft.io/docs/home-interface
https://forum.snapcraft.io/t/access-to-specific-hidden-file-path-in-users-home/6948
it looks like

  1. problem is in ~/.terraform.versions
  2. snap does not allow to use hidden (dot-prefixed) dirs in home

So either tfswitch in snap package should automatically use different folder (maybe ~/snap/tfswitch ? I see this folder has been created by snap) or at least allow to customize it.

from terraform-switcher.

warrensbox avatar warrensbox commented on September 25, 2024

@strowk perhaps I can allow users to customize it.
Thank you for bringing this up. I will find some time to do this before the end of the year. Hopefully, I can release this fix in January.
In the source code: -

getInstallLocation() //only downloads the terraform bins into the home directory in .terraform.versions
.
.
.
installLocation = usr.HomeDir + installPath //where installPath = "/.terraform.versions/"

I can make this getInstallLocation() customizable where users can provide a location for all terraform binaries. Again, I can only get to this by the end of the year. If you know go and would like to contribute, I would be happy to review and merge your code as well.

I will let you know once I have implemented this. Thank you for bringing this up.

from terraform-switcher.

strowk avatar strowk commented on September 25, 2024

Just want to add one note here - I see it would go better if either there would be note in installation doc and in description here https://snapcraft.io/tfswitch , that snap package requires additional configuration, or binary should somehow understand that it's running as a snap package and change path automatically. Otherwise everyone who install snap package would found themselves in this issue :)

I suspect that detection run from snap should not be very hard. Probably checking any of these env vars would do - https://snapcraft.io/docs/environment-variables

For example SNAP_USER_COMMON seems very convenient for this task -

Directory for user data that is common across revisions of a snap.

Basically it seems that following algo would work nicely -

  1. if custom location is set - use it
  2. else check if SNAP_USER_COMMON is set. If set - use it plus /.terraform.versions/
  3. else use usr.HomeDir plus /.terraform.versions/

I can try to do it, does not look very hard

from terraform-switcher.

applike-ss avatar applike-ss commented on September 25, 2024

Is there any progress on this? I would actually like to use a snap version of tfswitch 👍

from terraform-switcher.

warrensbox avatar warrensbox commented on September 25, 2024

I am requesting snapcraft for access to user home:
https://forum.snapcraft.io/t/request-interface-personal-files-read-write/25277/3

If you all can upvote the issue, it would be great!

from terraform-switcher.

toast-gear avatar toast-gear commented on September 25, 2024

I also have a need to be able to set a custom the location for the .terraform.versions directory not related to snap.

from terraform-switcher.

strowi avatar strowi commented on September 25, 2024

any progress on this one?

from terraform-switcher.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.