Skip to content

Commit 0da149a

Browse files
authored
Plumb context.Context down into functions in pkg/skaffold/sync (#6535)
1 parent dd7e1e7 commit 0da149a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pkg/skaffold/sync/sync.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ func syncItem(ctx context.Context, a *latestV1.Artifact, tag string, e filemon.E
8787
return nil, fmt.Errorf("retrieving working dir for %q: %w", tag, err)
8888
}
8989

90-
toCopy, err := intersect(a.Workspace, containerWd, syncRules, append(e.Added, e.Modified...))
90+
toCopy, err := intersect(ctx, a.Workspace, containerWd, syncRules, append(e.Added, e.Modified...))
9191
if err != nil {
9292
return nil, fmt.Errorf("intersecting sync map and added, modified files: %w", err)
9393
}
9494

95-
toDelete, err := intersect(a.Workspace, containerWd, syncRules, e.Deleted)
95+
toDelete, err := intersect(ctx, a.Workspace, containerWd, syncRules, e.Deleted)
9696
if err != nil {
9797
return nil, fmt.Errorf("intersecting sync map and deleted files: %w", err)
9898
}
@@ -134,14 +134,14 @@ func inferredSyncItem(ctx context.Context, a *latestV1.Artifact, tag string, e f
134134
}
135135
}
136136
if !matches {
137-
log.Entry(context.TODO()).Infof("Changed file %s does not match any sync pattern. Skipping sync", relPath)
137+
log.Entry(ctx).Infof("Changed file %s does not match any sync pattern. Skipping sync", relPath)
138138
return nil, nil
139139
}
140140

141141
if dsts, ok := syncMap[relPath]; ok {
142142
toCopy[f] = dsts
143143
} else {
144-
log.Entry(context.TODO()).Infof("Changed file %s is not syncable. Skipping sync", relPath)
144+
log.Entry(ctx).Infof("Changed file %s is not syncable. Skipping sync", relPath)
145145
return nil, nil
146146
}
147147
}
@@ -206,7 +206,7 @@ func latestTag(image string, builds []graph.Artifact) string {
206206
return ""
207207
}
208208

209-
func intersect(contextWd, containerWd string, syncRules []*latestV1.SyncRule, files []string) (syncMap, error) {
209+
func intersect(ctx context.Context, contextWd, containerWd string, syncRules []*latestV1.SyncRule, files []string) (syncMap, error) {
210210
ret := make(syncMap)
211211
for _, f := range files {
212212
relPath, err := filepath.Rel(contextWd, f)
@@ -220,7 +220,7 @@ func intersect(contextWd, containerWd string, syncRules []*latestV1.SyncRule, fi
220220
}
221221

222222
if len(dsts) == 0 {
223-
log.Entry(context.TODO()).Infof("Changed file %s does not match any sync pattern. Skipping sync", relPath)
223+
log.Entry(ctx).Infof("Changed file %s does not match any sync pattern. Skipping sync", relPath)
224224
return nil, nil
225225
}
226226

pkg/skaffold/sync/sync_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ func TestIntersect(t *testing.T) {
826826
}
827827
for _, test := range tests {
828828
testutil.Run(t, test.description, func(t *testutil.T) {
829-
actual, err := intersect(test.context, test.workingDir, test.syncRules, test.files)
829+
actual, err := intersect(context.TODO(), test.context, test.workingDir, test.syncRules, test.files)
830830

831831
t.CheckErrorAndDeepEqual(test.shouldErr, err, test.expected, actual)
832832
})

0 commit comments

Comments
 (0)