-
Notifications
You must be signed in to change notification settings - Fork 117
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
Build zipped package #550
Build zipped package #550
Conversation
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
The package registry tried to load the .zip archive, but it failed:
@jsoriano should I start the EPR differently? |
The problem seems to be in the format of the package. Implementation in package-registry expects to have the files under the This is an example package in the package registry repo:
This is a package built with this implementation:
I think I did this because I don't like archives that you decompress and they spread all over the current directory 🙂 But we are probably in time to reconsider this format if needed. (Btw, side thoughts now, having the package assets inside a directory might allow to embed in the zip other validation or control data, like a signature 🙂) |
I think we need to be consistent with current .zip files, for example: https://epr.elastic.co/epr/aws/aws-1.1.0.zip , so I will adjust the logic here :)
So with this approach we agree on the content addressed signatures. WDYT? |
ImplicitTopLevelFolder: false, | ||
} | ||
|
||
// Create a temporary work directory to properly name the root directory in the archive, e.g. aws-1.0.1 |
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 used the temporary folder with proper name to create the .zip package with root <packageName>-<version>
. It's a workaround for mholt/archiver, which doesn't support it.
If you think that copy to temp is an overkill, I will have to implement our own simple zip archiver.
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.
SGTM, we can revisit it later if problems are found.
Ah yes, this is a stronger point 🙂
This would be some kind of content addressed signatures, yes. The good point is that everything would be contained inside the package, we wouldn't need an extra file for the signature. Do you have any preference? |
To be honest I prefer the extra file as it's more intuitive :) Take the .zip file, sign it and have a signature. Frankly speaking we need to decide about this now, as it impacts both PRs: this and EPR. |
internal/files/compress.go
Outdated
tempDir := filepath.Join(os.TempDir(), folderNameFromFileName(destinationFile)) | ||
os.MkdirAll(tempDir, 0755) | ||
defer os.RemoveAll(tempDir) |
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.
Consider using os.MkdirTemp()
to be sure that different executions don't affect each other.
tempDir := filepath.Join(os.TempDir(), folderNameFromFileName(destinationFile)) | |
os.MkdirAll(tempDir, 0755) | |
defer os.RemoveAll(tempDir) | |
tmpBaseDir, err := os.MkdirTemp("", "elastic-package-") | |
if err != nil { ... } | |
defer os.RemoveAll(tmpBaseDir) | |
tempDir := filepath.Join(tmpBaseDir, folderNameFromFileName(destinationFile)) | |
os.MkdirAll(tempDir, 0755) |
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 can try it, but have to preserve the last element (for example: aws-1.0.1
).
ImplicitTopLevelFolder: false, | ||
} | ||
|
||
// Create a temporary work directory to properly name the root directory in the archive, e.g. aws-1.0.1 |
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.
SGTM, we can revisit it later if problems are found.
Ok, let's go with the extra file. |
internal/files/compress.go
Outdated
} | ||
workDir := filepath.Join(tempDir, folderNameFromFileName(destinationFile)) | ||
os.MkdirAll(workDir, 0755) | ||
defer os.RemoveAll(tempDir) |
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 defer should be immediately after the if err...
. If at some moment we handle the error returned by MkdirAll
and return there we may forget of removing the temp dir.
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.
Thanks, fixed
Issue: elastic/package-registry#728
This PR modifies:
-
build
command to also built .zip packages (--zip
flag)-
clean
command to clean built .zip