Skip to content

Commit

Permalink
Print platform variant when building go binary (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjohnsonjr authored Nov 20, 2020
1 parent bd1ec54 commit 1c70438
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/build/gobuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ func getGoarm(platform v1.Platform) (string, error) {
return "", nil
}

// TODO(jonjohnsonjr): Upstream something like this.
func platformToString(p v1.Platform) string {
if p.Variant != "" {
return fmt.Sprintf("%s/%s/%s", p.OS, p.Architecture, p.Variant)
}
return fmt.Sprintf("%s/%s", p.OS, p.Architecture)
}

func build(ctx context.Context, ip string, platform v1.Platform, disableOptimizations bool) (string, error) {
tmpDir, err := ioutil.TempDir("", "ko")
if err != nil {
Expand Down Expand Up @@ -272,7 +280,7 @@ func build(ctx context.Context, ip string, platform v1.Platform, disableOptimiza
cmd.Stderr = &output
cmd.Stdout = &output

log.Printf("Building %s for %s/%s", ip, platform.OS, platform.Architecture)
log.Printf("Building %s for %s", ip, platformToString(platform))
if err := cmd.Run(); err != nil {
os.RemoveAll(tmpDir)
log.Printf("Unexpected error running \"go build\": %v\n%v", err, output.String())
Expand Down

0 comments on commit 1c70438

Please sign in to comment.