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

defaultFlags is ignored #1450

Open
rh-hemartin opened this issue Nov 22, 2024 · 0 comments
Open

defaultFlags is ignored #1450

rh-hemartin opened this issue Nov 22, 2024 · 0 comments

Comments

@rh-hemartin
Copy link

rh-hemartin commented Nov 22, 2024

Hello! I'm trying to use defaultFlags but it looks like its ignored.

Here the reproducer:

mkdir ko-reproducer
cd ko-reproducer

cat <<EOF > main.go
package main

import "fmt"

func main() {
        fmt.Println("Hello World!")
}
EOF
go mod init example.com
go mod tidy
go build -cover .
GOCOVERDIR=hello ./example.com

This results in this error:

error: coverage meta-data emit failed: output directory "hello" inaccessible (err: stat hello: no such file or directory); no coverage data written
Hello World!
error: coverage counter data emit failed: output directory "hello" inaccessible (err: stat hello: no such file or directory); no coverage data written

Now with ko:

cat <<EOF > .ko.yaml
---
defaultFlags:
  - -cover
EOF

KOCACHE=kocache ko build . --push=false
GOCOVERDIR=hello ./kocache/bin/example.com/linux/amd64/out

Does not fail:

Hello World!

Now using "normal" flags:

cat <<EOF > .ko.yaml
---
builds:
- id: main
  main: ./
  flags:
    - -cover
EOF

rm -rf ./kocache
KOCACHE=kocache ko build . --push=false
GOCOVERDIR=hello ./kocache/bin/example.com/linux/amd64/out
error: coverage meta-data emit failed: output directory "hello" inaccessible (err: stat hello: no such file or directory); no coverage data written
Hello World!
error: coverage counter data emit failed: output directory "hello" inaccessible (err: stat hello: no such file or directory); no coverage data written

PD: I tested introducing a random string into defaultFlags and it does not fail, so its effectively ignored.
PD2: I can give it a go and try to fix it myself, but I want someone to confirm it first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant