Skip to content

Commit

Permalink
fix: Allow partial match for manual sync
Browse files Browse the repository at this point in the history
  • Loading branch information
simonstratmann committed Mar 18, 2024
1 parent eeafea6 commit b62745c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
7 changes: 1 addition & 6 deletions pkg/skaffold/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ func latestTag(image string, builds []graph.Artifact) string {

func intersect(ctx context.Context, contextWd, containerWd string, syncRules []*latest.SyncRule, files []string) (syncMap, error) {
ret := make(syncMap)
hadMismatch := false
for _, f := range files {
relPath, err := filepath.Rel(contextWd, f)
if err != nil {
Expand All @@ -240,16 +239,12 @@ func intersect(ctx context.Context, contextWd, containerWd string, syncRules []*
}

if len(dsts) == 0 {
log.Entry(ctx).Infof("Changed file %s does not match any sync pattern. Skipping sync", relPath)
hadMismatch = true
log.Entry(ctx).Infof("Changed file %s does not match any sync pattern. Skipping sync for it", relPath)
continue
}

ret[f] = dsts
}
if len(ret) == 0 && hadMismatch {
return nil, nil
}
return ret, nil
}

Expand Down
20 changes: 19 additions & 1 deletion pkg/skaffold/sync/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@ func TestNewSyncItem(t *testing.T) {
Tag: "placeholder",
},
},
expected: &Item{
Image: "placeholder",
Copy: map[string][]string{},
Delete: map[string][]string{
"index.html": {"index.html"},
},
},
},
{
description: "manual: not delete syncable",
Expand All @@ -289,6 +296,13 @@ func TestNewSyncItem(t *testing.T) {
Tag: "placeholder",
},
},
expected: &Item{
Image: "placeholder",
Copy: map[string][]string{
"index.html": {"/static/index.html"},
},
Delete: map[string][]string{},
},
},
{
description: "manual: err bad pattern",
Expand Down Expand Up @@ -767,7 +781,11 @@ func TestNewSyncItem(t *testing.T) {
}]
}`,
},
expected: nil,
expected: &Item{
Image: "test:123",
Copy: map[string][]string{},
Delete: map[string][]string{},
},
},

// Auto with Jib
Expand Down

0 comments on commit b62745c

Please sign in to comment.