-
-
Notifications
You must be signed in to change notification settings - Fork 576
Add reload.FS for hot reloading during development #2180
Conversation
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.
Hi @fasmat, nice work!
I added some comments and suggestions. Please consider them.
I tested creating a new app with this PR along with gobuffalo/cli#60 and the result was excellent! the live loading worked perfectly as before! I think we can merge it once we agreed with the name of the module, and some minor bugs could be managed after this hotfix was released. |
How about we move this functionality to the root of the |
Wow! I love the name! |
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.
Nice work! I hope we can have it as soon as possible!
Hey Folks! This is exciting, as for the hot reloading mechanics, just to confirm:
Am I right with those assumptions? |
@fasmat I love it! It's really exciting to see this progress! Adding here my 5 cents: I would suggest to add some tests to Also, and to add some context, there was a security issue in Packr we should keep in mind here. At some point Packr was allowing to read relative folders, opening the entire docker container to the world. This was a security issue as things like environment variables usually are stored in OSs files. As for how this should work we need to make our buffalo.FS consider the environment variable (GO_ENV) and only use disk FS when |
No this is not true. It behaves similarly to how packr functioned: if the requested files can be found on the disk, those will be used. Otherwise it will use the embedded files. EDIT: there are now also tests that check for exactly this behavior. |
@paganotoni Thanks for the feedback 😄 I'll see what I can do. The functionality is very limited. The whole thing is just 2 methods that basically just override the functions of
I don't think this is necessary @sio4 mentioned the use case of not having embedded files in production, which used to work with packr and maybe some other users also rely on. Regarding the security issue with relative folders: both EDIT: EDIT2: just to be 100% certain that this is really the case I added a test that checks for exactly this. As I expected no |
ok. Thanks @fasmat, It's great to know that stdlib is covering that issue. I would suggest that as part of testing the fallback behavior we're implementing in buffalo.FS we add some of those relative paths test, maybe just one to have as a guarantee of what we expect from this FS implementation. |
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.
Awesome. Thanks @fasmat !
This adds an implementation of
fs.FS
that can do both: hot reload and embedding of files.embed.go
is automatically hidden from the embedded file system.There is a related PR here: gobuffalo/cli#60
This PR updates the new command to generate
embed.go
files that use thereload.FS
.