-
Notifications
You must be signed in to change notification settings - Fork 59
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
Fix compute pack
to produce expected package.tar.gz
file name
#662
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.
Here are some comments to help guide the reviewer...
@@ -16,9 +16,7 @@ require ( | |||
github.com/getsentry/sentry-go v0.12.0 | |||
github.com/google/go-cmp v0.5.6 | |||
github.com/google/go-github/v38 v38.1.0 | |||
github.com/kennygrant/sanitize v1.2.4 |
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.
ℹ️ Now we no longer generate a package name from information in the user's fastly.toml
manifest file, it means we don't need this dependency.
@@ -39,6 +39,8 @@ func (c *PackCommand) Exec(_ io.Reader, out io.Writer) (err error) { | |||
progress := text.NewProgress(out, c.Globals.Verbose()) | |||
|
|||
defer func(errLog fsterr.LogInterface) { | |||
os.RemoveAll("pkg/package") |
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.
ℹ️ In the compute build
command we create a 'temp' directory to store files that are placed into the final package.tar.gz
, and then clean up the temp directory. So we are now doing the same thing here, and are just making sure we clean-up after ourselves.
bin := "pkg/package/bin/main.wasm" | ||
bindir := filepath.Dir(bin) |
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.
ℹ️ I'm just renaming variables for greater clarity, as the previous names were a bit too ambiguous.
@@ -91,7 +92,7 @@ func (c *PackCommand) Exec(_ io.Reader, out io.Writer) (err error) { | |||
|
|||
progress.Step("Copying manifest...") | |||
src = manifest.Filename | |||
dst = fmt.Sprintf("pkg/%s/%s", name, manifest.Filename) | |||
dst = fmt.Sprintf("pkg/package/%s", manifest.Filename) |
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.
ℹ️ Here is the crux of the PR, this is where we're fixing the destination path.
@@ -36,41 +34,17 @@ func TestPack(t *testing.T) { | |||
"Creating .tar.gz file...", | |||
}, | |||
expectedFiles: [][]string{ | |||
{"pkg", "mypackagename", "bin", "main.wasm"}, |
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.
ℹ️ Now we're cleaning up after ourselves we need to fix the tests to not check for that directory/files any more.
}, | ||
}, | ||
// The following test validates that the expected directory structure was |
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 test is redundant considering we no longer generate a package using the name
field from the fastly.toml
manifest file, and so validating that the code works when a name
field has a space in the value is unnecessary.
* fix pack command to generate generic package.tar.gz file name * clean up the pkg directory
We updated the
compute build
andcompute deploy
commands to generate, and lookup, a package inside/pkg/package.tar.gz
but we then neglected to update thecompute pack
command (which still had the old behaviour of dynamically generating the package filename, e.g./pkg/<dynamic_name>.tar.gz
).