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

Add debug flag to include delve #1320

Merged
merged 11 commits into from
Jun 11, 2024
13 changes: 13 additions & 0 deletions pkg/build/gobuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,16 @@ func getGoBinary() string {
return defaultGoBin
}

func doesPlatformSupportDebugging(platform v1.Platform) bool {
// Here's the list of supported platforms by Delve:
//
// https://github.com/go-delve/delve/blob/master/Documentation/faq.md#unsupportedplatforms
//
// For the time being, we'll support only linux/amd64 and linux/arm64.
imjasonh marked this conversation as resolved.
Show resolved Hide resolved

return platform.OS == "linux" && (platform.Architecture == "amd64" || platform.Architecture == "arm64")
}

func getDelve(ctx context.Context, platform v1.Platform) (string, error) {
env, err := buildEnv(platform, os.Environ(), nil)
if err != nil {
Expand Down Expand Up @@ -969,6 +979,9 @@ func (g *gobuild) buildOne(ctx context.Context, refStr string, base v1.Image, pl
OSVersion: cf.OSVersion,
}
}
if g.debug && !doesPlatformSupportDebugging(*platform) {
return nil, fmt.Errorf("debugging is not supported for %s", platform)
imjasonh marked this conversation as resolved.
Show resolved Hide resolved
}

if !g.platformMatcher.matches(platform) {
return nil, fmt.Errorf("base image platform %q does not match desired platforms %v", platform, g.platformMatcher.platforms)
Expand Down
Loading