Skip to content

Commit

Permalink
setup /v2/skaffoldLogs endpoint (GoogleContainerTools#5951)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarlonGamez authored and aaron-prindle committed Jun 7, 2021
1 parent f30fcc0 commit c6dd6f2
Show file tree
Hide file tree
Showing 6 changed files with 287 additions and 144 deletions.
24 changes: 16 additions & 8 deletions .github/workflows/integration-linux.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: release (linux)

on:
schedule:
- cron: "0 10 * * *"
# Triggers the workflow on push or pull request events
on: [push, pull_request]

jobs:

Expand All @@ -14,9 +13,9 @@ jobs:
kustomize_version: [3.5.4]
ko_version: [0.4.0]
kompose_version: [1.21.0]
gcloud_sdk_version: [276.0.0]
gcloud_sdk_version: [343.0.0]
container_structure_tests_version: [1.8.0]
minikube_version: [1.11.0]
minikube_version: [1.20.0]
integration_test_partitions: [0, 1, 2, 3]
steps:

Expand Down Expand Up @@ -72,16 +71,25 @@ jobs:
echo '{}' > /home/$(whoami)/.docker/config.json
mkdir -p /home/$(whoami)/.m2/ && cp ./hack/maven/settings.xml /home/$(whoami)/.m2/settings.xml
# - name: Setup other files and permissions
# run: |
# sudo chown $(whoami) /home/$(whoami)/.config/gcloud -R
# sudo chmod g+rw /home/$(whoami)/.config/gcloud -R
# sudo chown $(whoami):docker /home/$(whoami)/.docker -R
# sudo chmod g+rw /home/$(whoami)/.docker -R
# echo '{}' > /home/$(whoami)/.docker/config.json
# mkdir -p /home/$(whoami)/.m2/ && cp ./hack/maven/settings.xml /home/$(whoami)/.m2/settings.xml

- name: Install Minikube and start cluster
run: |
curl -Lo minikube https://storage.googleapis.com/minikube/releases/v${{ matrix.minikube_version }}/minikube-linux-amd64
sudo install minikube /usr/local/bin/minikube
minikube start --profile=minikube --driver=docker
- name: Install Skaffold release binary
- name: Make and Install Skaffold binary from current PR
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/builds/${{ env.SKAFFOLD_VERSION }}/skaffold-linux-amd64
sudo install skaffold /usr/local/bin/skaffold
make
sudo install "/home/$(whoami)/work/skaffold/skaffold/out/skaffold" /usr/local/bin/skaffold
- name: Run integration tests
env:
Expand Down
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

0 comments on commit c6dd6f2

Please sign in to comment.