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

Adds version output parsing #7

Merged
merged 1 commit into from
Jul 21, 2020
Merged

Adds version output parsing #7

merged 1 commit into from
Jul 21, 2020

Conversation

paultyng
Copy link
Contributor

No description provided.

+ provider.null v2.1.2

Your version of Terraform is out of date! The latest version
is 0.12.26. You can update by downloading from https://www.terraform.io/downloads.html
Copy link
Member

Choose a reason for hiding this comment

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

I think the note could be suppressed by disabling checkpoint when running under test, which would make the tests less fragile.

Copy link
Member

Choose a reason for hiding this comment

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

And perhaps we should even disable checkpoint for version commands by default as the advice is ignored and it's not shown to the end-user anyway?

Copy link
Member

@kmoe kmoe left a comment

Choose a reason for hiding this comment

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

Couple of comments and trivial merge conflict.

This PR can be a test of #12 once CI is set up - then it can land in v0.2.0.

Thanks!

tfexec/version.go Outdated Show resolved Hide resolved
// Version returns structured output from the `terraform version` command including both the Terraform CLI version
// and any initialized provider versions.
func (tf *Terraform) Version(ctx context.Context) (tfVersion *version.Version, providerVersions map[string]*version.Version, err error) {
// TODO: support re-invocation of this?
Copy link
Member

Choose a reason for hiding this comment

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

I think Version() should always invoke terraform version - tfexec is intended as a way to invoke terraform CLI commands as transparently as possible.

If the consumer wants the cached versions, they can read the fields from the Terraform struct.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with Katy here, I think that any caching responsibility should be up to the consumer, even if it's consumer within terraform-exec itself. e.g. I assume at some point we may need to cache and/or transparently expose the version here

err := runTerraformVersion(terraformPath)
if err != nil {
return "", fmt.Errorf("executable found at path %s is not terraform: %s", terraformPath, err)
}

but any such caching/exposure decision should be made within that package, keeping tfexec itself simple and transparent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I agree (about re-invocation at least, I dislike a field for this, will put a new commit together with thoughts).

Especially now that this is more info than just the tf version (provider versions), re-invocation is much more useful.

@kmoe kmoe added this to the v0.2.0 milestone Jul 3, 2020
@paultyng paultyng changed the base branch from master to tfexec-remove-discovery July 7, 2020 23:06
@paultyng paultyng changed the base branch from tfexec-remove-discovery to master July 7, 2020 23:06
@paultyng
Copy link
Contributor Author

paultyng commented Jul 7, 2020

Rebased and pulled in your work in #16

@paultyng
Copy link
Contributor Author

@kmoe rebased and added runtime tests for 0.11, 0.12, and 0.13.

@paultyng
Copy link
Contributor Author

The wintest failure is Go 1.12 it seems.

@kmoe
Copy link
Member

kmoe commented Jul 13, 2020

Yes, the Windows executor is using Go 1.12. It seems it's not happy with the use of %w.

@paultyng paultyng modified the milestones: v0.3.0, v0.4.0 Jul 19, 2020
kmoe
kmoe previously approved these changes Jul 20, 2020
Copy link
Member

@kmoe kmoe left a comment

Choose a reason for hiding this comment

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

Please rebase following #37. Once CI passes we can merge.

@paultyng
Copy link
Contributor Author

All 🟢!

@paultyng paultyng merged commit 16b2ac2 into master Jul 21, 2020
@paultyng paultyng deleted the version branch July 21, 2020 13:48
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.

3 participants