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

ADD OpenTofu support #411

Closed
wants to merge 1 commit into from
Closed

Conversation

orbitz
Copy link

@orbitz orbitz commented Oct 6, 2023

This adds support for OpenTofu. I have not added tests yet.

The major change is an environment variable called TFENV_ENGINE which can be explicitly specified or is automatically determined based on heuristic of version file names.

Copy link

@JonZeolla JonZeolla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest making this backwards compat to start and move to a breaking change in the future after opentofu support is stable

elif [ "${#terraform_version_dir}" -lt "${#tofu_version_dir}" ]; then
echo "tofu"
else
echo "terraform"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only doing a phone review but is this falling back to terraform if autodetect fails? If so, I'm in favor

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JonZeolla Yep, exactly.


TFENV_VERSION_SOURCE='TFENV_TOFU_VERSION';
else
log 'error' "Could not determine version. Engine set to ${TFENV_ENGINE}, make sure version files correspond to this or specify TFENV_ENGINE environment variable"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest making this a warning and fallback to terraform/backwards compatibility

elif [ "${TFENV_ENGINE}" = "tofu" ] && [ -n "${TFENV_TOFU_VERSION:-""}" ]; then
version_source='TFENV_TOFU_VERSION';
else
log 'error' "Could not determine version. Engine was determined to be ${TFENV_ENGINE}, ensure version files match that engine"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning instead of error?

remote_versions="$(curlw -sSf "${TFENV_REMOTE}/terraform/")" \
|| log 'error' "Failed to download remote versions from ${TFENV_REMOTE}/terraform/";

#log 'debug' "Remote versions available: ${remote_versions}"; # Even in debug mode this is too verbose

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove if unused?

@JonZeolla
Copy link

Also I'm willing to test this just give me until next week if interested

@orbitz
Copy link
Author

orbitz commented Oct 7, 2023

@JonZeolla Thanks for the feedback. I'll fix and push. If you have time to test it, much appreciated.

@JonZeolla
Copy link

@orbitz I am slowly working through this in SeisoLLC/easy_infra#299 in my spare time; feedback welcome if you see that I am not following how you expected this to work. I will bring questions/issues here as I work through them

@JonZeolla
Copy link

LGTM

@orbitz
Copy link
Author

orbitz commented Nov 16, 2023

@JonZeolla Do you know what's necessary to get this merged in?

@JonZeolla
Copy link

@orbitz no, sorry. I just know that I tested with both terraform and tofu and this branch seems to check out. For the time being, I am (unfortunately) just pinning my project to the opentofu fork and branch

@joshpollara
Copy link

@Zordrak are you able to help get this merged?

@OJFord OJFord mentioned this pull request Nov 28, 2023
@joshpollara
Copy link

@jack-parsons-bjss ping!

@Zordrak
Copy link
Collaborator

Zordrak commented Dec 19, 2023

Rejected :: #409 (comment)

@Zordrak Zordrak closed this Dec 19, 2023
@kvendingoldo
Copy link

Hello there,
Tofuenv's first stable release (v1.0) is now available! tofuenv is a fork of tfenv that only works with OpenTofu binaries. Our crew (me, @anastasiiakozlova245, @Nmishin) has been working on the fork over the past week. We worked hard to improve the usability of core tofuenv features, add some new capabilities, and, of course, fix a few bugs in the original tfenv program.

We'd appreciate your input and support on GitHub. Please feel free to submit issues and make contributions. Link to tofuenv: https://github.com/tofuutils/tofuenv

tofuenv can be installed manually from GitHub or via brew (for mac users).

@kvendingoldo
Copy link

Hi folks,
The tofuutils crew is dropping new tool for managing Terraform/OpenTofu: tenv!

tenv, is Golang based application, that means that you don't depend on shell or other environment dependencies anymore.

We encourage you to make use of it, share any issues you encounter, and even contribute to its improvement. Your support and stars ⭐️ would be greatly appreciated! We're all ears for your feedback!

We saved all tfenv features and added some new. It's an active, not dead development. We'll be glad to hear your wishes about new features and implement them in next releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants