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

Detect ko images for debugging, by image author #6569

Merged
merged 1 commit into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions pkg/skaffold/debug/apply_transforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions pkg/skaffold/debug/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pkg/skaffold/debug/transform_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pkg/skaffold/debug/transform_go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}},
Expand Down