-
Notifications
You must be signed in to change notification settings - Fork 43
Changes from statik to go:embed for example and extension templates #129
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
data/extension/init/templates/tinygo/envoy.access_loggers/default/go.mod
Outdated
Show resolved
Hide resolved
4f12463
to
ed15f0d
Compare
One simple workaround could be to serve the go.mod files dynamically in go. This could stay until there's a go.mod solution in go:embed, and still get us off the abandoned library and more complicated build. Each of the go.mod files are identical.
|
might be saved by the bell, as I mistook the root path used in statik. it was 🤞 |
41638e4
to
b9f9e3f
Compare
OK I think the go.mod in the extensions dir seems to be about our lint setup. If all tests pass except lint, it might be a better punch to avoid that lint check vs override go's behavior or rely on codegen. In a bit, I'll raise an issue in go to document the surprising limitation about go.mod files. I can understand how someone could equate presence of go.mod meaning the directory is no longer in the module, but it is surprising enough to have an issue to point to and ideally docs about. |
raised golang/go#45197 on the constraint about go.mod. Not sure if having a need a hand on the lint failure as it isn't consistent running locally. I tried to exclude but guess I got something wrong.
|
The goal of All modern |
Personally, I don't see what features of I earlier said that " Again, I'm just one vote. If other reviewers are fine with it, I won't object. |
The following suggestion seems alright to me, provided we document it golang/go#45197 (comment) basically rename go.mod to go.mod_ We should keep in mind that the file is already templated, so it isn't valid anyway. |
FWIW I'd like to finish #130 before merging this anyway because testing is where I lost most time |
e14979a
to
736fadf
Compare
@@ -0,0 +1,2 @@ | |||
# We rename go.mod to go.mod_ to workaround https://github.com/golang/go/issues/45197 |
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.
@mathetake this will only effect tinygo as I don't expect any other extension language to want a file named go.mod in it.
pkg/extension/init/init.go
Outdated
@@ -102,7 +102,12 @@ func (s *scaffolder) walk(sourceDirName, destinationDirName string) (errs error) | |||
} | |||
|
|||
func (s *scaffolder) visit(sourceDirName, destinationDirName string, sourceFileInfo os.FileInfo) (errs error) { | |||
relOutputFileName := filepath.Join(destinationDirName, sourceFileInfo.Name()) | |||
baseOutputFileName := sourceFileInfo.Name() | |||
// We rename go.mod to go.mod_ to workaround https://github.com/golang/go/issues/45197 |
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.
this is far far easier than writing an FS renamer, especially considering we are already walking the file tree. However, I linked the issue as it is soliciting a library to do that.
good news is the tinygo tests pass now. Not sure about the rust failures haven't looked deeply yet
|
will rebase after #135 and look into adding unit tests that show the templates directory tree isn't empty due to faulty go:embed setup. |
736fadf
to
ad5b724
Compare
pulled the lint thing out to here #138 and will rebase later |
ad5b724
to
cf82e32
Compare
changed merge base to |
Thanks for the tip by @carlmjohnson I didn't realize that dot directories are filtered in go:embed expressions. I renamed Summary is two if statements which would be common to users who understand go:embed pros and cons instead of a codegen phase powered by a fork of a fork. Dirty, but less dirty. |
ps it isn't strictly required to rename the config file to config.toml, but I noticed that the old naming isn't encouraged anymore per https://doc.rust-lang.org/cargo/reference/config.html so fixed it while here. |
155bbde
to
b24f531
Compare
4815a25
to
9781bf8
Compare
I think we're having docker problems. I'll re-kick this tomorrow, but I think the code change is done now. There's a test coverage issue on "getenvoy extension init" which I'll do in a separate PR, so that there's nothing needed here. |
#161 finishes backfilling the tests needed for here |
72020bd
to
12af57c
Compare
circleci is no longer in use, so we can ignore that |
go.mod
Outdated
@@ -36,6 +36,7 @@ require ( | |||
github.com/tetratelabs/getenvoy-package v0.0.0-20190730071641-da31aed4333e | |||
github.com/tetratelabs/log v0.0.0-20190710134534-eb04d1e84fb8 | |||
github.com/tetratelabs/multierror v1.1.0 | |||
github.com/tetratelabs/proxy-wasm-go-sdk v0.12.0 |
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.
one glitch of renaming go.mod -> go.mod_ is that if you do go mod tidy
, this pops into the root go.mod only because the examples import it. I'll look into it..
This reduces build complexity by eliminating a generation step with go:embed. This implicitly reduces tech debt even more because not only were we using a stalled project, statik, but also a fork of it. go:embed is not perfect, as it disallows the file name go.mod. The workaround is to rename it to go.mod_ per golang/go#45197. While this is imperfect an if-statement is a far better punch than a dependency on a fork of a stalled project which also requires a codegen step. Signed-off-by: Adrian Cole <adrian@tetrate.io>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
12af57c
to
554af22
Compare
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Thanks for the review @mathetake! |
This reduces build complexity by eliminating a generation step with go:embed. This implicitly reduces tech debt even more because not only were we using a stalled project, statik, but also a fork of it.
go:embed is not perfect, as it disallows the file name
go.mod
. The workaround is to rename it togo.mod_
per golang/go#45197. While this is imperfect an if-statement is a far better punch than a dependency on a fork of a stalled project which also requires a codegen step.Fixes #126