Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup /v2/skaffoldLogs endpoint #5951

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pkg/skaffold/event/v2/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ type eventHandler struct {
logLock sync.Mutex
applicationLogs []proto.Event
applicationLogsLock sync.Mutex
skaffoldLogs []proto.Event
skaffoldLogsLock sync.Mutex
cfg Config

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

type listener struct {
Expand All @@ -101,6 +104,10 @@ 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 @@ -178,6 +185,10 @@ 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
4 changes: 4 additions & 0 deletions pkg/skaffold/server/v2/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ 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