-
Notifications
You must be signed in to change notification settings - Fork 38
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: Check file format when uploading artifacts #270
base: master
Are you sure you want to change the base?
Conversation
@bahaa-ghazal, Let me know if you want to start the integration pipeline by mentioning me and the command "start pipeline". my commands and optionsYou can trigger a pipeline on multiple prs with:
You can start a fast pipeline, disabling full integration tests with:
You can trigger GitHub->GitLab branch sync with:
You can cherry pick to a given branch or branches with:
|
Changelog: Title Ticket: MEN-7860 Signed-off-by: Bahaa Aldeen Ghazal <[email protected]>
033f311
to
2121f28
Compare
Merging these commits will result in the following changelog entries: Changelogsmender-cli (MEN-7860)New changes in mender-cli since master: Bug Fixes
|
tr := tar.NewReader(artifact) | ||
versionH, err := tr.Next() | ||
if err != nil { | ||
return errors.Wrap(err, "Cannot find artifact") |
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.
Can we adjust the error message a little?
I found the current message quite confusing when I was testing the CLI.
return errors.Wrap(err, "Cannot find artifact") | |
return errors.Wrap(err, "error parsing artifact") |
tr := tar.NewReader(artifact) | ||
versionH, err := tr.Next() | ||
if err != nil { | ||
return errors.Wrap(err, "Cannot find artifact") | ||
} else if versionH.Name != "version" { | ||
return errors.New("Invalid artifact format") | ||
} | ||
v := struct { | ||
Format string `json:"format"` | ||
}{} | ||
err = json.NewDecoder(tr).Decode(&v) | ||
if err != nil || v.Format != "mender" { | ||
return errors.New("Invalid artifact format") | ||
} | ||
_, err = artifact.Seek(0, io.SeekStart) | ||
if err != nil || v.Format != "mender" { | ||
return err | ||
} |
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.
Nitpick: Can you refactor this artifact parsing part into it's own function and reuse it below?
Duplicating code often leads to forgetting about the existence about the other instance when touching the code later.
Changelog: Title
Ticket: MEN-7860