Skip to content

Commit e62f675

Browse files
authored
add logrus.Logger return type on WithEventContext() (#6309)
1 parent 9f0acfa commit e62f675

File tree

9 files changed

+15
-13
lines changed

9 files changed

+15
-13
lines changed

pkg/skaffold/build/cache/retrieve.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (c *cache) Build(ctx context.Context, out io.Writer, tags tag.ImageTags, ar
6262
var alreadyBuilt []graph.Artifact
6363
for i, artifact := range artifacts {
6464
eventV2.CacheCheckInProgress(artifact.ImageName)
65-
out := output.WithEventContext(out, constants.Build, artifact.ImageName)
65+
out, _ := output.WithEventContext(out, constants.Build, artifact.ImageName)
6666
output.Default.Fprintf(out, " - %s: ", artifact.ImageName)
6767

6868
result := results[i]

pkg/skaffold/build/scheduler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func (s *scheduler) build(ctx context.Context, tags tag.ImageTags, i int) error
108108
}
109109
defer closeFn()
110110

111-
w = output.WithEventContext(w, constants.Build, a.ImageName)
111+
w, _ = output.WithEventContext(w, constants.Build, a.ImageName)
112112
finalTag, err := performBuild(ctx, w, tags, a, s.artifactBuilder)
113113
if err != nil {
114114
event.BuildFailed(a.ImageName, err)

pkg/skaffold/deploy/deploy_mux.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (m DeployerMux) RegisterLocalImages(images []graph.Artifact) {
102102
func (m DeployerMux) Deploy(ctx context.Context, w io.Writer, as []graph.Artifact) error {
103103
for i, deployer := range m.deployers {
104104
eventV2.DeployInProgress(i)
105-
w = output.WithEventContext(w, constants.Deploy, strconv.Itoa(i))
105+
w, _ = output.WithEventContext(w, constants.Deploy, strconv.Itoa(i))
106106
ctx, endTrace := instrumentation.StartTrace(ctx, "Deploy")
107107

108108
if err := deployer.Deploy(ctx, w, as); err != nil {

pkg/skaffold/kubernetes/portforward/entry_manager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func NewEntryManager(entryForwarder EntryForwarder) *EntryManager {
115115
}
116116

117117
func (b *EntryManager) forwardPortForwardEntry(ctx context.Context, out io.Writer, entry *portForwardEntry) {
118-
out = output.WithEventContext(out, constants.PortForward, fmt.Sprintf("%s/%s", entry.resource.Type, entry.resource.Name))
118+
out, _ = output.WithEventContext(out, constants.PortForward, fmt.Sprintf("%s/%s", entry.resource.Type, entry.resource.Name))
119119

120120
// Check if this resource has already been forwarded
121121
if _, ok := b.forwardedResources.Load(entry.key()); ok {

pkg/skaffold/kubernetes/status/status_check.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ func (s *Monitor) printStatusCheckSummary(out io.Writer, r *resource.Deployment,
287287
}
288288
event.ResourceStatusCheckEventCompleted(r.String(), ae)
289289
eventV2.ResourceStatusCheckEventCompleted(r.String(), sErrors.V2fromV1(ae))
290-
out = output.WithEventContext(out, constants.Deploy, r.String())
290+
out, _ = output.WithEventContext(out, constants.Deploy, r.String())
291291
status := fmt.Sprintf("%s %s", tabHeader, r)
292292
if ae.ErrCode != proto.StatusCode_STATUSCHECK_SUCCESS {
293293
if str := r.ReportSinceLastUpdated(s.muteLogs); str != "" {
@@ -333,7 +333,7 @@ func (s *Monitor) printStatus(deployments []*resource.Deployment, out io.Writer)
333333
ae := r.Status().ActionableError()
334334
event.ResourceStatusCheckEventUpdated(r.String(), ae)
335335
eventV2.ResourceStatusCheckEventUpdated(r.String(), sErrors.V2fromV1(ae))
336-
out := output.WithEventContext(out, constants.Deploy, r.String())
336+
out, _ := output.WithEventContext(out, constants.Deploy, r.String())
337337
fmt.Fprintln(out, trimNewLine(str))
338338
}
339339
}

pkg/skaffold/output/output.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121
"os"
2222
"time"
2323

24+
"github.com/sirupsen/logrus"
25+
2426
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/constants"
2527
eventV2 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/event/v2"
2628
)
@@ -99,14 +101,14 @@ func GetUnderlyingWriter(out io.Writer) io.Writer {
99101

100102
// WithEventContext will return a new skaffoldWriter with the given parameters to be used for the event writer.
101103
// If the passed io.Writer is not a skaffoldWriter, then it is simply returned.
102-
func WithEventContext(out io.Writer, phase constants.Phase, subtaskID string) io.Writer {
104+
func WithEventContext(out io.Writer, phase constants.Phase, subtaskID string) (io.Writer, *logrus.Logger) {
103105
if sw, isSW := out.(skaffoldWriter); isSW {
104106
return skaffoldWriter{
105107
MainWriter: sw.MainWriter,
106108
EventWriter: eventV2.NewLogger(phase, subtaskID),
107109
timestamps: sw.timestamps,
108-
}
110+
}, nil
109111
}
110112

111-
return out
113+
return out, nil
112114
}

pkg/skaffold/output/output_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func TestWithEventContext(t *testing.T) {
152152

153153
for _, test := range tests {
154154
testutil.Run(t, test.name, func(t *testutil.T) {
155-
got := WithEventContext(test.writer, test.phase, test.subtaskID)
155+
got, _ := WithEventContext(test.writer, test.phase, test.subtaskID)
156156
t.CheckDeepEqual(test.expected, got, cmpopts.IgnoreTypes(false))
157157
})
158158
}

pkg/skaffold/runner/build.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func (r *Builder) GetBuilds() []graph.Artifact {
6565
// Build builds a list of artifacts.
6666
func (r *Builder) Build(ctx context.Context, out io.Writer, artifacts []*latestV1.Artifact) ([]graph.Artifact, error) {
6767
eventV2.TaskInProgress(constants.Build, "Build containers")
68-
out = output.WithEventContext(out, constants.Build, eventV2.SubtaskIDNone)
68+
out, _ = output.WithEventContext(out, constants.Build, eventV2.SubtaskIDNone)
6969

7070
// Use tags directly from the Kubernetes manifests.
7171
if r.runCtx.DigestSource() == NoneDigestSource {
@@ -172,7 +172,7 @@ func (r *Builder) imageTags(ctx context.Context, out io.Writer, artifacts []*lat
172172

173173
for i, artifact := range artifacts {
174174
imageName := artifact.ImageName
175-
out := output.WithEventContext(out, constants.Build, imageName)
175+
out, _ := output.WithEventContext(out, constants.Build, imageName)
176176
output.Default.Fprintf(out, " - %s -> ", imageName)
177177

178178
select {

pkg/skaffold/runner/v1/deploy.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (r *SkaffoldRunner) Deploy(ctx context.Context, out io.Writer, artifacts []
6969
}
7070
defer r.deployer.GetStatusMonitor().Reset()
7171

72-
out = output.WithEventContext(out, constants.Deploy, eventV2.SubtaskIDNone)
72+
out, _ = output.WithEventContext(out, constants.Deploy, eventV2.SubtaskIDNone)
7373

7474
output.Default.Fprintln(out, "Tags used in deployment:")
7575

0 commit comments

Comments
 (0)