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

Replace go-bindata by vfsgen #4430

Merged
merged 17 commits into from
Aug 24, 2018
Merged

Conversation

simonpasquier
Copy link
Member

Closes #2411.

Looking at https://tech.townsourced.com/post/embedding-static-files-in-go/ (which was mentioned in the issue), vfsgen has all the needed features.

In particular:

  • Reproducible builds (no issue with timestamping).
  • Well maintained and relatively popular.
  • Integration with go generate.
  • Self-contained (no external dependency).

@grobie
Copy link
Member

grobie commented Jul 27, 2018

With go generate support, there isn't any need anymore to check in the generated files, right? That would remove the need to remind contributors to run make assets in pull requests.

@simonpasquier
Copy link
Member Author

@grobie I'm not sure. AFAICT it is more a personal preference: some projects like kubernetes still commit all the generated code. I don't have any personal preference though.

@simonpasquier simonpasquier changed the title [WIP] Replace go-bindata by vfsgen Replace go-bindata by vfsgen Jul 30, 2018
@simonpasquier simonpasquier force-pushed the vfsgen-poc branch 2 times, most recently from 983aa5a to fe42e80 Compare August 7, 2018 14:21
@simonpasquier
Copy link
Member Author

@brian-brazil can you have a look?

web/ui/README.md Outdated
This will put `go-bindata` in DEBUG mode where it serves from your local filesystem.
To make this work, add `-tags dev` to the `flags` entry in `.promu.yml`, and then `make build`.

This will serves all files from your local filesystem.
Copy link
Contributor

Choose a reason for hiding this comment

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

serve

Makefile Outdated
cd $(PREFIX)/web/ui && go generate

$(VFSGENDEV):
cd $(PREFIX)/vendor/github.com/shurcooL/vfsgen/ && go install ./cmd/vfsgendev/...
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we should be modifying the user's environment like this

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point. I've replaced vfsgenby a custom helper program that does the same (just a couple of lines).

Makefile Outdated
@$(GO) get -u github.com/jteeuwen/go-bindata/...
@go-bindata $(bindata_flags) -pkg ui -o web/ui/bindata.go -ignore '(.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)' web/ui/templates/... web/ui/static/...
@$(GO) fmt ./web/ui
$(GO) get -u github.com/shurcooL/vfsgen
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still needed given its vendored?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. I have removed it from vendor/ in the last version because otherwise govendor ilst +unused complains that it isn't used.

Copy link
Contributor

Choose a reason for hiding this comment

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

That doesn't sound right, assets_generate.go is referencing it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Using a blank import has made govendor happy.

@brian-brazil
Copy link
Contributor

👍

@grobie
Copy link
Member

grobie commented Aug 22, 2018

AFAICT it is more a personal preference: some projects like kubernetes still commit all the generated code. I don't have any personal preference though.

I'm not aware that anyone is actively reviewing the code generated by go-bindata / vfsgen, so I don't see a use case for actually checking in that file. As it's now possible to easily generate the files during compilation time on-the-fly, I'd vote to remove the need to ask every contributor to remember executing make assets.

@simonpasquier
Copy link
Member Author

I'd vote to remove the need to ask every contributor to remember executing make assets

@brian-brazil @juliusv what are your views on this?

@brian-brazil
Copy link
Contributor

If we've gotten the system to a place where it's no longer required, I see no issue with removing it.

@grobie
Copy link
Member

grobie commented Aug 22, 2018

Ah, now I remember the issue with go generate, it's not part of go build, so one couldn't longer do go get github.com/prometheus/prometheus/cmd/prometheus to install Prometheus. In that case, maybe leave it as it is right now @simonpasquier.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This avoids installing vfsgendev in the target environment.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
@simonpasquier
Copy link
Member Author

@grobie yep it seems to be the less disruptive way for now. Also when the generated code isn't committed, we need to add the assets prerequisite to a few targets (eg build, test, ...) as well as modify the CircleCI and Travis CI configurations.

@simonpasquier
Copy link
Member Author

@grobie @brian-brazil are you ok merging this? I'll take of migrating AlertManager and Pushgateway too.

@brian-brazil
Copy link
Contributor

I already gave a +1

@grobie grobie merged commit 3581377 into prometheus:master Aug 24, 2018
@grobie
Copy link
Member

grobie commented Aug 24, 2018

Thanks, great work @simonpasquier!

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

3 participants