Skip to content

Commit

Permalink
Remove skaffoldLogs endpoint, consolidate into events endpoint (Googl…
Browse files Browse the repository at this point in the history
…eContainerTools#6296)

* remote skaffoldLogs endpoint, consolidate into events endpoint

* update test
  • Loading branch information
MarlonGamez authored Jul 27, 2021
1 parent b4c2367 commit 4956efb
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 295 deletions.
19 changes: 0 additions & 19 deletions pkg/skaffold/event/v2/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ type eventHandler struct {
logLock sync.Mutex
applicationLogs []proto.Event
applicationLogsLock sync.Mutex
skaffoldLogs []proto.Event
skaffoldLogsLock sync.Mutex
cfg Config

iteration int
Expand All @@ -80,7 +78,6 @@ type eventHandler struct {
eventChan chan *proto.Event
eventListeners []*listener
applicationLogListeners []*listener
skaffoldLogListeners []*listener
}

type listener struct {
Expand All @@ -106,10 +103,6 @@ func ForEachApplicationLog(callback func(*proto.Event) error) error {
return handler.forEachApplicationLog(callback)
}

func ForEachSkaffoldLog(callback func(*proto.Event) error) error {
return handler.forEachSkaffoldLog(callback)
}

func Handle(event *proto.Event) error {
if event != nil {
handler.handle(event)
Expand Down Expand Up @@ -155,10 +148,6 @@ func (ev *eventHandler) logApplicationLog(event *proto.Event) {
ev.log(event, &ev.applicationLogListeners, &ev.applicationLogs, &ev.applicationLogsLock)
}

func (ev *eventHandler) logSkaffoldLog(event *proto.Event) {
ev.log(event, &ev.skaffoldLogListeners, &ev.skaffoldLogs, &ev.skaffoldLogsLock)
}

func (ev *eventHandler) forEach(listeners *[]*listener, log *[]proto.Event, lock sync.Locker, callback func(*proto.Event) error) error {
listener := &listener{
callback: callback,
Expand Down Expand Up @@ -191,10 +180,6 @@ func (ev *eventHandler) forEachApplicationLog(callback func(*proto.Event) error)
return ev.forEach(&ev.applicationLogListeners, &ev.applicationLogs, &ev.applicationLogsLock, callback)
}

func (ev *eventHandler) forEachSkaffoldLog(callback func(*proto.Event) error) error {
return ev.forEach(&ev.skaffoldLogListeners, &ev.skaffoldLogs, &ev.skaffoldLogsLock, callback)
}

func emptyState(cfg Config) proto.State {
builds := map[string]string{}
for _, p := range cfg.GetPipelines() {
Expand Down Expand Up @@ -316,7 +301,6 @@ func TaskInProgress(task constants.Phase, description string) {
handler.iteration++

handler.applicationLogs = []proto.Event{}
handler.skaffoldLogs = []proto.Event{}
}

handler.handleTaskEvent(&proto.TaskEvent{
Expand Down Expand Up @@ -402,9 +386,6 @@ func (ev *eventHandler) handleExec(event *proto.Event) {
case *proto.Event_ApplicationLogEvent:
ev.logApplicationLog(event)
return
case *proto.Event_SkaffoldLogEvent:
ev.logSkaffoldLog(event)
return
case *proto.Event_BuildSubtaskEvent:
be := e.BuildSubtaskEvent
if be.Step == Build {
Expand Down
6 changes: 3 additions & 3 deletions pkg/skaffold/event/v2/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ func TestHandleSkaffoldLogEvent(t *testing.T) {
})
}
wait(t, func() bool {
testHandler.skaffoldLogsLock.Lock()
logLen := len(testHandler.skaffoldLogs)
testHandler.skaffoldLogsLock.Unlock()
testHandler.logLock.Lock()
logLen := len(testHandler.eventLog)
testHandler.logLock.Unlock()
return logLen == len(messages)
})
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/skaffold/server/v2/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ func (s *Server) ApplicationLogs(_ *empty.Empty, stream proto.SkaffoldV2Service_
return event.ForEachApplicationLog(stream.Send)
}

func (s *Server) SkaffoldLogs(_ *empty.Empty, stream proto.SkaffoldV2Service_SkaffoldLogsServer) error {
return event.ForEachSkaffoldLog(stream.Send)
}

func (s *Server) Handle(ctx context.Context, e *proto.Event) (*empty.Empty, error) {
return &empty.Empty{}, event.Handle(e)
}
Expand Down
Loading

0 comments on commit 4956efb

Please sign in to comment.