-
Notifications
You must be signed in to change notification settings - Fork 58
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
Verify binaries are for correct platform #223
Conversation
verifyImage(src, "linux/arm64", "ARM") | ||
verifyImage(src, "linux/amd64", "x86") | ||
|
||
srcWithProto := fmt.Sprintf("docker://%s", src) |
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.
The docker run
was failing with the docker://
prefix.
dad3dca
to
612557b
Compare
"--entrypoint=sh", | ||
imageTag, | ||
"-c", ` | ||
apk add -U file > /dev/null |
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.
You can use text.Template
to clean this up
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.
@tdeebswihart what issue/advantage do you see here? I think string interpolation is fine for this use case. Since the quotes are easy to get right, escaping isn't an issue and it gives you helpful syntax highlighting to see where the variables are.
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 don't, it's just a nit
src/image_copy/main.go
Outdated
@@ -67,21 +70,68 @@ func getTags(dstTag string, updateMajor bool) []string { | |||
return tags | |||
} | |||
|
|||
func verifyImage(imageTag, platform, check string) { |
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.
You should rename check
to something like expectedArchitecture
as that's what we're looking for
src/image_copy/main.go
Outdated
cmd.Stdout = &out | ||
cmd.Stderr = &out | ||
err := cmd.Run() | ||
fmt.Println(out.String()) | ||
if err != nil { | ||
log.Fatal(err.Error()) | ||
} |
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.
cmd.Stdout = &out | |
cmd.Stderr = &out | |
err := cmd.Run() | |
fmt.Println(out.String()) | |
if err != nil { | |
log.Fatal(err.Error()) | |
} | |
out, err := cmd.CombinedOutput() | |
fmt.Println(string(out)) | |
if err != nil { | |
log.Fatal(err.Error()) | |
} |
CombinedOutput does all that for you
What was changed
Add verification step for Docker images before releasing them.
PS: I didn't add this to the build step because the risk is high that it would fail silently without anyone noticing.
Why?
To ensure we release the right binary for each platform.
Checklist
Closes
How was this tested:
Running from terminal:
Pass
Fail