Skip to content

Commit

Permalink
Make --watch work with ko:// (#250)
Browse files Browse the repository at this point in the history
The dep-notify package doesn't know anything about ko, so we need to
trim the strict prefix before sending import paths over to it.
  • Loading branch information
jonjohnsonjr committed Nov 20, 2020
1 parent 1c70438 commit b843019
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/commands/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"log"
"net/http"
"os"
"strings"
"sync"

"github.com/google/go-containerregistry/pkg/authn"
Expand Down Expand Up @@ -232,9 +233,12 @@ func resolveFilesToWriter(
value := v.([]string)

for _, ip := range value {
// dep-notify doesn't understand the ko:// prefix
ip := strings.TrimPrefix(ip, build.StrictScheme)
if ss.Has(ip) {
// See the comment above about how "builder" works.
builder.Invalidate(ip)
// Always use ko:// for the builder.
builder.Invalidate(build.StrictScheme + ip)
fs <- key
}
}
Expand Down Expand Up @@ -309,13 +313,16 @@ func resolveFilesToWriter(
ch <- b
if fo.Watch {
for _, ip := range recordingBuilder.ImportPaths {
// dep-notify doesn't understand the ko:// prefix
ip := strings.TrimPrefix(ip, build.StrictScheme)

// Technically we never remove binary targets from the graph,
// which will increase our graph's watch load, but the
// notifications that they change will result in no affected
// yamls, and no new builds or deploys.
if err := g.Add(ip); err != nil {
// If we're in watch mode, just fail.
err := fmt.Errorf("adding importpath to dep graph: %v", err)
err := fmt.Errorf("adding importpath %q to dep graph: %v", ip, err)
errCh <- err
return err
}
Expand Down

0 comments on commit b843019

Please sign in to comment.