tofuenv icon indicating copy to clipboard operation
tofuenv copied to clipboard

[tfswitch-parity] Auto-install if a .tf file contains a Terraform `required_version` block

Open skyzyx opened this issue 1 year ago • 8 comments

Please replicate this feature from tfswitch. https://tfswitch.warrensbox.com/Quick-Start/#use-versiontf-file

skyzyx avatar Jan 05 '24 22:01 skyzyx

@skyzyx looks great! We'll take it to work

kvendingoldo avatar Jan 07 '24 13:01 kvendingoldo

Hi, I am working on a a golang rewrite : https://github.com/dvaumoron/gotofuenv

The tofu proxy of gotofuenv default behaviour is latest-allowed, with a fallback to latest-stable if no required_version from .tf files are found.

I would appreciate a chat to pool our effort together...

dvaumoron avatar Jan 11 '24 13:01 dvaumoron

Hi @dvaumoron. Your projects looks great. We had the same in our plans, because bash-based application is not a good idea for different operation systems. Some time ago we started to work on tenv (https://github.com/tofuutils/tenv) application that should be able to manage Terraform and OpenTofu versions. We kicked off it on golang and I think that it would be better to work on it together to reduce amount of Terraform/OpenTofu wrappers.

At this moment tenv is just a wrapper for tfenv and tofuenv, but we had in out plan to rewrite all logic into Golang.It would be fantastic if you'd contribute to 'tenv' instead of creating another wrapper. It will allow us to release a stable version of the 'tenv' utility more quickly.

Let's make a new generation of Terraform/OpenTofu version switcher based on Golang together.

kvendingoldo avatar Jan 11 '24 14:01 kvendingoldo

gotofuenv is functional (currently only tested on linux/amd64 with .deb installation or brew installation). That's not a wrapper but a pair of standalone executable (the tofu proxy and gotofuenv cli)

However it lack Terraform retrieval support, and adding a bunch of automated test would be great.

dvaumoron avatar Jan 11 '24 14:01 dvaumoron

@dvaumoron tenv is also designed not as wrapper, but as a in-depended binary program for managing OpenTofu as well as Terraform.

For now I made a rough implementation that is a Golang wrapper under tfenv/tofuenv, but it was made to reduce release date. We are going to make tenv independent soon.

It would be good to merge your gotofuenv into tenv. By that OpenTofu/Terraform community have just a one tool in the near future to manage versions.

kvendingoldo avatar Jan 11 '24 14:01 kvendingoldo

I take a look on tenv, i am unsure about the best way to integrate my work in it

dvaumoron avatar Jan 11 '24 14:01 dvaumoron

If i separate my initCmds from main package of gotofuenv, it will be callable to be added as subcommand, but that's quick and dirty mode, it will leave duplication (your package to call github api does not work the same as mine) and inconsistencies (i do not use logrus for my display)

dvaumoron avatar Jan 11 '24 15:01 dvaumoron

@dvaumoron it will be good for the beginning. In the future we can merge tenv and gotofuenv to one repository and you can take a lead under OpenTofu support in this tool.

Today we gonna post an initial design for main tenv methods, it probably can be a good for the future implementation.

Also, we can disscuss technical details like logrus / github package. It helps us to make our future repositories merge less painfull. I invite you to talk about all of this technical stuff inside of tenv repository.

kvendingoldo avatar Jan 11 '24 15:01 kvendingoldo