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

releases: support enterprise versions #148

Merged

Conversation

colinodell
Copy link
Contributor

This pull request allows the installation of enterprise versions by supplying an Enterprise bool flag and an optional EnterpriseMeta string field as suggested in #15 (comment).


According to #15 and #16, the ability to download enterprise versions was removed from the public release of this library. It seems this decision was likely made to prevent users from accidentally installing Enterprise versions. However, there are some valid cases folks have the need to automate the downloading of Enterprise versions:

With these proposed changes, users of this library can now opt-in to fetching the Enterprise versions as needed, without negatively impacting the ability for OSS users to continue using the OSS releases.

@hashicorp-cla
Copy link

hashicorp-cla commented Aug 7, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

Hi @colinodell
Thank you for sending the PR in.

This looks like a good start but there is one more aspect of enterprise releases which will need to be reflected before we can merge it in.

All enterprise products should come with two *.txt files - EULA.txt and TermsOfEvaluation.txt in the archive.

After asking internally, I was advised that we'd need to be installing those files somewhere while installing the product binary to alleviate any legal concerns.

This implies some changes:

We can introduce LicenseDir (string) which would be treated as required to let the user to specify where to place the files which contain licensing terms.

Since this brings us to a total of 3 fields related to enterprise, I wonder if it would make sense to instead turn this into a struct, e.g.

type LatestVersion struct {
  Enterprise EnterpriseOptions
}

type EnterpriseOptions struct {
  LicenseDir string // required
  Meta       string // optional
}

The code responsible for the installation would need to be updated to reflect that we need to install more than just a binary.

I see you updated releases.LatestVersion but for consistency we should add support for enterprise products into other parts of the API as well, i.e.

Finally we should probably update the Readme.md to include an example with an enterprise product so that folks know this is supported and how to do it.


I appreciate this may be much more work than you initially planned for, so one of the maintainers (like myself) can probably pick it up and finish the work later if you don't want/intend to. Just let us know.

@colinodell
Copy link
Contributor Author

Thanks for the detailed feedback! It is indeed more work than I had anticipated, but I'd be happy to take it on with your guidance :)

After asking internally, I was advised that we'd need to be installing those files somewhere while installing the product binary to alleviate any legal concerns.
...
We can introduce LicenseDir (string) which would be treated as required to let the user to specify where to place the files which contain licensing terms.

Currently, this PR installs those files into the InstallDir (because of how downloader.DownloadAndUnpack() extracts all files there). So I imagine this implementation would need to check for those license files in InstallDir and move them to LicenseDir. I'll proceed along that path unless you tell me otherwise.

I see you updated releases.LatestVersion but for consistency we should add support for enterprise products into other parts of the API as well

Adding support to the other releases APIs makes sense to me. But in #16 it was mentioned that:

As confirmed internally the Checkpoint API does not reflect Enterprise versioning at all, i.e. it will only ever return OSS versions without the metadata, so that one does not need patching.

Is that still true? If so, I'd propose we avoid touching checkpoint.LatestVersion for now.

@radeksimko
Copy link
Member

Is that still true? If so, I'd propose we avoid touching checkpoint.LatestVersion for now.

I forgot about that entirely. I believe that is still true, so yes we can avoid touching that one. 👌🏻

So I imagine this implementation would need to check for those license files in InstallDir and move them to LicenseDir.

Instead of moving the files I think we could just unpack them directly to the appropriate path, i.e. modify this part of the function you mentioned and check for the filename there before deciding where exactly to copy the file from the archive, so we can avoid the additional I/O

d.Logger.Printf("unpacking %s to %s", f.Name, dstDir)
dstPath := filepath.Join(dstDir, f.Name)
dstFile, err := os.Create(dstPath)
if err != nil {
return pkgFilePath, err
}
_, err = io.Copy(dstFile, srcFile)
if err != nil {
return pkgFilePath, err
}
srcFile.Close()
dstFile.Close()

That means we'll need to introduce one more argument to DownloadAndUnpack, e.g. licenseDir string but the rest should be mostly plumbing in places from where we call DownloadAndUnpack.

With all these changes we shouldn't need to worry about compatibility as we're not changing public interface at all nor changing behaviour of existing surface.

@colinodell colinodell force-pushed the feature/enterprise-versions-in-releases branch from 46a0168 to 93622cc Compare August 28, 2023 15:59
@colinodell
Copy link
Contributor Author

I think I've made all the requested changes - this is ready for re-review!

@colinodell colinodell requested a review from radeksimko August 28, 2023 16:00
Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

Thanks for making all the changes, this is pretty close.

I left mostly minor suggestions and comments. Happy to merge once these are addressed.

releases/enterprise.go Outdated Show resolved Hide resolved
installer_test.go Outdated Show resolved Hide resolved
internal/releasesjson/downloader.go Outdated Show resolved Hide resolved
releases/exact_version.go Outdated Show resolved Hide resolved
releases/latest_version.go Outdated Show resolved Hide resolved
releases/latest_version.go Outdated Show resolved Hide resolved
releases/versions.go Outdated Show resolved Hide resolved
releases/versions.go Outdated Show resolved Hide resolved
releases/enterprise.go Outdated Show resolved Hide resolved
@colinodell colinodell requested a review from radeksimko August 29, 2023 14:58
I'm not entirely sure this is actually necessary or beneficial (from memory consumption perspective) but I'm keeping it as-is as it should do no harm to existing users who do not install enterprise products.
releases/latest_version.go Outdated Show resolved Hide resolved
releases/enterprise.go Outdated Show resolved Hide resolved
@radeksimko radeksimko merged commit 89c9d1a into hashicorp:main Aug 31, 2023
@colinodell
Copy link
Contributor Author

Thanks for your help and guidance here! 🎉

@colinodell colinodell deleted the feature/enterprise-versions-in-releases branch August 31, 2023 13:49
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