-
Notifications
You must be signed in to change notification settings - Fork 1.5k
data: Allow Terraform module bundling via vfsgen #332
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
Conversation
Based on [1]. Generate at release-time with:
$ go generate ./data/
I've swapped [1]'s tag from 'dev' to 'release' (with the opposite
sense) because we're not going to commit the autogenerated content to
the repository ('go get' support is not worth version-controlling
machine-generated code).
Because dev builds load the data at runtime (instead of compiling it
in at build time), I've added an environment variable to fill the role
of the previous terraform.BaseLocation.
[1]: https://github.com/shurcooL/vfsgen/blob/33ae1944be3fe078a54c597f107e0867da19c713/README.md#go-generate-usage
I've pushed 6af70ec7bab0b21aa69a495d97ae6d6b4a0df4c9 as an ugly hack to work around this until something like openshift/release#1677 lands. |
f193a29 to
a40d944
Compare
When we build releases. Generated with: $ glide get --strip-vendor github.com/shurcooL/vfsgen $ glide-vc --use-lock-file --no-tests --only-code $ bazel run //:gazelle ... gazelle: /home/trking/.local/lib/go/src/github.com/openshift/installer/vendor/github.com/libvirt/libvirt-go/callbacks_wrapper.go: error reading go file: /home/trking/.local/lib/go/src/github.com/openshift/installer/vendor/github.com/libvirt/libvirt-go/callbacks_wrapper.go: pkg-config not supported: #cgo pkg-config: libvirt ... using: $ glide --version glide version 0.13.2-dev $ (cd $GOPATH/src/github.com/Masterminds/glide && git describe) v0.13.1-7-g3e13fd1 $ (cd $GOPATH/src/github.com/sgotti/glide-vc && git describe) v0.1.0-2-g6ddf6ee $ bazel version Build label: 0.17.2- (@Non-Git) Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar Build time: Fri Sep 21 15:04:25 2018 (1537542265) Build timestamp: 1537542265 Build timestamp as int: 1537542265 I'm ignoring the pkg-config issues for now, because we're about to drop Bazel.
Default to 'release' to make life easier for openshift/release, and because a release build will work more reliably (the Terraform assets are always there, they're just harder to change).
This will keep the old installer working until we can get openshift/release switched over to openshift-install. Once we do, we can revert this commit.
But smoke passed, so /retest |
So this is required always? :/ |
| @@ -0,0 +1,336 @@ | |||
| terraform { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data/data smells :) can it be data/terraform ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data/data smells :) can it be data/terraform ?
It could, but anything that doesn't need to be dynamically templated can live in here. I thought we might want to use this approach for some of our manifests and such, as long as they didn't need templating. But I'm fine calling the directory whatever for the short-term, and sorting the rest out later. Thoughts?
| var Assets http.FileSystem | ||
|
|
||
| func init() { | ||
| dir := os.Getenv("OPENSHIFT_INSTALL_DATA") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use GOPATH to set reasonable default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use GOPATH to set reasonable default?
Maybe? But that will break in Go 1.11 when we move to modules and toss out GOPATH ;). Maybe export a default in your ~/.bashrc or whatever? Or compile it in?
No, you could run from the |
| } | ||
|
|
||
| if info.IsDir() { | ||
| os.Mkdir(base, 0777) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it have to be 0777?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it have to be 0777?
It doesn't have to be, but this is generic, and your umask will reduce it to whatever you feel is reasonable.
| @@ -1 +0,0 @@ | |||
| ../../../config.tf No newline at end of file | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we keep the symlink?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we keep the symlink?
We might be able to, but we don't need it for openshift-install (only one step :), and I wasn't sure how well http.FileSystem handled symlinks.
| } | ||
|
|
||
| // take advantage of the new installer only having one step. | ||
| err = os.Rename(filepath.Join(tmpDir, "config.tf"), filepath.Join(templateDir, "config.tf")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this happen in Unpack?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this happen in
Unpack?
Unpack is generic, just dump the http.FileSystem to disk. This is specific to the content that we happen to stick into Unpack. And I was going to shuffle this around later, and not bother to write the step that we don't need (e.g. only unpack modules and steps/infra/aws for AWS). But I hadn't worked that up yet.
| @@ -0,0 +1,51 @@ | |||
| # Bootstrap Module | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you combine this with 5c536a2 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you combine this with 5c536a2 ?
Yes. I made 2ac5913 a separate commit so I could revert it once openshift/release#1677 lands. But I can squash them if you like. Thoughts?
|
/lgtm |
|
Let's just get this thing in to remove the deadlock between this repo and openshift/release. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: abhinavdahiya, wking The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Dunno why GitHub says golint is sad; Prow says it's happy. /test golint |
|
/refresh |
The new
datapackage works two ways:For devs, it loads the Terraform modules (now under
data/data) from the disk. If you execute your installer from a directory other thandata(i.e. most of the time), you should setOPENSHIFT_INSTALL_DATAto point at thedata/datadirectory. That makes it easy to adjust the static files during development, because there's no need to rebuild after a tweak.For users, we compile the Terraform modules into the executable. That makes it easy to distribute the file (no separate pieces or wrapping tarball).
This is very similar to #329. The differences are:
asset/cluster: include templates in binary #329 always extracts from the tarball. There's no "load from the disk at runtime" workflow.
I'm vendoring a different package ;).
The compiled-in binaries are slightly different sizes. As of my b740463d688:
Compared with asset/cluster: include templates in binary #329's:
But <2 MB isn't a large percentage change, so this is probably a wash.
I've broken the old installer by shifting its Terraform modules around, deleting symlinks, etc.
Dev builds look like:
$ CGO_ENABLED=0 go build ./cmd/openshift-installwith invocations like:
$ OPENSHIFT_INSTALL_DATA=data/data OPENSHIFT_INSTALL_CLUSTER_NAME=wking-testing ... ./openshift-install --dir wking --log-level debug clusterRelease builds look like:
and the invocation is the same except you don't need to bother with
OPENSHIFT_INSTALL_DATA.CC @crawford