diff --git a/pkg/skaffold/debug/apply_transforms.go b/pkg/skaffold/debug/apply_transforms.go index 28aaed9b835..b875880a384 100644 --- a/pkg/skaffold/debug/apply_transforms.go +++ b/pkg/skaffold/debug/apply_transforms.go @@ -73,6 +73,7 @@ func retrieveImageConfiguration(ctx context.Context, artifact *graph.Artifact, i // need to duplicate slices as apiClient caches requests return ImageConfiguration{ Artifact: artifact.ImageName, + Author: manifest.Author, Env: envAsMap(config.Env), Entrypoint: dupArray(config.Entrypoint), Arguments: dupArray(config.Cmd), diff --git a/pkg/skaffold/debug/transform.go b/pkg/skaffold/debug/transform.go index f47b17976bd..547c3a3d293 100644 --- a/pkg/skaffold/debug/transform.go +++ b/pkg/skaffold/debug/transform.go @@ -73,6 +73,7 @@ type ImageConfiguration struct { // Artifact is the corresponding Artifact's image name (`pkg/skaffold/build.Artifact.ImageName`) Artifact string + Author string Labels map[string]string Env map[string]string Entrypoint []string diff --git a/pkg/skaffold/debug/transform_go.go b/pkg/skaffold/debug/transform_go.go index c85c8b0bcf6..e888bb75063 100644 --- a/pkg/skaffold/debug/transform_go.go +++ b/pkg/skaffold/debug/transform_go.go @@ -70,6 +70,11 @@ func (t dlvTransformer) IsApplicable(config ImageConfiguration) bool { return true } } + // Detect ko image by author, see https://github.com/google/ko/blob/v0.8.3/pkg/build/gobuild.go#L610 + if config.Author == "github.com/google/ko" { + log.Entry(context.TODO()).Infof("Artifact %q has Go runtime: has author %q", config.Artifact, config.Author) + return true + } // FIXME: as there is currently no way to identify a buildpacks-produced image as holding a Go binary, // nor to cause certain environment variables to be defined in the resulting image, look at the image's diff --git a/pkg/skaffold/debug/transform_go_test.go b/pkg/skaffold/debug/transform_go_test.go index 2eaf37973fe..8d5cc20f694 100644 --- a/pkg/skaffold/debug/transform_go_test.go +++ b/pkg/skaffold/debug/transform_go_test.go @@ -97,6 +97,11 @@ func TestDlvTransformer_IsApplicable(t *testing.T) { launcher: "launcher", result: true, }, + { + description: "ko author", + source: ImageConfiguration{Author: "github.com/google/ko"}, + result: true, + }, { description: "entrypoint /bin/sh", source: ImageConfiguration{Entrypoint: []string{"/bin/sh"}},