Skip to content
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 log message when buildpack doesn't satisfy target constraints for builder #1801

Merged
merged 4 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/dist/buildmodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ type Target struct {
}

type Distribution struct {
Name string `json:"name" toml:"name"`
Name string `json:"name,omitempty" toml:"name,omitempty"`
Versions []string `json:"versions,omitempty" toml:"versions,omitempty"`
}
29 changes: 28 additions & 1 deletion pkg/dist/buildpack_descriptor.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dist

import (
"encoding/json"
"fmt"
"sort"
"strings"
Expand Down Expand Up @@ -84,7 +85,33 @@ func (b *BuildpackDescriptor) EnsureTargetSupport(os, arch, distroName, distroVe
}
}
}
return fmt.Errorf("buildpack %s does not support target: (%s %s, %s@%s)", style.Symbol(b.Info().FullName()), os, arch, distroName, distroVersion)
type osDistribution struct {
Name string `json:"name,omitempty"`
Version string `json:"version,omitempty"`
}
type target struct {
OS string `json:"os"`
Arch string `json:"arch"`
Distribution osDistribution `json:"distribution"`
}
return fmt.Errorf(
"unable to satisfy target os/arch constraints; build image: %s, buildpack %s: %s",
toJSONMaybe(target{
OS: os,
Arch: arch,
Distribution: osDistribution{Name: distroName, Version: distroVersion},
}),
style.Symbol(b.Info().FullName()),
toJSONMaybe(b.Targets()),
)
}

func toJSONMaybe(v interface{}) string {
b, err := json.Marshal(v)
if err != nil {
return fmt.Sprintf("%s", v) // hopefully v is a Stringer
}
return string(b)
}

func (b *BuildpackDescriptor) Kind() string {
Expand Down